0% found this document useful (0 votes)
242 views11 pages

M04 - Part 1 Hands-On Assignment - Linux Command Line Exercises - Shaker Mohammadtom

This document provides instructions for accessing and using the command line interface in Fedora and Linux Mint. It describes how to open a terminal emulator, check the username, view the date and time, switch between virtual terminals, and get help for commands using the man pages. Exercises guide the user through logging into different terminals, running basic commands like whoami and date, and exploring options for the man command.

Uploaded by

Shaker
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
242 views11 pages

M04 - Part 1 Hands-On Assignment - Linux Command Line Exercises - Shaker Mohammadtom

This document provides instructions for accessing and using the command line interface in Fedora and Linux Mint. It describes how to open a terminal emulator, check the username, view the date and time, switch between virtual terminals, and get help for commands using the man pages. Exercises guide the user through logging into different terminals, running basic commands like whoami and date, and exploring options for the man command.

Uploaded by

Shaker
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

lOMoARcPSD|7891473

lOMoARcPSD|7891473

*** For this lab you can choose to use the virtual machines you build in the M01 –
Part 2: hands On Project – Building a Virtual Machine or you can use the machines you
built in AWS. If you choose the use the machines you built in AWS you will use the Red
Hat instance where the lab calls for Fedora and the Ubuntu Instance where the lab calls
for Mint***

Chapter 5: Getting to know the Command Line

Exercise 5.a: Accessing the Command Line in Fedora (Objective 2.1)

Linux Distribution: Fedora 30 Workstation


User: Non-root user and password needed
Desktop Environment: GNOME 3 (GNOME Shell)
1. If it is not already, boot up your computer (or virtual machine) to start the Fedora
Linux distribution.
2. When the machine is booted, log onto a regular user account by clicking on its name
listed on the first screen.
3. Enter the user account’s password into the Password field and press Enter.
4. Click Activities in the upper-left window corner to open the Favorites panel on the left
side and the search box in the windows upper middle.
5. In the search box, type terminal. A terminal icon should appear.
6. Click on the terminal icon to open a terminal emulator window.
7. After the terminal emulator window is open, you should see a command line prompt,
ending in a dollar sign ($).
8. At the prompt, type whoami and press Enter. You should see the regular user
account name you used to log into the system (though the name may be slightly
different than what you saw when you logged in via the GUI), and then another
command line prompt.
Record the account name (also called username) here:___mint_______

9. At the prompt, type date and press Enter. You should see the date and time (or at
least what the computer thinks the date and time is currently), and then another
command line prompt.
10. Press the Ctrl key and hold it; meanwhile press the Alt key and hold it; and then
pressthe F3 key. Release all three keys. You should see a new screen. This is a
virtual console terminal login screen.
11. Type in the regular username you recorded in step #8, and press Enter.
12. Type in the password you used in step #3, and press Enter. Note, you will not see
any helpful characters like asterisks or dots as you type in the password. 
13. Once you have successfully logged in, you should see a command line prompt,
similar to the one you received in step #7.
14. At the prompt, type whoami and press Enter. Does the displayed name match the
one you recorded in step #8? It should.
15. At the prompt, type date and press Enter. You should see the date and time (or at
least what the computer thinks the date and time is currently).

Continued on the next page


lOMoARcPSD|7891473

Exercise 5.a: Accessing the Command Line in Fedora (continued)


16. This next command won’t work. Type Date and press Enter. You should see a
message that says “command not found” or something similar. This is because all
command line commands are case sensitive. In other words, date does not equal
Date!
17. Type exit and press Enter to end the virtual terminal login session.
18. Press the Ctrl key and hold it; meanwhile press the Alt key and hold it; and then
pressthe F1 key. Release all three keys. (Written in short-hand, this key sequence is
Ctrl+Alt+F1). You should be back at the GUI session with the terminal emulator still
running, though you may have to log in again in order to see the terminal emulator
screen.
19. Click on the terminal emulator window to select it. 
20. Type exit and press Enter to end the terminal emulator session.

Exercise 5.b: Accessing the Command Line in Linux Mint (Objective 2.1)

Linux Distribution: Linux Mint 18.3 LTS


User: Non-root user and password needed
Desktop Environment: Cinnamon
1. If it is not already, boot up your computer (or virtual machine) to start the Linux Mint
distribution.
2. When the machine is booted, log onto a regular user account by clicking on its name
listed on the first screen.
3. Enter the user account’s password into the Password field and press Enter.
4. Open a terminal emulator in the GUI, by pressing the Ctrl key and holding it;
meanwhile press the Alt key and hold it; and then press the T key. Release all three
keys. (Written in short-hand, this key sequence is Ctrl+Alt+T). You should see a
terminal emulator window open. (Alternately, you can click on the terminal icon
located on the lower panel to open a terminal emulator.)
5. After the terminal emulator window is open, you should see a command line prompt,
ending in a dollar sign ($).
6. At the prompt, type whoami and press Enter. You should see the regular user
account name you used to log into the system (though the name may be slightly
different than what you saw when you logged in via the GUI, and then another
command line prompt.
Record the account name (also called username) here:____mint______

7. At the prompt, type date and press Enter. You should see the date and time (or at
least what the computer thinks the date and time is currently), and then another
command line prompt.
8. Press the Ctrl+Alt+F2 key sequence. You should see a new screen. This is a virtual
console terminal login screen.
11. Type in the regular username you recorded in step #6, and press Enter.
12. Type in the password you used in step #3. Note, you will not see any helpful
characters like asterisks or dots as you type in the password.
13. Once you have successfully logged in, you should see a command line prompt,
similar to the one you received in step #5.

Downloaded by Shakir Mohammed ([email protected])


lOMoARcPSD|7891473

14. At the prompt, type whoami and press Enter. Does the displayed name match the
one you recorded in step #6? It should.
Continued on the next page

Exercise 5.b: Accessing the Command Line in Linux Mint (continued)


15. At the prompt, type date and press Enter. You should see the date and time (or at
least what the computer thinks the date and time is currently).
16. This next command won’t work. Type Date and press Enter. You should see a
message that says “No command found” or something similar. This is because all
command line commands are case sensitive. In other words, date does not equal
Date!
17. Type exit and press Enter to end the virtual terminal login session.
18. Press the Ctrl+Alt+F7 key sequence. You should be back at the GUI session with the
terminal emulator still running, though you may have to log back in again to see the
terminal emulator screen. 
19. Click on the terminal emulator window to select it. 
20. Type exit and press Enter to end the terminal emulator session.

Exercise 5.c: Getting Help on the Command Line(Objective 2.2)

Linux Distribution: Linux Mint 18.3 LTS


User: Non-root user and password needed
Desktop Environment: Cinnamon
1. If it is not already, boot up your computer (or virtual machine) to start the Linux Mint
distribution.
2. If you are not already logged into the system, when the machine is booted, log onto a
regular user account and enter the appropriate password.
4. Open a terminal emulator in the GUI, by pressing Ctrl+Alt+T. You should see a
terminal emulator window open.
5. After the terminal emulator window is open, you should see a command line prompt,
ending in a dollar sign ($).
6. At the prompt, type man man and press Enter to enter into the description for the
man (aka help) pages for commands. This command will provide you text describing
how to use the man pages for getting help on various commands and topics used in
Linux.
lOMoARcPSD|7891473

Continued on the next page

Exercise 5.c: Getting Help on the Command Line (continued)


7. Within the help for the man pages, read through the Description; Manual Sections;
and all the Options. Use either: the arrow keys, the Enter key’ or the space bar to
move through the displayed text. Below, write the standard "Manual Sections", which
are located in “Description”
1. Executable programs or shell commands

2. System calls (functions provided by the kernel)

3. Library calls (functions within program libraries)

4. Special files (usually found in /dev)

5. File formats and conventions

Downloaded by Shakir Mohammed ([email protected])


lOMoARcPSD|7891473

6. Games

7. Miscellaneous

8. System administration commands

9. Kernel routines

8. Type q to quit the man pages and return to the prompt.


9. Type man uname and press Enter. Notice at the top left and right of the manual
page, it displays the uname command with a (1) behind it, and in the middle of the
top of the page are the words "User Commands." These items at the top of the man
page, because this man page is within the User Commands standard section of the
manual (see step #7 above for the various sections.)
10. Type q to quit the man pages and return to the prompt.
11. Type man -S 2 uname and press Enter. Notice at the top left and right of the
manual page, it displays the uname command with a (2) behind it this time, and in
the middle of the top of the page are the words "Linux Programmer's Manual." You
see these items at the top of the man page, because this man page is within the
Linux Programmer's Manual standard section of the manual (see step #7 for the
various sections.) To reach different sections of the man pages, use the -S option.
You can also use different command syntax: man 2 uname has the same affect.
13. Type q to quit the man pages and return to the prompt.
lOMoARcPSD|7891473

uname command by typing man -k


14. See what various sections there may be for the
uname and pressing Enter. There should be several results listed! The -k stands
for "keyword." The whatis database allows you to search through it for certain
man pages keywords to find various helpful information and the sections the
information is in, using the -k option.
15. You can also try another command to do the exact same thing as shown in the step
above. Try it out by typing: apropos uname and press Enter.
Continued on next page

Exercise 5.c: Getting Help on the Command Line(continued)

16. The man pages all live in the /usr/share/man/ directory. You can see the
different man page sections and miscellaneous files located here by typing: ls
/usr/share/man/ and pressing Enter. Notice the man1 and man2 files. These are
actually directories that contain the various man pages.

Downloaded by Shakir Mohammed ([email protected])


lOMoARcPSD|7891473

17. You can find the various files with the name “uname” that may be associated with the
uname command, including the man pages. Try this out, by typing: whereis
uname and pressing Enter. The output is not very easy to read, because it’s not
formatted nicely. The whereis command searches particular directories to find
files associated with the name you give it.
18. Try out the command you have been getting help on by typing uname and pressing
Enter. The uname command provides system information.
19. You get a lot more system information, including the Linux kernel's version number
bytyping uname -a and pressing Enter.
20. One more source of documentation is the directory /usr/share/doc. Take a
look at this directory by typing: ls /usr/share/doc and pressing Enter. Nothing too
exciting here, but you should be aware of this directory if you are searching for
documentation on your Linux system.
21. Take a look at a specific documentation file, by typing in the command: less
/usr/share/doc/bash/copyright and pressing Enter. This shows you the GPL license
for this bash shell! You read about the various licenses in Chapter 2. Some
distributions name this file COPYING. The /usr/share/doc directory has
miscellaneous documentation, such as various products’ licenses.
lOMoARcPSD|7891473

22. Press Enter a few times to read through the license document, and then type q to quit
and return to the prompt.

Exercise 5.d: Looking at Command History(Objective 2.1)

Linux Distribution: Linux Mint 18.3 LTS


User: Non-root user and password needed
Desktop Environment: Cinnamon
1. If it is not already, boot up your computer (or virtual machine) to start the Linux Mint
distribution.
2. If you are not already logged into the system, when the machine is booted, log onto a
regular user account and enter the appropriate password.
3. If you do not already have a terminal emulator open, open a terminal emulator in the
GUI, by pressing Ctrl+Alt+T. You should see a terminal emulator window open. After
the terminal emulator window is open, you should see a command line prompt,
ending in a dollar sign ($).
4. Type whoami and press Enter to display your current username.

Downloaded by Shakir Mohammed ([email protected])


lOMoARcPSD|7891473

5. Here's an interesting little trick: Type !! and press Enter. You should see that the
Bash shell "re-issued" the command from the step above. The !! command "pulls
out" the last command you did from your command history; displays the command;
and runs it again.
Continued on next page

Exercise 5.d: Looking at Command History(continued)


6. To see all your command history (commands you have previously entered in the
bash shell) type history and press Enter. You should see several commands listed
along with a number by each one.
7. The history command displays information kept in a hidden file, which is located
in your home directory. To see this file, type cat .bash_history (don’t miss that
leading period on the file’s name) and press Enter. You may not see any commands
that you recently typed in the file. (This is okay and normal!) Once you log out and
back in again, then you will see the commands in this file. The proper way to view
"current" command history is via the history command.
8. Type history and press Enter to again view your recent commands.
lOMoARcPSD|7891473

9. Pick one of the commands from the history list and note its number. Type !# (where
# is the number of the command in your history) and press Enter. The command
should display and execute! This is another method, besides the up arrow key, you
can use to recall previous commands.

Downloaded by Shakir Mohammed ([email protected])

You might also like