Skip to content

Latest commit

 

History

History

linux-users-groups

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

README.md

Linux Users and Groups Will Finally Make Sense

Video: https://youtu.be/5uKIGLDzg4I
Written version: https://cloudexplainers.com/linux-users-and-groups-will-finally-make-sense/

Everything below ran for real in the video. Run it in a throwaway machine or container, never on a computer you care about.

Commands, in the order the video runs them

Permission denied

# ana@ubuntu:~$
id ben
# ben@ubuntu:~$
touch /srv/team/plan.txt

Users: a name and a number

# ana@ubuntu:~$
whoami
id
tail -n 1 /etc/passwd
head -n 1 /etc/passwd
wc -l /etc/passwd
grep www-data /etc/passwd

Groups

# ana@ubuntu:~$
grep ana /etc/group
groups

Creating users and groups

# ana@ubuntu:~$
sudo useradd -m -s /bin/bash ben
sudo passwd ben
id ben
sudo groupadd team
sudo mkdir /srv/team
sudo usermod -aG team ben
grep team /etc/group

Owners and permissions

# ana@ubuntu:~$
ls -ld /srv/team
sudo chgrp team /srv/team
sudo chmod g+w /srv/team
ls -ld /srv/team
ls -lnd /srv/team

Why Ben was denied

# ben@ubuntu:~$
id
su - ben
id
touch /srv/team/plan.txt
ls -l /srv/team

The -a trap

# ana@ubuntu:~$
sudo usermod -G users ben
id ben
sudo usermod -aG team ben
id ben

From Cloud Explainers. Lab files are MIT licensed (see the repository's LICENSE).