Get the current directory information

내 진행 상황 확인하기

/ 1

Change directory and list the subdirectories

내 진행 상황 확인하기

/ 1

Locate and read the contents of a file

내 진행 상황 확인하기

/ 1

Navigate to a directory and locate a file

내 진행 상황 확인하기

/ 1

이 실습에는 학습을 지원하는 AI 도구가 통합되어 있을 수 있습니다.

Activity overview

Previously, you learned about Linux and how to communicate with the OS through the shell. You also learned how to use some of the core commands to navigate the Linux file system and read content from files it contains.

These are essential skills. For example, when investigating unauthorized access, you might navigate to and then read a user access report.

In this lab activity, you’ll navigate a Linux file structure, locate files, and read the contents of files. You’ll also need to answer a few multiple-choice questions based on the information contained in these files.

As a security analyst, it’s key that you know how to navigate, manage, and analyze files remotely via a Linux shell without a graphical user interface.

Scenario

In this scenario, you have to locate and analyze the information of certain files located in the /home/analyst directory.

Here’s how you’ll do this: First, you’ll get the information of the current working directory you’re in and display the contents of the directory. Second, you’ll navigate to the reports directory and list the subdirectories it contains. Third, you’ll navigate to the users subdirectory and display the contents of the Q1_added_users.txt file. Finally, you’ll navigate to the logs directory and display the first 10 lines of a file it contains.

To complete these tasks, you'll need to use commands that you've previously learned in this course. Well, it's time to practice what you’ve learned. Let’s do this!

Note: The lab starts with your user account, called analyst, already logged in to the Bash shell. This means you can start with the tasks as soon as you click the Start Lab button. Disclaimer: For optimal performance and compatibility, it is recommended to use either Google Chrome or Mozilla Firefox browsers while accessing the labs.

Start your lab

You'll need to start the lab before you can access the materials. To do this, click the green “Start Lab” button at the top of the screen.

Lab Start button displayed.

After you click the Start Lab button, you will see a shell, where you will be performing further steps in the lab. You should have a shell like this:

Linux Terminal displayed.

When you have completed all the tasks, refer to the End your Lab section that follows the tasks for information on how to end your lab.

Task 1. Get the current directory information

In this task, you must use the commands you learned about to check the current working directory and list its contents.

  1. Display your working directory.

The command to complete this step:

pwd

This will show that your current working directory is your home directory.

/home/analyst
  1. Display the names of the files and directories in the current working directory.

The command to complete this step:

ls

The output should be:

logs projects reports temp

Answer: The lab starts with /home/analyst as your current working directory.

Answer: The lab starts with four subdirectories in the /home/analystdirectory, namely logs, notes, temp, and reports.

Click Check my progress to verify that you have completed this task correctly.

Get the current directory information Note: There is no penalty for clicking Check my progress and you’ll be shown a hint.

Task 2. Change directory and list the subdirectories

In this task, you must navigate to a new directory and determine the subdirectories it contains.

  1. Navigate to the /home/analyst/reports directory.

The command to complete this step using a relative path:

cd reports Note: The cd command accepts absolute and relative paths. An absolute path includes all the directories from the root of the file system and starts with a /. An alternative is a relative path, which is expressed starting from the current directory and starts without the initial /. The above command uses a relative path.

The command to complete this step using an absolute path:

cd /home/analyst/reports
  1. Display the files and subdirectories in the /home/analyst/reports directory.

The command to complete this step:

ls

The output should be:

users

Answer: The subdirectory contained in the /home/analyst/reports directory is called users.

Click Check my progress to verify that you have completed this task correctly.

Change directory and list the subdirectories

Task 3. Locate and read the contents of a file

In this task, you must navigate to a subdirectory and read the contents of a file it contains.

  1. Navigate to the /home/analyst/reports/users directory.

The command to complete this step:

cd /home/analyst/reports/users

The above command uses an absolute path. You could also use a relative path as follows:

cd users
  1. List the files in the current directory.

The command to complete this step:

ls
  1. Display the contents of the Q1_added_users.txt file.

The command to complete this step:

cat Q1_added_users.txt Note: The cat command prints the contents of a file to the shell. You can specify the file to display using absolute or relative paths.

The same command using an absolute path:

cat /home/analyst/reports/users/Q1_added_users.txt

Answer: The employee with username aezra works in the Human Resources department.

Answer: The employee_id of the employee with username mreed in the Information Technology department is 1104.

Click Check my progress to verify that you have completed this task correctly.

Locate and read the contents of a file

Task 4. Navigate to a directory and locate a file

In this task, you must navigate to a new directory, locate a file, and examine the contents of the file.

  1. Navigate to the /home/analyst/logs directory.

The command to complete this step:

cd /home/analyst/logs
  1. Display the name of the file it contains.

The command to complete this step:

ls

This command will display the following output:

server_logs.txt
  1. Display the first 10 lines of this file.

The command to complete this step:

head server_logs.txt Note: The head command displays just the beginning of a file, by default ten lines. You can specify how many lines to display using the -n argument, which specifies the number of lines to display.

Answer: There are three warning messages in the first 10 lines of the server_logs.txt file.

Click Check my progress to verify that you have completed this task correctly.

Navigate to a directory and locate a file

Conclusion

Great work!

You now have practical experience in using basic Linux Bash shell commands to

  • navigate directory structures with the cd command,
  • display the current working directory with the pwd command,
  • list the contents of a directory with the ls command, and
  • display the contents of files with the cat and head commands.

Navigating through directories and reading file contents are fundamental skills that you’ll often use when communicating through the shell.

End your lab

Before you end the lab, make sure you’re satisfied that you’ve completed all the tasks, and follow these steps:

  1. Click End Lab. A pop-up box will appear. Click Submit to confirm that you're done. Ending the lab will remove your access to the Bash shell. You won’t be able to access the work you've completed in it again.
  2. Another pop-up box will ask you to rate the lab and provide feedback comments. You can complete this if you choose to.
  3. Close the browser tab containing the lab to return to your course.
  4. Refresh the browser tab for the course to mark the lab as complete.

시작하기 전에

  1. 실습에서는 정해진 기간 동안 Google Cloud 프로젝트와 리소스를 만듭니다.
  2. 실습에는 시간 제한이 있으며 일시중지 기능이 없습니다. 실습을 종료하면 처음부터 다시 시작해야 합니다.
  3. 화면 왼쪽 상단에서 실습 시작을 클릭하여 시작합니다.

시크릿 브라우징 사용

  1. 실습에 입력한 사용자 이름비밀번호를 복사합니다.
  2. 비공개 모드에서 콘솔 열기를 클릭합니다.

콘솔에 로그인

    실습 사용자 인증 정보를 사용하여
  1. 로그인합니다. 다른 사용자 인증 정보를 사용하면 오류가 발생하거나 요금이 부과될 수 있습니다.
  2. 약관에 동의하고 리소스 복구 페이지를 건너뜁니다.
  3. 실습을 완료했거나 다시 시작하려고 하는 경우가 아니면 실습 종료를 클릭하지 마세요. 이 버튼을 클릭하면 작업 내용이 지워지고 프로젝트가 삭제됩니다.

현재 이 콘텐츠를 이용할 수 없습니다

이용할 수 있게 되면 이메일로 알려드리겠습니다.

감사합니다

이용할 수 있게 되면 이메일로 알려드리겠습니다.

한 번에 실습 1개만 가능

모든 기존 실습을 종료하고 이 실습을 시작할지 확인하세요.

시크릿 브라우징을 사용하여 실습 실행하기

이 실습을 실행하는 가장 좋은 방법은 시크릿 모드 또는 시크릿 브라우저 창을 사용하는 것입니다. 개인 계정과 학생 계정 간의 충돌로 개인 계정에 추가 요금이 발생하는 일을 방지해 줍니다.

실습을 시작하려면 이 간단한 단계를 완료하세요.