Every user of a Linux server belongs to one or more groups.
To see your user and your groups, you use the commandidlike this:netops@automation:~$ id uid=1000(netops) gid=1000(netops) groups=1000(netops),27(sudo)
Figure 1 - The Output of id
To see the groups of another user, you add its name, like
id lea.In the lab, look at the groups of the users
leaandmarc.Answer the question below
Which group are lea and marc both in?
rootis the user that can do everything on the server.
A user of the groupsudocan run one command as root by typingsudobefore it.Here,
whoamiprints the user who runs the command:netops@automation:~$ sudo whoami root
Figure 2 - sudo Runs One Command as root
In the lab, read the file
/root/flag.txtwithcatto get the flag.Answer the question below
Enter the flag you obtained.
To create a user, you use the command
useraddwith the option-mlike this:netops@automation:~$ sudo useradd -m webadmin
Figure 3 - useradd -m Creates a User and Its Home Directory
In the lab, create the user
webadminwith its home directory to get the flag.Answer the question below
Enter the flag you obtained.
To add a user to a group, you use the command
usermodwith the option-aGlike this:netops@automation:~$ sudo usermod -aG sudo webadmin netops@automation:~$ id webadmin uid=1001(webadmin) gid=1001(webadmin) groups=1001(webadmin),27(sudo)
Figure 4 - usermod -aG Adds a User to a Group
The first
sudoruns the command as root.
The secondsudois the name of the group.In the lab, add
webadminto the groupsudoto get the flag.Answer the question below
Enter the flag you obtained.