Using the Command Line to Get Help

Hands-On Lab

 

Photo of Michael Christian

Michael Christian

Course Development Director in Content

Length

00:30:00

Difficulty

Beginner

In this hands-on lab, we'll make use of documentation available from the command line to answer specific questions about a command or file. Man and info pages are readily available, useful sources of documentation on Linux commands and configuration files.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Using the Command Line to Get Help

Introduction

In this hands-on lab, we'll make use of documentation available from the command line to answer specific questions about a file.

Connecting to the Lab

  1. Open your terminal application, and run the following command (remember to replace <PUBLIC_IP> with the public IP you were provided on the lab instructions page):
    ssh cloud_user@<PUBLIC_IP>
  2. Enter yes at the prompt.
  3. Enter your cloud_user password at the prompt.

Determine How Many Lines the File Contains

  1. Determine the current working directory.
    pwd
  2. List the contents of the current working directory.
    ls
  3. Open the man pages for the wc command.
    man wc
  4. Type / and search for line.
  5. Locate the line that contains the -l option, and read the description.
  6. Press q to exit the man pages.
  7. Determine the total number of lines in the file longfile.txt.
    wc -l longfile.txt
  8. Output the result to a new file named value.txt.
    wc -l longfile.txt > value.txt
  9. Verify that this was successful.
    cat value.txt

Determine the Number of Characters on the Longest Line

  1. Open the man pages for the wc command.
    man wc
  2. Locate the line that contains the -L option, and read the description.
  3. Press q to exit the man pages.
  4. Determine the number of characters on the longest line in the file longfile.txt.
    wc -L longfile.txt
  5. Append the result to the value.txt file.
    wc -L longfile.txt >> value.txt

Determine the Total Number of Characters in the File

  1. Open the man pages for the wc command.
    man wc
  2. Locate the line that contains the -m option, and read the description.
  3. Press q to exit the man pages.
  4. Determine the total number of characters in the file longfile.txt.
    wc -m longfile.txt
  5. Append the result to the value.txt file.
    wc -m longfile.txt >> value.txt
  6. List the contents of the value.txt file.
    cat value.txt

Conclusion

Congratulations, you've successfully completed this hands-on lab!