MALAPOTE - 4.2.7 Lab - Getting Familiar With The Linux Shell
MALAPOTE - 4.2.7 Lab - Getting Familiar With The Linux Shell
Recommended Equipment
● CyberOps Workstation virtual machine
Instructions
2018 - 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 1 of 13 www.netacad.com
Lab - Getting Familiar with the Linux Shell
Question:
2018 - 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 2 of 13 www.netacad.com
Lab - Getting Familiar with the Linux Shell
b. Navigate to the /home/analyst directory if it is not your current directory. Type cd /home/analyst
[analyst@secOps ~]$ cd /home/analyst
c. Type ls -l at the command prompt to list the files and folders that are in the current folder. Standing for list,
the -l option displays file size, permissions, ownership, date of creation and more.
[analyst@secOps ~]$ ls -l
total 20
drwxr-xr-x 2 analyst analyst 4096 Mar 22 2018 Desktop
drwxr-xr-x 3 analyst analyst 4096 Apr 2 14:44 Downloads
drwxr-xr-x 9 analyst analyst 4096 Jul 19 2018 lab.support.files
drwxr-xr-x 2 analyst analyst 4096 Mar 21 2018 second_drive
-rw-r--r-- 1 analyst analyst 255 Apr 17 16:42 space.txt
2018 - 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 3 of 13 www.netacad.com
Lab - Getting Familiar with the Linux Shell
d. In the current directory, use the mkdir command to create three new folders: cyops_folder1,
cyops_folder2, and cyops_folder3. Type mkdir cyops_folder1 and press Enter. Repeat these steps to
create cyops_folder2 and cyops_folder3.
[analyst@secOps ~]$ mkdir cyops_folder1
[analyst@secOps ~]$ mkdir cyops_folder2
[analyst@secOps ~]$ mkdir cyops_folder3
[analyst@secOps ~]$
2018 - 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 4 of 13 www.netacad.com
Lab - Getting Familiar with the Linux Shell
Note: In the [analyst@secOps ~]$ prompt above: The tilde symbol ~ represents the current user’s home
directory. In this example, the current user’s home directory is /home/analyst. After the cd
/home/analyst/cyops_folder3 command, the current user’s home directory is now
/home/analyst/cyops_folder3.
Note: $ (dollar sign) indicates regular user privilege. If a ‘#’ (hashtag or pound sign) is displayed at the
prompt, it indicates elevated privilege (root user).
Note: While these symbols, conventions and main concepts remain the same, the prompt of a terminal
window is highly customizable in Linux. Therefore, the prompt structure seen in the CyberOps Workstation
VM will likely differ from the prompt in other Linux installations.
Challenge: Type the command cd ~ and describe what happens.
Question:
g. Use the mkdir command to create a new folder named cyops_folder4 inside the cyops_folder3 folder:
[analyst@secOps ~]$ mkdir /home/analyst/cyops_folder3/cyops_folder4
[analyst@secOps ~]$
i. Up to this point, we have been using full or absolute paths. Absolute path is the term used when referring
to paths that always start at the root (/) directory. It is also possible to work with relative paths. Relative
paths reduce the amount of text to be typed. To understand relative paths, we must understand the . and ..
(dot and double dot) directories. From the cyops_folder3 directory, issue a ls –la:
analyst@secOps ~]$ ls –la /home/analyst/cyops_folder3
total 12
drwxr-xr-x 3 analyst analyst 4096 Aug 16 15:04 .
drwxr-xr-x 20 analyst analyst 4096 Aug 16 15:02 ..
drwxr-xr-x 2 analyst analyst 4096 Aug 16 15:04 cyops_folder4
2018 - 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 5 of 13 www.netacad.com
Lab - Getting Familiar with the Linux Shell
The -a option tells ls to show all files. Notice the . and .. listings shown by ls. These listings are used by the
operating system to track the current directory (.) and the parent directory (..) You can see the use of the .
and .. when using the cd command to change directories. Using the cd command to change the directory
to the . directory incurs no visible directory change as the . points to the current directory itself.
j. Change the current directory to /home/analyst/cyops_folder3:
[analyst@secOps ~]$ cd /home/analyst/cyops_folder3
[analyst@secOps cyops_folder3]$
k. Type cd .
[analyst@secOps cyops_folder3]$ cd .
[analyst@secOps cyops_folder3]$
Question:
What happens?
Answer: It will remove the folder3 directory.
l. Changing the directory to the .. directory, will change to the directory that is one level up. This directory is
also known as parent directory. Type cd ..
[analyst@secOps cyops_folder3]$ cd ..
[analyst@secOps ~]$
Question:
What happens?
Answer: It will change to the “Home” directory..
What would be the current directory if you issued the cd .. command at [analyst@secOps ~]$?
Answer: Home directory.
What would be the current directory if you issued the cd .. command at [analyst@secOps home]$?
Answer: Root directory.
What would be the current directory if you issued the cd .. command at [analyst@secOps /]$?
Answer: still in the Root directory.
2018 - 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 6 of 13 www.netacad.com
Lab - Getting Familiar with the Linux Shell
b. Use the echo command to echo a message. Because no output was defined, echo will output to the current
terminal window:
analyst@secOps ~]$ echo This is a message echoed to the terminal by echo.
This is a message echoed to the terminal by echo.
c. Use the > operator to redirect the output of echo to a text file instead of to the screen:
analyst@secOps ~]$ echo This is a message echoed to the terminal by echo. >
some_text_file.txt
No output was shown.
Question:
d. Notice, that even though the some_text_file.txt file did not exist, prior to the echo command, it was
automatically created to receive the output generated by echo. Use the ls -l command to verify if the file
was really created:
[analyst@secOps ~]$ ls –l some_text_file.txt
-rw-r--r-- 1 analyst analyst 50 Feb 24 16:11 some_text_file.txt
e. Use the cat command to display the contents of the some_text_file.txt text file:
[analyst@secOps ~]$ cat some_text_file.txt
This is a message echoed to the terminal by echo.
f. Use the > operator again to redirect a different echo output of echo to the some_text_file.txt text file:
analyst@secOps ~]$ echo This is a DIFFERENT message, once again echoed to the
terminal by echo. > some_text_file.txt
g. Once again, use the cat command to display the contents of the some_text_file.txt text file:
[analyst@secOps ~]$ cat some_text_file.txt
This is a DIFFERENT message, once again echoed to the terminal by echo.
Question:
2018 - 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 7 of 13 www.netacad.com
Lab - Getting Familiar with the Linux Shell
b. Use the cat command to display the contents of the some_text_file.txt text file yet again:
[analyst@secOps ~]$ cat some_text_file.txt
This is a DIFFERENT message, once again echoed to the terminal by echo.
This is another line of text. It will be APPENDED to the output file.
Question:
c. Use the ls -la command to display all files in the home directory of analyst, including the hidden files.
[analyst@secOps ~]$ ls –la
Questions:
2018 - 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 8 of 13 www.netacad.com
Lab - Getting Familiar with the Linux Shell
Answer: 144 files. This includes the hidden files and directories that typically aren't visible in the standard
ls output. These could be system or user configuration files, dotfiles, or directories.
Is it possible to hide entire directories by adding a dot before its name as well? Are there any directories in
the output of ls -la above?
Answer: Yes, it is possible to hide entire directories by adding a dot (.) before the directory name. Just like
with files, directories starting with a dot are considered hidden in Linux and will not show up with the regular
ls command unless you use -a or -la to display all files, including hidden ones. As for the output of ls -la,
yes, there are usually directories in that output. For example, you would typically see directories like .
(representing the current directory), .. (representing the parent directory), and other directories specific to
your home directory. These hidden directories are important for system configurations or user settings. You
can use ls -la to identify them and explore their contents if needed.
Give three examples of hidden files shown in the output of ls -la above.
Answer:
d. Type the man ls command at the prompt to learn more about the ls command.
[analyst@secOps ~]$ man ls
e. Use the down arrow key (one line at a time) or the space bar (one page at a time) to scroll down the page
and locate the -a option used above and read its description to familiarize yourself with the ls -a command.
What are the source and destination files? (use full paths to represent the parameters)
Answer: In the cp command you used, the first part, some_text_file.txt, is the source file, meaning it's the
file you want to copy. It’s located in your home directory, so the full path to it is
/home/analyst/some_text_file.txt. The second part, cyops_folder2/, is the destination, which is the folder
where you want to copy the file to. In this case, the full path to the destination folder is
/home/analyst/cyops_folder2/. The command makes a copy of the file and places it in that folder, leaving
the original file in its original location.
2018 - 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 9 of 13 www.netacad.com
Lab - Getting Familiar with the Linux Shell
c. Use the ls command to verify that some_text_file.txt is also in the home directory:
[analyst@secOps ~]$ ls -l
total 36
drwxr-xr-x 2 analyst analyst 4096 Aug 16 15:01 cyops_folder1
drwxr-xr-x 2 analyst analyst 4096 Aug 16 15:11 cyops_folder2
drwxr-xr-x 3 analyst analyst 4096 Aug 16 15:04 cyops_folder3
drwxr-xr-x 2 analyst analyst 4096 Sep 26 2014 Desktop
drwx------ 3 analyst analyst 4096 Jul 14 11:28 Downloads
drwxr-xr-x 8 analyst analyst 4096 Jul 25 16:27 lab.support.files
drwxr-xr-x 2 analyst analyst 4096 Mar 3 15:56 second_drive
-rw-r--r-- 1 analyst analyst 142 Aug 16 15:09 some_text_file.txt
-rw-r--r-- 1 analyst analyst 254 Aug 16 13:38 space.txt
2018 - 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 10 of 13 www.netacad.com
Lab - Getting Familiar with the Linux Shell
b. In Linux, directories are seen as a type of file. As such, the rm command is also used to delete directories
but the -r (recursive) option must be used. Notice that all files and other directories inside a given directory
are also deleted when deleting a parent directory with the -r option. Issue the command below to delete the
cyops_folder1 folder and its contents:
[analyst@secOps ~]$ rm –r cyops_folder1
[analyst@secOps ~]$ ls -l
total 28
drwxr-xr-x 2 analyst analyst 4096 Aug 16 15:11 cyops_folder2
drwxr-xr-x 3 analyst analyst 4096 Aug 16 15:04 cyops_folder3
drwxr-xr-x 2 analyst analyst 4096 Sep 26 2014 Desktop
drwx------ 3 analyst analyst 4096 Jul 14 11:28 Downloads
drwxr-xr-x 8 analyst analyst 4096 Jul 25 16:27 lab.support.files
drwxr-xr-x 2 analyst analyst 4096 Mar 3 15:56 second_drive
-rw-r--r-- 1 analyst analyst 254 Aug 16 13:38 space.txt
2018 - 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 11 of 13 www.netacad.com
Lab - Getting Familiar with the Linux Shell
Reflection
What are the advantages of using the Linux command line?
Answer: The "Getting Familiar with the Linux Shell" lab helped me get more comfortable using the command
line in Linux. Before this, I mostly relied on graphical interfaces, so this was my first real experience navigating
and managing files using commands.
The basic commands like ls, cd, mkdir, cp, and rm were easy to pick up and showed me how to move around
directories, create new folders, copy, and delete files. I also learned about absolute and relative paths, which
made it easier to understand how to find and manage files in different locations on the system.
One thing that stood out was using redirection operators like > and >> to send output from commands into files.
This was super helpful when I needed to save information from my commands or log results without losing
previous data.
I also got a chance to see hidden files (the ones starting with a dot .) and how important they are for system
settings. Using ls -la to list those hidden files was a good way to understand how Linux keeps certain files out
of sight for system organization.
Overall, the lab was a great introduction to using the Linux shell, and I feel more confident navigating the system.
It's clear to me now that the command line is a powerful tool, and I’m excited to keep learning more advanced
features as I get more comfortable with it.
2018 - 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 12 of 13 www.netacad.com
Lab - Getting Familiar with the Linux Shell
End of document
2018 - 2020 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 13 of 13 www.netacad.com