Course 4 – TOOLS OF THE TRADE: LINUX AND SQL

Module 3: Linux Commands in the Bash Shell

GOOGLE CYBERSECURITY PROFESSIONAL CERTIFICATE

Coursera Study Guide

INTRODUCTION – Linux Commands in the Bash Shell


In this comprehensive overview, participants will embark on a journey into the practical application of Linux commands through the Bash shell. The module introduces participants to the fundamental commands used in Linux, providing a hands-on experience in navigating and managing the file system. Learners will gain proficiency in using the Bash shell to execute essential tasks, such as authorizing and authenticating users, fostering a practical understanding of user management in Linux environments.

A crucial aspect of this module is the exploration of the Bash shell’s capabilities in file system manipulation, empowering participants to efficiently organize and control data within the Linux operating system. Additionally, participants will discover valuable resources and strategies for seeking help when encountering new or unfamiliar Linux commands, ensuring a supportive learning environment. By the conclusion of this module, learners will have developed practical skills in executing Linux commands through the Bash shell, enhancing their ability to navigate and manage the Linux file system with confidence. This hands-on approach solidifies participants’ command-line proficiency and prepares them for effective utilization of Linux in real-world scenarios.

Learning Objectives

  • Navigate the file system using Linux commands via the Bash shell.
  • Manage the file system using Linux commands via the Bash shell.
  • Describe how Linux handles file permissions.
  • Use Linux commands via the Bash shell to authenticate and authorize users.
  • Use sudo to provide root user permissions.
  • Access resources that provide support on using Linux commands.

1. What is a command?

  • The highest-level directory in Linux
  • A common shell in many Linux distributions
  • An instruction that tells a computer to do something (CORRECT)
  • A component of the Linux architecture

A command is an instruction that tells a computer to do something.

2. Which of the following commands prints the working directory to the screen?

  • pwd (CORRECT)
  • head
  • ls
  • cat

The pwd command prints the working directory to the screen.

3. What does the cd command do?

  • Prints the working directory to the screen (CORRECT)
  • Outputs a specified string of text
  • Navigates between directories
  • Displays the names of files in the current directory

The cd command navigates between directories.

4. A security professional enters head access.txt into a shell. What are they telling the operating system to do?

  • Display the first 10 lines of access.txt (CORRECT)
  • Remove the first 5 lines of access.txt
  • Add a header to the file named access.txt
  • Return the content of access.txt one page a time

They are telling the operating system to display the first 10 lines of access.txt. The head command displays just the beginning of a file, by default 10 lines.

5. What is the difference between an absolute file path and a relative file path?

  • An absolute file path starts from the current directory, and a relative file path starts from the root.
  • An absolute file path ends with a forward slash (/), and a relative file path ends with a backslash (\).
  • An absolute file path ends with a backslash (\), and a relative file path ends with a forward slash (/).
  • An absolute file path starts from the root, and a relative file path starts from the current directory. (CORRECT)

An absolute file path is the full file path that starts from the root, and a relative file path is a shorter file path that starts from the current directory.

6. What is a Linux command?

  • An instruction telling the computer to do something (CORRECT)
  • The default shell in most Linux distributions
  • The information that is output from the shell
  • A dollar sign ($) before the cursor

A Linux command is an instruction telling the computer to do something.

7. What does the ls command do?

  • It displays just the beginning of a file, by default 10 lines.
  • It displays the names of files and directories in the current working directory. (CORRECT)
  • It prints the working directory to the screen.
  • It displays the content of a file.

The ls command displays the names of files and directories in the current working directory.

TEST YOUR KNOWLEDGE: MANAGE FILE CONTENT IN BASH

1. What two arguments commonly follow the grep command?

  • The file to write to and the string to add to it
  • The string to search for and the file to search through (CORRECT)
  • The file to move and the new file location
  • The file name to search for and the directory to search through

The grep command is commonly followed by the string to search for and the file to search through. It is used to search files for specified strings.

2. In Linux, what does the piping command (|) do?

  • It searches a specified file and returns all lines in the file containing a specified string.
  • It moves a file or directory to a new location.
  • It sends the standard input of one command as standard output to another command for further processing. (CORRECT)
  • It sends the standard output of one command as standard input to another command for further processing.

The piping command (|) sends the standard output of one command as standard input to another command for further processing.

3. A security professional enters cp vulnerabilities.txt /home/analyst/projects into the command line. What do they want the operating system to do?

  • Remove the vulnerabilities.txt file from the projects directory
  • Copy the vulnerabilities.txt file into the projects directory (CORRECT)
  • Create a new file named vulnerabilities.txt in the projects directory
  • Search for the string vulnerabilities.txt in the projects directory

They want the operating system to copy the vulnerabilities.txt file into the projects directory.  The original version of the file or directory will also remain in its original location.

4. What command creates a new file called failed_logins.txt?

  • find failed_logins.txt
  • rm failed_logins.txt
  • touch failed_logins.txt (CORRECT)
  • mkdir failed_logins.txt

The command touch failed_logins.txt creates a new file called failed_logins.txt. The touch command is used to create a new file.

5. What command can you enter to search the log.txt file for all lines containing the string error?

  • search error log.txt
  • grep log.txt error
  • search log.txt error
  • grep error log.txt (CORRECT)

You can enter grep error log.txt. The grep command searches a specified file and returns all lines in the file containing a specified string. Its first argument is the string you are searching for. Its second argument is the file you are searching through.

6. Which of the following commands can you use to create a new file?

  • mkdir
  • mv
  • touch (CORRECT)
  • rmdir

You can use the touch command to create a new file.

TEST YOUR KNOWLEDGE: AUTHENTICATE AND AUTHORIZE USERS

1. What is authorization?

  • The process of a user proving that they are who they say they are in the system
  • The process of temporarily granting elevated permissions to specific users
  • The concept of granting access to specific resources in a system (CORRECT)
  • The concept of granting only the minimal access and authorization required to complete a task or function

Authorization is the concept of granting access to specific resources in a system.

2. Which of the following statements correctly describe the file permissions string -rw-rw-rw-? Select two answers.

  • The user has write permissions. (CORRECT)
  • The group has read permissions. (CORRECT)
  • The file type is a directory.
  • The user and group have execute permissions.

The 3rd character of the file permissions string -rw-rw-rw- indicates that the user has write permissions, and the 5th character of the file permissions string -rw-rw-rw- indicates that the group has read permissions.

3. A security professional enters chmod g+w access.txt into the command line. What does this command tell the operating system to do?

  • Remove write permissions from the user for the access.txt file
  • Add write permissions to the group for the access.txt file (CORRECT)
  • Remove write permissions from the group for the access.txt file
  • Add write permissions to the user for the access.txt file

The command chmod g+w access.txt tells the operating system to add write permissions to the group.

4. Which of the following commands typically must be used with sudo? Select three answers.

  • userdel (CORRECT)
  • chmod
  • chown (CORRECT)
  • useradd (CORRECT)

The useradd,  userdel, and chown commands must typically be used with sudo. The useradd command adds a user to the system, userdel deletes a user from the system, and chown changes ownership of a file.

5. A security analyst is updating permissions on a directory named projects. The current permissions are drwxrw-r–. They want to add execute permissions for the group. What do they enter on the command line?

  • chmod g-x projects
  • chmod u-x projects
  • chmod g+x projects (CORRECT)
  • chmod x+x projects

They enter chmod g+x projects. This command adds execute permissions for the group.

6. When working with a directory, what do write permissions allow users to do?

  • Change the directory permissions
  • Create new files in that directory (CORRECT)
  • Read files in that directory
  • Enter into a directory and access its files

When working with a directory, write permissions allow users to create new files in that directory.

7. If you want to change the permissions on an approved_users.txt file, which command can you use?

  • ls -la
  • head
  • chmod (CORRECT)
  • ls -l

If you want to change the permissions on an approved_users.txt file, you can use chmod. The chmod command changes permissions on files and directories.

8. What is the purpose of the sudo command?

  • It changes permissions on files and directories.
  • It deletes a user from the system.
  • It adds a user to the system.
  • It temporarily grants elevated permissions to specific users. (CORRECT)

The sudo command temporarily grants elevated permissions to specific users. Elevated permissions are necessary to run certain commands such as useradd and userdel.

TEST YOUR KNOWLEDGE: GET HELP IN LINUX

1. Which of the following statements accurately describe Linux’s online global community? Select three answers.

  • Linux users can find support from the community for everyday tasks. (CORRECT)
  • Because Linux is open-source, the community can easily contribute. (CORRECT)
  • The community publishes online information to help users learn how to operate Linux. (CORRECT)
  • The community is focused on collecting feedback from advanced users of Linux.

Linux’s online global community enables users to find support for everyday tasks. Information is published online to help users learn how to operate Linux. In addition, because Linux is open-source, members of the community can easily contribute.

2. What does the man command do?

  • Display information on other commands and how they work (CORRECT)
  • Delete a user from the system
  • Temporarily grants elevated permissions to specific users
  • Display a description of a command on a single line

The man command displays information on other commands and how they work. For more information about a specific command, enter this other command after man.

3. What does the whatis command do?

  • Temporarily grants elevated permissions to specific users
  • Return the username of the current user
  • Display information on other commands and how they work
  • Display a description of a command on a single line (CORRECT)

The whatis command displays a description of a command on a single line. It is useful if you do not need the additional details found in the entire man page.

4. What is an advantage of the apropos command?

  • It incorporates mandatory options for customized searching
  • Users can search for a command even if they do not know the specific command name. (CORRECT)
  • It condenses the description of a specific command to one line.
  • It can be used to search for descriptions of commands when you know the specific command name.

Users can use apropos to search for a command even if they do not know the specific command name. The apropos command searches the manual page descriptions for a specified string. The apropos command has options, such as -a, but they are not mandatory.

5. What has happened because Linux is an open-source operating system?

  • All Linux distributions are updated each year.
  • All Linux distributions are available for free.
  • A global community of Linux users has formed. (CORRECT)
  • Linux users work more independently from one another.

Because Linux is an open-source operating system, a global community of Linux users has formed. The global community is a huge resource for all Linux users because users can find answers for everyday tasks.

6. How can you use the man command?

  • To display information on what other commands are and how they work (CORRECT)
  • To temporarily grant elevated permissions to specific users
  • To search the manual page descriptions for a specified string
  • To display a description of a command on a single line

You can use the man command to display information on what other commands are and how they work. For example, if you want information on the chown command and how it works, you can enter man chown.

MODULE 3 CHALLENGE

1. What are the arguments in grep bmoreno Q4users.txt? Select two answers.

  • Q4users.txt (CORRECT)
  • grep
  • bmoreno (CORRECT)
  • .txt

2. What is the root directory?

  • The highest-level directory in Linux (CORRECT)
  • The command to navigate between directories
  • The home directory of a specific user with no privileges
  • A subdirectory of the home directory

3. A security analyst enters grep OS updates.txt into the command line. What does this tell the operating system to do?

  • Move the updates.txt file to the OS directory
  • Create a new file named updates.txt in the OS directory
  • Search through the updates.txt file and return all lines containing the string OS (CORRECT)
  • Create a new directory named OS and a new file named updates.txt

4. A security analyst enters touch updates.txt into the command line. What does this tell the operating system to do?

  • Open the updates.txt file
  • Create a new file named updates.txt in their current directory (CORRECT)
  • Move the updates.txt file out of their current directory
  • Create a new file named updates.txt and move it to the root directory

5. What are the three types of permissions?

  • Root, user, and group
  • User, group, and other
  • Read, write, and execute (CORRECT)
  • Read, write, and save

6. A security analyst enters chmod u+w,g-r access.txt into the command line. What does this command do?

  • It adds write permissions for the group and removes read permissions for the user on the access.txt file.
  • It adds write and read permissions for the user and group on the access.txt file.
  • It removes write and read permissions for the user and group on the access.txt file.
  • It adds write permissions for the user and removes read permissions for the group on the access.txt file. (CORRECT)

7. Which of the following commands require the user to be a root user or have sudo privileges? Select two answers.

  • cd
  • useradd (CORRECT)
  • grep
  • userdel (CORRECT)

8. Given the following permissions drw-rw-r–, what permissions does the group have? Select all that apply.

  • Write (CORRECT)
  • Use
  • Read (CORRECT)
  • Execute

9. What are the arguments in cp vulnerabilities.txt /home/analyst/projects? Select two answers.

  • vulnerabilities.txt (CORRECT)
  • cp
  • /home
  • /home/analyst/projects (CORRECT)

10. Which of the following items represents the root directory?

  • *home
  • *
  • /home
  • / (CORRECT)

11. Which command searches a specified file and returns all lines in the file containing a specified string?

  • sudo
  • pwd
  • grep (CORRECT)
  • mkdir

12. Which of the following are types of permissions? Select all that apply.

  • Write (CORRECT)
  • Execute (CORRECT)
  • Read (CORRECT)
  • Authorize

13. A security analyst enters chmod u+w,g-r access.txt into the command line. What does this command tell the operating system to do? Select all that apply.

  • Remove read permissions from the user for the access.txt file
  • Add write permissions to the user for the access.txt file (CORRECT)
  • Add write permissions to the group for the access.txt file
  • Remove read permissions from the group for the access.txt file (CORRECT)

14. What does sudo do?

  • Changes the owner associated with a particular file
  • Temporarily grants elevated permissions to specific users (CORRECT)
  • Adds users to the system
  • Deletes users from the system

15. Which of the following commands searches the manual page descriptions for a specified string?

  • cp
  • apropos (CORRECT)
  • man
  • pwd

16. Given the following permissions drw-rw-r–, what does the fourth character represent?

  • The group does not have execute permissions for this directory
  • The user has execute permissions for this directory
  • The group has execute permissions for this directory
  • The user does not have execute permissions for this directory (CORRECT)

17. What are the arguments in mv Q1users.txt /home/analyst/reports? Select two answers.

  • mv
  • Q1users.txt (CORRECT)
  • /home/analyst/reports (CORRECT)
  • .txt

18. Fill in the blank: The highest-level directory in Linux is called the _____.

  • sudo
  • permissions
  • root directory (CORRECT)
  • home directory

19. A security analyst is updating permissions on the file access.txt. They want to add write permissions for the user and remove read permissions for the group.  What do they enter on the command line?

  • chmod u+w,g-r access.txt (CORRECT)
  • chmod u+rw,g-rw access.txt
  • chmod access.txt u+w,g-r
  • chmod u-w,g+r access.txt

20. Which command can you use to change your current directory?

  • ls
  • cat
  • pwd
  • cd (CORRECT)

21. What does the touch command do?

  • Moves a file or directory to a new location
  • Creates a new file (CORRECT)
  • Opens a file editor
  • Changes permissions on files and directories

22. What are read, write, and execute?

  • Specific Linux commands used to change file permissions
  • Different methods for editing files
  • The three types of permissions for authorized users (CORRECT)
  • The three types of owners for files and directories

23. A user is not a root user, but needs elevated privileges to use certain commands. What should they do?

  • Use the sudo command (CORRECT)
  • Use the chmod command
  • Assign themselves write permissions
  • Assign themselves execute permissions

24. A security analyst enters apropos password into the command line. What does this tell the operating system to do?

  • Output all the commands that contain the word “password” in their man page descriptions (CORRECT)
  • Display detailed information on the password command and how it works
  • Display a description of the password command on a single line
  • Change your current directory to /password

25. Given the following permissions drw-rw-r–, which character indicates if this is a file or directory?

  • Fifth
  • Second
  • Tenth
  • First (CORRECT)

26. What should you specify in the argument following the cd command?

  • The string you want to search for
  • Your current directory
  • The file you want to create
  • The directory you want to navigate to (CORRECT)

27. Which of these commands creates a new file?

  • chmod
  • touch (CORRECT)
  • cd
  • mkdir

CONCLUSION – Linux Commands in the Bash Shell

In summary, this module provides a comprehensive exploration of Linux commands executed through the Bash shell, offering participants practical insights into their application within the Linux operating system. Through hands-on experiences, learners acquire proficiency in navigating and managing the file system, as well as authorizing and authenticating users. The module also emphasizes the significance of seeking help when working with new Linux commands, ensuring participants have the resources and strategies needed for continuous learning.

By fostering a practical understanding of command-line operations in Linux, this module equips participants with essential skills for real-world applications. The hands-on approach enhances their confidence in using the Bash shell, contributing to their overall proficiency in Linux environments. As participants progress through this comprehensive overview, they not only gain theoretical knowledge but also develop practical expertise, setting a solid foundation for leveraging Linux commands effectively in cybersecurity and related fields.