Skip to content

Permission Bits

You'll create a second user, read and set the rwx mode on files by hand, lock yourself out of a file on purpose, and find out why every sudo call ends up in a log.

About

Every file on Linux has an owner, a group and nine permission bits, and almost every confusing error in your first year is one of those being wrong. This evening you'll make a second user so you can see the system from the other side of the fence, set permissions in both the letter and the number form, and find out why running everything with sudo is the fastest way to a broken home directory. You'll also learn the one rule that prevents most disasters: never chmod -R 777 anything, no matter what the forum post says.

At a glance

Per requirement
15 XP
Completion bonus
75 XP
Requirements
6
Takes
One evening
Skill level
Novice (never tried it)
Cost
Free
Supplies
Nothing special
Where
At home
Other people
On your own

Requirements

  1. 1
    Make a second user and log in as them. Use adduser or useradd -m, give them a password, and log in as them in a terminal with su - or on a second console (Ctrl-Alt-F3). Try to read a file in your own home directory from there and watch it fail. Take a photo of the permission denied message with both usernames visible in the prompt. Photo
  2. 2
    Read ls -l and explain every column of one line. Pick a file, run ls -l on it, and write out what each field means: the type, the three sets of rwx, the link count, the owner, the group, the size and the date. Take a photo of the output and your explanation beside it. Photo
  3. 3
    Set permissions with letters and then with numbers to get the same result. Make a script file, make it executable with chmod u+x, then set the same thing with chmod 744, and show that stat reports the same mode. Then do 600 and 755 and say what each one allows. Take a photo of the terminal showing both forms producing the same output. Photo
  4. 4
    Share one directory between your two users with a group. Make a group, add both users to it, chown the directory to that group, and set the setgid bit so new files inherit the group. Log in as the second user and create a file in it. Take a photo of ls -l showing the shared directory and the file with the right group. Photo
  5. 5
    Lock yourself out of a file and get back in. As your normal user, chmod 000 a file you own, try to read it, then fix it without sudo. You can, because the owner can always change the mode. Then make a file with sudo in your home directory and work out why you can't edit it afterwards. Take a photo of the chain of commands and the error. Photo
  6. 6
    Read the sudoers file and run one command as root with the log open. Run sudo visudo to read it and change nothing, then run a harmless command with sudo and find it in the auth log or in journalctl. Every sudo call is recorded, which is the thing people forget. Take a photo of the log line with your username and the command in it. Photo