From the course: CompTIA Linux (XK0-005) Cert Prep

Unlock the full course today

Join today to access over 23,100 courses taught by industry experts.

Elevate group privileges

Elevate group privileges

- [Instructor] We've seen that we can switch users if we have that user's password using the su command. This isn't always ideal. A nicer solution is to change to a different primary group. By doing so, we gain the privileges of the group as opposed to the user. We can do this using the new group command. Let's create a new group by typing in sudo groupadd accounting, and hit Enter. And enter your password if prompted. Now let's add a password to our group by typing in sudo gpasswd accounting, and hit Enter. Type in the desired group password when prompted. We can verify that this worked by viewing the /etc/gshadow file. Type in sudo cat /etc/gshadow, and hit Enter. We can see that the accounting group has a password. Now as user1, let's switch primary groups by using the new group command. Type in newgrp accounting and hit Enter, and enter the accounting group's password. We can now verify our primary group by…

Contents