- 10.4.3.3 Lab – Working with the Linux Command Line Answers
- 10.4.3.3 Lab – Working with the Linux Command Line Answers
- Lab – Working with Linux Command Line ( Answers Version )
- Introduction
- Recommended Equipment
- Step 1: Access the command line.
- Step 2: Display the man pages from the command line.
- Step 3: Create and change directories.
- Step 4: Create text files.
- Step 5: Copy, delete, and move files.
- Step 6: Delete directories.
- Step 7: Print lines matching a pattern.
- Step 8: Display the IP Address.
- Step 9: Change your login password.
- Step 10: Use the shutdown command.
- Reflection
10.4.3.3 Lab – Working with the Linux Command Line Answers
10.4.3.3 Lab – Working with the Linux Command Line Answers
IT Essentials v7.0 & 7.02 | |
Final Exam Answers Ch 1 — 9 | |
Final Exam Answers Ch 10 — 14 | |
Final Exam Composite Answers Ch 1 — 14 | |
IT Essentials 7.02 — Chapter 10 | |
Chapter 10 Exam Answers | Online Test |
Chapter 10 Quiz Answers | Online Test |
IT Essentials 7.02 — Chapter 11 | |
Chapter 11 Exam Answers | Online Test |
Chapter 11 Quiz Answers | Online Test |
IT Essentials 7.02 — Lab Answers | |
10.2.1.8 Lab – Create a Partition in Windows Answers | |
10.3.1.1 Lab – Windows Installation Answers | |
10.3.1.4 Lab – Finalize the Windows Installation Answers |
Lab – Working with Linux Command Line ( Answers Version )
Introduction
In this lab, you will use the Linux command line to manage files and folders and perform some basic administrative tasks.
Recommended Equipment
Answers Note: This lab can be done using the virtual machine created in a previous lab.
Step 1: Access the command line.
- Log on to a computer as a user with administrative privileges. The account ITEUser is used as the example user account throughout this lab.
- To access the command line, click Dash, and type terminal in the search field and press Enter. The default terminal emulator opens.
10.4.3.3 Lab – Working with the Linux Command Line Answers 01
Step 2: Display the man pages from the command line.
You can display command line help using the man command. A man page, short for manual page, is an online documentation of the Linux commands. A man page provides detailed information about a command and all the available options.
- To learn more about the man page, type man man at the command prompt and press Enter.
10.4.3.3 Lab – Working with the Linux Command Line Answers 02
10.4.3.3 Lab – Working with the Linux Command Line Answers 03
Step 3: Create and change directories.
In this step, you will use the change directory (cd), make directory (mkdir), and list directory (ls) commands.
Note: A directory is another word for folder. The terms directory and folder are used interchangeably throughout this lab.
- Type pwd at the prompt. What is the current directory?____________________________________________________________________________________
Answers may vary. The current directory is /home/ITEUser in this example. - Navigate to the /home/ITEUser directory if it is not your current directory. Type cd /home/ITEUser.
10.4.3.3 Lab – Working with the Linux Command Line Answers 04
10.4.3.3 Lab – Working with the Linux Command Line Answers 05
10.4.3.3 Lab – Working with the Linux Command Line Answers 06
10.4.3.3 Lab – Working with the Linux Command Line Answers 07
Step 4: Create text files.
- Navigate to the /home/ITEUser/ITEfolder1 (~/ITEfolder1) directory. Type cd ITEfolder1 at the prompt.
- Type echo This is doc1.txt > doc1.txt at the command prompt. The echo command is used to display a message at the command prompt. The > is used to redirect the message from the screen to a file. For example, in the first line, the message This is doc1.txt is redirected into a new file named doc1.txt. Use the echo command and > redirect to create these files: doc2.txt, file1.txt, and file2.txt.
10.4.3.3 Lab – Working with the Linux Command Line Answers 08
10.4.3.3 Lab – Working with the Linux Command Line Answers 09
10.4.3.3 Lab – Working with the Linux Command Line Answers 10
10.4.3.3 Lab – Working with the Linux Command Line Answers 11
Step 5: Copy, delete, and move files.
- At the command prompt, type mv doc2.txt ~/ITEfolder2 to move the file doc2.txt to the /home/ITEUser/ITEfolder2 directory.
- Type ls at the prompt to verify that doc2.txt is no longer in the current directory.
- Type cd ../ITEfolder2 to change the directory to ITEfolder2. Type ls at the prompt to verify doc2.txt has been moved.
- Type cp doc2.txt doc2_copy.txt to create a copy of doc2.txt. Type ls at the prompt to verify a copy of the file has been created. Use the cat command to look at the content of doc2_copy.txt. The content in the copy should be the same as the original file.
10.4.3.3 Lab – Working with the Linux Command Line Answers 12
Step 6: Delete directories.
In this step, you will delete a directory using the rm command. The rm command can be used to delete files and directories.
- Navigate to the /home/ITEUser/ITEfolder3 directory. Use the ls command to list the content of the directory.
- Use the rm ITEfolder4 to delete the empty directory, and the message rm: cannot remove ‘ITEfodler4/’: Is a directory.
- Use the man pages to determine what options are necessary so the rm command can delete directory. Type man rm at the prompt.
What option is needed to delete a directory?____________________________________________________________________________________
The option –d or –dir is used to delete a directory. - Use the rm –d ITEfolder4 command to delete the empty directory and use the ls command to verify the removal of the directory.
- Navigate to /home/ITEUser.
- Now remove the folder ITEfolder3 using the rm –d ITEfolder3 command to delete the non-empty directory. The message indicates that the directory is not empty and cannot be deleted.
- Use man pages to find out more information about the rm command.
What option is necessary to delete a non-empty folder using the rm command?____________________________________________________________________________________
The option –r, -R, or –recursive is used with the rm command to delete non-empty folders. - To remove a non-empty directory, type the rm –r ITEfolder3 command to delete the non-empty folder. Use the ls command to verify that directory was deleted.
Step 7: Print lines matching a pattern.
The cat command is used to view the content of a text file. To search the content of a text file, you can use the grep command. The grep command can also be used to match a pattern with screen outputs.
In this step, you will create a few additional text files in the /home/ITEUser/ITEfolder1 directory. The content and the filename are of your choosing. Three text files are used as example in this step.
- Navigate to /home/ITEUser/ITEfolder1.
- Use the echo command and redirect > to create a few text files ~/ITEfolder1 and verify that the files were created in ~/ITEfolder1.
10.4.3.3 Lab – Working with the Linux Command Line Answers 13
____________________________________________________________________________________
You would use the grep doc * command. The files, doc1.txt, doc2_new.txt, and myfile1, contain the word doc with the content.
____________________________________________________________________________________
You would use the grep the *.txt command. No files met the search parameters.
____________________________________________________________________________________
You would use the grep –i th *.txt command. The files doc1.txt and doc2_new.txt met the search parameters.
Step 8: Display the IP Address.
The ifconfig command allows you to configure a network interface. In this step, you will use the ifconfig to display the IP address associated with a network interface.
At the command prompt, type ifconfig. In this example, the eth0 interface has been assigned an IP address of 192.168.1.7 with a subnet mask of 255.255.255.0.
Step 9: Change your login password.
Changing your login password is a good practice in compute security and to unauthorized access to your information and your account.
In this step, you will change your login password. You will need your current password and choose a new password to access your account.
- Type passwd at the prompt to start the process of changing your password. Enter the current password and provide your new password twice. When the message passwd: password updated successfully is displayed, your password has been changed.
- Log out of the computer and use the new password to log on to the computer again.
Step 10: Use the shutdown command.
The shutdown command is used to bring the computer down gracefully. It requires elevated privileges and a time parameter. Because the user ITEUser is the first user account on the computer, the sudo command and the password allows this user the elevated privileges. The time parameter can be now, number of minutes from now, or at a specific time, such as 13:00.
Type sudo shutdown +1 to bring the computer down gracefully in 1 minute. When prompted, enter your password.
Reflection
What are the advantages of using the Linux command line?
Answers may vary. The command line allows the users more options and control over the graphical interface. For example, you can search through many text files for a certain pattern without opening a single file. As the users become more experienced with the command line, the users may combine these commands in scripts to perform routine tasks. The command line interface uses less resources when users administrate the computers remotely.
IT Essentials v7.0 & 7.02 | |
Final Exam Answers Ch 1 — 9 | |
Final Exam Answers Ch 10 — 14 | |
Final Exam Composite Answers Ch 1 — 14 | |
IT Essentials 7.02 — Chapter 10 | |
Chapter 10 Exam Answers | Online Test |
Chapter 10 Quiz Answers | Online Test |
IT Essentials 7.02 — Chapter 11 | |
Chapter 11 Exam Answers | Online Test |
Chapter 11 Quiz Answers | Online Test |
IT Essentials 7.02 — Lab Answers | |
10.2.1.8 Lab – Create a Partition in Windows Answers | |
10.3.1.1 Lab – Windows Installation Answers | |
10.3.1.4 Lab – Finalize the Windows Installation Answers |