arrow_back

Linux Essentials: Command Line Primer

로그인 가입
700개 이상의 실습 및 과정 이용하기

Linux Essentials: Command Line Primer

실습 30분 universal_currency_alt 크레딧 1개 show_chart 입문
info 이 실습에는 학습을 지원하는 AI 도구가 통합되어 있을 수 있습니다.
700개 이상의 실습 및 과정 이용하기

gem-basics-linux

Google Cloud self-paced labs logo

Activate Cloud Shell

Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.

  1. Click Activate Cloud Shell Activate Cloud Shell icon at the top of the Google Cloud console.

When you are connected, you are already authenticated, and the project is set to your PROJECT_ID. The output contains a line that declares the PROJECT_ID for this session:

Your Cloud Platform project in this session is set to YOUR_PROJECT_ID

gcloud is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.

  1. (Optional) You can list the active account name with this command:
gcloud auth list
  1. Click Authorize.

  2. Your output should now look like this:

Output:

ACTIVE: * ACCOUNT: student-01-xxxxxxxxxxxx@qwiklabs.net To set the active account, run: $ gcloud config set account `ACCOUNT`
  1. (Optional) You can list the project ID with this command:
gcloud config list project

Output:

[core] project = <project_ID>

Example output:

[core] project = qwiklabs-gcp-44776a13dea667a6 Note: For full documentation of gcloud, in Google Cloud, refer to the gcloud CLI overview guide.

Overview

This lab provides a hands-on introduction to fundamental Linux shell commands. You'll learn how to navigate the filesystem, manipulate files, and understand basic shell operations, equipping you with essential skills for interacting with Linux environments. Prior knowledge of Linux shell commands is expected.

Task 1. Navigating the Filesystem

In this task, you'll learn to move around the Linux filesystem using essential commands.

  1. Use the pwd command to print the current working directory.
pwd Note:
This command displays the absolute path of your current location.
  1. Change directories using the cd command. First, navigate to the home directory.
cd ~ Note:
The `~` represents the home directory.
  1. Now, create a directory named my_project within your home directory.
mkdir my_project Note:
This command creates a new directory.
  1. Navigate into the my_project directory.
cd my_project Note:
Now you are inside the newly created directory.
  1. Use cd .. to go back to the parent directory (your home directory).
cd .. Note:
This command moves you one level up in the directory structure.

Task 2. File Manipulation

This task covers basic file creation, copying, moving, and deletion operations.

  1. Create an empty file named hello.txt using the touch command.
touch hello.txt Note:
This command creates an empty file if it doesn't exist.
  1. Write some text into hello.txt using the echo command and redirection.
echo "Hello, world!" > hello.txt Note:
The `>` redirects the output of the echo command to the file.
  1. Display the contents of hello.txt using the cat command.
cat hello.txt Note:
This command displays the contents of a file.
  1. Copy hello.txt to goodbye.txt using the cp command.
cp hello.txt goodbye.txt Note:
This command duplicates the file.
  1. Move goodbye.txt to my_project directory.
mv goodbye.txt my_project/ Note:
This command moves or renames files.
  1. Delete the hello.txt file using the rm command.
rm hello.txt Note:
This command permanently deletes files. Use with caution.

Task 3. Working with Directories

This task focuses on listing directory contents and removing directories.

  1. List the contents of the current directory using the ls command.
ls Note:
This command lists files and directories in the current directory.
  1. List the contents of the my_project directory, including hidden files, using ls -la. First navigate to home directory.
cd ~ && ls -la my_project/ Note:
The `-l` option provides a detailed listing, and `-a` includes hidden files.
  1. Remove the my_project directory and its contents using the rm -r command. First navigate to home directory.
cd ~ && rm -r my_project/ Note:
The `-r` option is necessary to remove directories recursively. Use with caution.
  1. Verify that the my_project directory has been removed. First navigate to home directory.
cd ~ && ls Note:
The directory should no longer be listed.

Task 4. Basic Shell Operations

This task introduces command chaining and output redirection.

  1. Use command chaining to create a directory and then navigate into it using &&.
mkdir my_new_project && cd my_new_project Note:
If the first command (mkdir) succeeds, the second command (cd) will execute.
  1. Use output redirection to save the output of the ls -l command to a file named listing.txt.
ls -l > listing.txt Note:
The `>` redirects the output of the ls command to the file.
  1. Append the output of the pwd command to listing.txt using >>.
pwd >> listing.txt Note:
The `>>` appends the output to the file instead of overwriting it.
  1. Display the contents of listing.txt to confirm the appended output.
cat listing.txt Note:
This command displays the contents of the file.

Congratulations!

You have successfully navigated the Linux filesystem, manipulated files, worked with directories, and performed basic shell operations. These skills are fundamental for any Linux user and provide a solid foundation for more advanced command-line tasks. Explore the manual pages for each command (man [command]) to discover more options and functionalities.

Additional Resources

Manual Last Updated Jul 16, 2025

Lab Last Tested Jul 16, 2025

시작하기 전에

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

시크릿 브라우징 사용

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

콘솔에 로그인

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

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

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

감사합니다

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

한 번에 실습 1개만 가능

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

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

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