Chapter 04 of 17
Control access and redirection
Understand permissions as access rules, not magic numbers.
The mental model.
Permissions are evaluated for the owner, the file’s group, or everyone else. Read is 4, write 2, and execute 1. 640 means owner read/write, group read, and no access for others. chmod changes modes; chown changes ownership.
Directory permissions differ from file permissions: read lists names, execute traverses a directory, and write permits changing entries. Deleting a file is governed mainly by the containing directory, with sticky-bit rules adding restrictions in shared locations such as /tmp.
> creates or truncates an output file; >> appends. The shell performs redirection before starting the command. sudo echo text > /etc/example does not elevate the shell opening the file. A carefully scoped sudo tee is often the appropriate pattern.
umask removes default permission bits from newly created files and directories; it does not alter existing files. ACLs can add named user or group rules, with a mask limiting effective permissions. Avoid chmod 777 as a troubleshooting shortcut.
Read it. Predict it. Try it.
Before running these commands, predict what each line will change or print. Launch a quest below to open the simulated terminal.
echo "private notes" > notes.txt
chmod 600 notes.txt
ls -l notes.txt
echo "second entry" >> notes.txt
cat notes.txtThe file should be readable and writable only by its owner. Appending preserves the first entry; using > again would replace it.
Check your understanding
Explain the why.
Put it into practice.
Complete the exercises, then try the Boss Challenge without hints. Each quest checks its own objectives. You can revisit this chapter at any time.
Make the learning stick.
Close the explanation and describe the main idea in your own words. Change a filename or input and predict the outcome. Tomorrow, repeat a quest without hints. Then apply it in a disposable real Linux environment.
Open the real-system labs →