Lab 1: Command Line Interface (CLI)
Introduction
In this lab assignment, you will explore the Linux CLI, which is essential for effective system administration and development tasks. The assignment is designed to enhance your command-line skills through hands-on practice with various operations related to files, directories, permissions, text editing, user management, networking, process management, and package management. You will work through a series of tasks categorized by levels of mastery: Pass, Merit, and Distinction.
Resources to assist with the lab:
- Homework Questions
- Class Resources
- Classmates/Teammates
- Internet Resources
- Teaching Assistants
Please reach out to the TAs only after making a genuine effort to resolve the issue independently. While they are available to provide guidance and support, their role is to assist you in developing your understanding rather than providing immediate solutions. You are encouraged to approach challenges proactively, fostering problem-solving skills and critical thinking in the process.
Developing problem-solving skills and critical thinking is fundamental to your education and growth. These skills are emphasized as part of the Aims of a BYU Education, which seek to cultivate individuals of faith, intellect, and character. Problem-solving and critical thinking are essential components of sound reasoning, effective communication, and intellectual depth — qualities that prepare you to succeed in both academic and real-world challenges.
BYU’s focus on lifelong learning and service reminds us that the ability to independently approach, analyze, and resolve complex issues is just as important as mastering technical skills. These capabilities not only build competence but also instill the confidence to contribute meaningfully to the world and continue learning throughout life.
Configuration Instructions
Virtual Machines and Operating Systems
You will be working with:
- 1 Ubuntu 20.04 Machine
Network Configuration
Your machine already has internet access set up and can be accessed through your Proxmox instance. In future labs, you will practice setting the network settings but for this lab, it has been done for you.
Accessing the Virtual Machines
- The VMs can be accessed through your Proxmox instance.
- To track your progress, visit the scoreboard.
- You need to be connected to the VPN to access the scoreboard and your Proxmox instance.
Scoreboard Key
- Green arrows indicate that everything is working as intended.
- Orange Exclamation indicates that something is partially working.
- Red down arrows indicate that something is not working.
You can hover over your specific arrow and a tooltip will appear with a hint on what is wrong or not working.
Credentials
- All VMs have the same login credentials:
- Username:
blueteam - Password:
abc123
- Username:
Connecting to Proxmox
- Install OpenVPN on your computer:
- Download the installer here.
- After installation, import the VPN profile that was emailed to your BYU email address.
- Connect to the VPN.
- Access Proxmox:
- In your browser, navigate to the Proxmox URL from the email (e.g.,
https://172.18.<ID>.100:8006, where ‘ID’ is your user ID). - You will see a warning when the page loads. This is expected due to Proxmox’s self-signed TLS certificate. Click
Advanced, thenProceed to....
- In your browser, navigate to the Proxmox URL from the email (e.g.,
- Login to Proxmox:
- Username:
student - Password: Use the password sent to you via email.
- Change the
RealmfromLinux PAM standard authenticationtoProxmox VE authentication server. - Click
Login. - You should see the Lab1 VMs in the panel on the left-hand side. You may have to expand the node button (It has the green checkmark next to it) to see them.
- Username:
Scoring Advice
There may be a way to achieve a criteria that we have not accounted for. If you believe your method meets the criteria but is not being scored please reach out to a TA.
Pass Criteria
P1: File and Directory Operations
- Create a directory called
P1in/home/blueteam/. - Change the directory you’re in to the
P1directory you just created. - Use
touchto create a file calledP1.txt - Display the full path of your current directory. Enter the line
path:<command>into the file/home/blueteam/P1/P1.txt - Use
tailto view file changes in/var/log/auth.login real-time. Enter the linelive-tail:<command>into the file/home/blueteam/P1/P1.txt - View the first 10 lines of
/var/log/auth.logusinghead. Enter the linehead:<command>into the file/home/blueteam/P1/P1.txt - View the last 10 lines of
/var/log/auth.logusingtail. Enter the linetail:<command>into the file/home/blueteam/P1/P1.txt - Delete the directory
/home/blueteam/P1-delete-me - Move and rename the file in a single command
/home/blueteam/P1-move-me.txtto/home/blueteam/P1/moved.txt. - Copy the file
/home/blueteam/P1-copy-me.txtto/home/blueteam/P1/P1-copy-me.txt
P2: Text Editor Basics
- Create
/home/blueteam/P2/P2.txtusing nano and put the linenano is too easyas the first line - Open the file
/home/blueteam/P2/P2-2.txtand use the find and replace to change every instance ofVimtoNano
P3: Permissions and Ownership
- View file permissions and ownership using
ls.- List all files (including hidden ones) contained in
/home/blueteam/P3/. Enter the linehidden:<command>into the file/home/blueteam/P3/P3.txt. Run the command from inside of theP3directory. - List all files (including hidden ones) and use the long list format on the file in
/home/blueteam/P3/. Enter the linehidden-long:<command>into the file/home/blueteam/P3/P3.txt. Run the command using the absolute file path.
- List all files (including hidden ones) contained in
- Modify file and folder permissions using
chmod.- Change the permissions on the hidden file in
/home/blueteam/P3to be read only by the file owner and no permissions to anyone else - Change the permissions on the file
/home/blueteam/P3/P3-3.txtto be read and write by the owner and read only by others in the group and all others
- Change the permissions on the hidden file in
- Change file owners and groups using
chown.- Change the owner of the hidden file to
blueteamand the group tosudo - Change the owner of the file
/home/blueteam/P3/P3-4.txttoroot - Change the group of the file
/home/blueteam/P3/P3-2.txttoblueteam
- Change the owner of the hidden file to
P4: User and Group Management
- Add users with/without login shells, home directories, and passwords using
useraddoradduser- Create a user called
no-shellthat does not have a shell or password they can log in with but does have a home directory. It should say/usr/sbin/nologinor/bin/falsefor the user in/etc/passwdafter the user has been created - Create a user called
shellthat has a shell and password they can use to log in, but no home directory - Create a user called
no-passwordthat has a shell, but no password they can log in with, and no home directory - Create a user called
loginwith a login shell, home directory, and a password they can log in with
- Create a user called
- Modify groups that a user belongs to using
usermodand view group info usinggroups- Add the
loginuser to thesudogroup - Remove the
backupuser from theredteamgroup
- Add the
P5: Archiving and Compression
- Create compressed files using
zip. Compress the directory/home/blueteam/P5/and all of its contents into a zip calledP5.zipand put it in/home/blueteam - Extract compressed files using
zip. Extract the zip/home/blueteam/P5-unzip.zip. Make sure the directory that contains all the extracted files is located at/home/blueteam/P5-unzip/
P6: Networking
- Check network configuration. Enter the line
network:<command>into the file/home/blueteam/P6/P6.txt - Test connectivity to
google.comusing an ICMP-based check. Enter the lineping:<command>into the file/home/blueteam/P6/P6.txt - Download the
google.comhomepage from the internet. Enter the linedownload:<command>into the file/home/blueteam/P6/P6.txt. Make sure you get the homepage and not a redirect page.
P7: Process Management
- List running processes using
psthat displays processes for all users in a user-oriented format that includes processes without a terminal. Enter the lineps:<command>into the file/home/blueteam/P7/P7.txtand enter the flags in alphabetical order - View CPU and memory usage using
topthat displays only the processes for theblueteamuser. Enter the linetop:<command>into the file/home/blueteam/P7/P7.txt
P8: Disk Usage and Filesystem Management
- Check how much space is left on the disk using the
dfcommand and a flag to make the data human readable. Enter the linedf:<command>into the file/home/blueteam/P8/P8.txt - Check how large the
/opt/directory is using theducommand and display the size inK. Enter the linedu:<command>into the file/home/blueteam/P8/P8.txt
P9: Package Management
- Install the package
net-toolsusingapt - Completely
removeandpurgethe packagenmapusingapt
Merit Criteria:
M1: File and Directory Operations
- Count words, lines, and characters. Use the file
/home/blueteam/M1/Never-Gonna-Give-You-Up.txtand put your answers in/home/blueteam/M1/M1.txt- Count the number of words in the file and enter the line
word-count:<command>,<number of words>into the/home/blueteam/M1/M1.txtfile. Ensure that the only number your command returns is the word count. - Count the number of lines in the file and enter the line
lines:<command>,<number of lines>into the/home/blueteam/M1/M1.txtfile - Count the number of characters in the file and enter the line
char:<command>,<number of characters>into the/home/blueteam/M1/M1.txtfile - Count the number of times
Neverappears in the file and enter the linenever:<number of times>into the/home/blueteam/M1/M1.txtfile
- Count the number of words in the file and enter the line
- Use
sedto replace the word “Always” with “Never” in the file/home/blueteam/M1/Never-Gonna-Give-You-Up-sed.txt. Enter the linesed:<command>into the/home/blueteam/M1/M1.txtfile - Combine the commands
cowsayandfortuneto make the cow say a fortune. Enter the linecowsay:<command>into the/home/blueteam/M1/M1.txtfile - Create a hard link to
/home/blueteam/M1-hardlink.txtcalledM1-hardlink.txtin/home/blueteam/M1/: - Create a symbolic link to
/home/blueteam/M1-symlink.txtcalledM1-symlink.txtin/home/blueteam/M1/:
M2: Text Editor Basics
- Open the file
/home/blueteam/M2/WeLoveVim.mdusingVIMand add the lineI <3 VIMas the last line of the file - Using the same file as above use
VIMto find and replace every instance ofNanotoVim
M3: Permissions and Ownership
- Using recursion change the owner of all files and directories in
/home/blueteam/M3toblueteam:sudo - Using recursion change the file (not folder) permissions of all files in
/home/blueteam/M3to640
M4: Networking
- Display all
tcpandudpconnections usingnetstat. Enter the linetcp-udp:<command>into the/home/blueteam/M4/M4.txtfile - Display all connections. Enter the line
all:<command>into the/home/blueteam/M4/M4.txtfile - Display all listening sockets. Enter the line
listening:<command>into the/home/blueteam/M4/M4.txtfile - Display all TCP and UDP connections that are listening and show the numerical addresses instead of resolving the hostnames. Enter the line
everything:<command>into the/home/blueteam/M4/M4.txtfile. Order the flags in alphabetical order.
M5: Process Management
- Create a cronjob for the
blueteamaccount that will execute/home/blueteam/M5/cronScript.pyevery5 minutes. The cronjob should be placed in your user’scrontab - Terminate the process that is running
pleasekillme.pyand remove the cronjob that is enabling it to be persistent but do not remove the script.
You can remove scripts that point to blackteam but do not remove the scripts themselves. Note that the redteam may use accounts that seem to be out of scope to maintain persistence in your system.
M6: Disk Usage and Filesystem Management
- Partition the drive
sdbto usexfsand mount the directory/mnt/M6-mounttosdb - Unmount the drive mounted to
/mnt/M6-unmount
M7: Package Management
- Update and upgrade all packages
- Verify the integrity of system binaries and repair any binaries that do not match
Distinction Criteria:
D1: File and Directory Operations
- Copy the directory
/home/blueteam/D1and all of its contents to/home/blueteam/D1-copyusing recursion. Enter the linecopy:<command>into the/home/blueteam/D1/D1.txtfile.Use the full filepath in the command. - Count the number of files in the directory
/home/blueteam/D1using recursion. Enter the linecount:<count>into the/home/blueteam/D1/D1.txtfile. - Remove all files and subdirectories from
/home/blueteam/D1-copyusing recursion. Enter the lineremove:<command>into the/home/blueteam/D1/D1.txtfile. Use the full filepath in the command. - Locate files by name, type, modification date, and file size.
- Locate all files with
gamein the name. Enter the linegame:<command>into the/home/blueteam/D1/D1.txtfile - Locate all
pythonfiles on the system. Enter the linepython:<command>into the/home/blueteam/D1/D1.txtfile - Locate all files that are larger than
1GB. Enter the line1GB:<command>into the/home/blueteam/D1/D1.txtfile - Locate all files with the
Set User IDpermissions set. Enter the lineSUID:<command>into the/home/blueteam/D1/D1.txtfile
- Locate all files with
- Add the
Set User IDpermission to the file/home/blueteam/D1/script.py
D2: Networking
- Something is listening on port 1337. Find the PID of the process. Enter the line
sus:<filepath>(with the filepath of the file that is running in the process) into the/home/blueteam/D2/D2.txtfile - Kill the process you identified and stop it from respawning.
D3: Process Management
- List all open files. Enter the line
all-files:<command>into the/home/blueteam/D3/D3.txtfile - List all open files for the root user. Enter the line
root-files:<command>into the/home/blueteam/D3/D3.txtfile - List all open files for SSH for your current
SSHsession. Enter the linessh-files:<command>into the/home/blueteam/D3/D3.txtfile
Submission
You don’t need to submit anything for this lab. All of the above criteria will be auto-graded unless stated otherwise. Once you have finished the lab you will have to do a verbal pass off with a TA.
Pass Off Questions
You will be asked two of these questions at random during your verbal pass-off.
- What is the purpose of creating directories and files in Linux, and how does it help in organizing system resources?
- Why might it be important to view the full path of your current directory, especially when working with scripts or configuration files?
- What are some reasons you might want to monitor log files like
/var/log/auth.login real-time, and how could this benefit system security? - In what scenarios would it be useful to view the first or last few lines of a file with commands like
headandtail? - How can the
find and replacefeature be useful in text editors when updating configuration files or scripts? - What does listing hidden files and viewing permissions reveal about the security and access control of a directory?
- Why is it essential to set specific permissions on files, and what could happen if permissions are too open or too restrictive?
- What is the significance of file ownership in Linux, and why would you change a file’s owner to
rootin certain cases? - Why might you create a user without a login shell or password, and in what scenarios could this type of user account be necessary?
- What is the role of groups in Linux, and how does adding a user to the
sudogroup affect their system privileges? - Why is compressing files and directories useful in Linux, and how does it impact storage and file transfers?
- Why would you want to download a web page from the internet using a command, and what are some examples of how this is used in system administration?
- What information does the
pscommand provide about processes, and how does viewing processes for all users improve system monitoring? - Why might you filter processes in
topto show only those for a specific user, and how does this assist in resource management? - What are the advantages of using human-readable formatting when checking disk usage, and what critical information can this reveal?
- What role does package management play in Linux, and why is it crucial to verify that a package is fully installed or completely removed?
Grading:
- Pass: All Pass criteria and verbal pass-off has been completed.
- Merit: All Pass and Merit criteria completed.
- Distinction: All Pass, Merit, and Distinction criteria completed.