Skip to main content

Using Directories and Listing Files

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 will practice moving through directories and listing files. Becoming comfortable changing directories, and listing files is a necessary step in moving through a Linux file system.

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 Directories and Listing Files

Introduction

In this hands-on lab, we will practice moving through directories and listing files.

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 Which File Is the Oldest

  1. Determine the current working directory.
    pwd
  2. List the contents of the current working directory.
    ls
  3. Change to the Practice folder.
    cd Practice/
  4. List the contents of the Practice folder.
    ls
  5. Change to the Test folder.
    cd Test/
  6. Open the man page for the ls command.
    man ls
  7. Locate the entry for the -l option, and read the description.
  8. Locate the entry for the -A option, and read the description.
  9. Locate the entry for the -t option, and read the description.
  10. Run the following command to determine the oldest file:
    ls -lAt ~/Practice/Test/var/log/

Determine Which File Is the Largest

  1. Open the man page for the ls command.
    man ls
  2. Locate the entry for the -S option, and read the description.
  3. Run the following command to determine the largest file:
    ls -lS ~/Practice/Test/var/log/

Determine When the File ~/Practice/Test/sos_commands/networking/netstat_-W_-neopa Was Last Modified

  1. Run the following command:
    ls -l ~/Practice/Test/sos_commands/networking/netstat_-W_-neopa

Determine When the File ~/Practice/Test/sos_commands/networking/netstat_-W_-neopa Was Last Accessed

  1. Open the man page for the ls command.
    man ls
  2. Locate the entry for the -u option, and read the description.
  3. Run the following command to determine when the file was last accessed:
    ls -lu ~/Practice/Test/sos_commands/networking/netstat_-W_-neopa
  4. Check the current date to confirm.
    date

Conclusion

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