Skip to main content

Command Palette

Search for a command to run...

Linux Challenge #2 (Users and Permissions)

Published
2 min read
Linux Challenge #2 (Users and Permissions)

Welcome to Linux Challenge #2! In this challenge, you will delve into the world of Linux users and permissions. As an aspiring Linux user, it's crucial to understand how users and permissions work in a Linux system.

  1. Create a new user called "user1".

     sudo adduser user1 # User1 is a name for user
    
  2. Create a new file called "file1.txt" in your home directory.

     touch file1.txt
    
  3. Change the ownership of "file1.txt" to "user1".

     sudo chown user1 file1.txt
    
  4. Confirm that "user1" has read and write permissions for "file1.txt".

     ls -lart # It will list down all the details of that file.
    
  5. Create a new group called "group1".

     sudo addgroup group1 # Group1 is the name of the group
    
  6. Add "user1" to "group1".

     sudo usermod -a -G group1 user1
    
  7. Change the ownership of "file1.txt" to "group1".

     sudo chown :group1 file1.txt
    
  8. Confirm that "group1" has read and write permissions for "file1.txt".

     sudo chmod g+rw file1.txt
    
  9. Create a new directory called "dir1" in your home directory.

     mkdir dir1
    
  10. Change the ownership of "dir1" to "user1".

    sudo chown user1 dir1 # user1 is a user and dir1 is a directory
    
  11. Confirm that "user1" has read, write, and execute permissions for "dir1".

    ls -l dir1
    
  12. Change the ownership of "dir1" to "group1".

    sudo chown :group1 dir1/
    
  13. Confirm that "group1" has read, write, and execute permissions for "dir1".

    sudo chmod g+rwx dir1
    
  14. Create a new user called "user2".

    sudo adduser user2
    
  15. Confirm that "user2" does not have access to "file1.txt" or "dir1".

    ls -l file1.txt #user2 does not have access to text file.
    ls -l dir1 #user2 does not have access to this dir file.
    
  16. Add "user2" to "group1".

    sudo usermod -a -G group1 user2
    
  17. Confirm that "user2" now has access to "file1.txt" and "dir1".

    ls -l file1.txt
    ls -l dir1
    
  18. Remove the "user1" and "user2" users.

    sudo userdel user1 # for removing user1.
    sudo userdel user2 # for removing user2.
    
  19. Remove the "group1" group.

    sudo groupdel group1 # group1 will be deleted.
    
  20. Remove the "dir1" directory and its contents.

    sudo rm -rf dir1
    

    This challenge will test your knowledge and skills in managing Linux users and permissions and will require you to think critically and troubleshoot to complete the tasks successfully. Good luck, and have fun exploring the world of Linux users and permissions!