0% found this document useful (0 votes)
34 views

6 sudo command

Uploaded by

Brian K. Acevedo
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)
34 views

6 sudo command

Uploaded by

Brian K. Acevedo
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/ 3

Marvel-Themed Linux sudo Practices: 10 Exercises

Practice 1: Using sudo to Create Protected Directories


Objective: Learn to use sudo to create directories in restricted locations.
Instructions:
1. Open your Linux terminal.
2. Try creating a directory in /root without sudo: mkdir /root/Avengers. You will
receive a "Permission denied" error.
3. Use sudo mkdir /root/Avengers to create the directory with elevated
privileges.
4. Verify the directory's creation by navigating to /root/Avengers using sudo cd.

Practice 2: Using sudo to Edit Protected Files


Objective: Learn to use sudo with text editors to edit system files.
Instructions:
1. Open your terminal.
2. Use sudo nano /etc/avengers_config.txt to create or edit a protected file.
3. Add the text: "Avengers Assemble Configuration."
4. Save the file and exit. Verify the changes using sudo cat
/etc/avengers_config.txt.

Practice 3: Changing File Ownership with sudo


Objective: Use sudo to change file ownership in restricted directories.
Instructions:
1. Navigate to the /root/Avengers directory using sudo cd /root/Avengers.
2. Create a file as root: sudo touch infinity_stone.txt.
3. Change the ownership of the file to your user: sudo chown $USER:$USER
infinity_stone.txt.
4. Verify the ownership change using ls -l.

Practice 4: Installing Marvel-Themed Packages


Objective: Use sudo to install software packages.
Instructions:
1. Open your terminal.
2. Use sudo apt update to update the package index.
3. Install the figlet package (for creating ASCII art): sudo apt install figlet.
4. Use figlet Avengers to display "Avengers" in ASCII art.

Practice 5: Using sudo to Restart Services


Objective: Learn to restart system services with sudo.
Instructions:
1. Open your terminal.
2. Restart the ssh service (or any installed service): sudo systemctl restart ssh.
3. Check the status of the service using sudo systemctl status ssh.
4. Note the output to verify that the service is running.

Practice 6: Removing Protected Files with sudo


Objective: Use sudo to delete files in restricted directories.
Instructions:
1. Navigate to the /root/Avengers directory: sudo cd /root/Avengers.
2. Create a test file: sudo touch test_file.txt.
3. Delete the file using sudo rm test_file.txt.
4. Verify the file's removal with sudo ls.

Practice 7: Using sudo for User Management


Objective: Use sudo to manage users on the system.
Instructions:
1. Add a new user named IronMan: sudo useradd IronMan.
2. Set a password for the user: sudo passwd IronMan.
3. Verify the user’s creation by listing system users: sudo cat /etc/passwd | grep
IronMan.

Practice 8: Granting sudo Access to a User


Objective: Use sudo to grant another user administrative privileges.
Instructions:
1. Open the sudoers file using sudo visudo.
2. Add the line IronMan ALL=(ALL) NOPASSWD:ALL to grant IronMan full sudo
privileges without requiring a password.
3. Save and exit.
4. Log in as IronMan and test their sudo access.

Practice 9: Viewing System Logs with sudo


Objective: Use sudo to read restricted system logs.
Instructions:
1. Open your terminal.
2. Use sudo cat /var/log/auth.log to view authentication logs.
3. Search for sudo commands run on the system using sudo grep sudo
/var/log/auth.log.

Practice 10: Testing Commands with sudo Simulation


Objective: Simulate sudo commands without executing them using the -l option.
Instructions:
1. Use sudo -l to list the commands your user is allowed to run with sudo.
2. Identify commands listed in the output.
3. Try running a command listed in the output using sudo, such as sudo ls /root.

You might also like