LINUX · Permissions · 8 min
Create private files by default
Use a shell umask before creating a directory and dummy token.
Not completedYour task
Set umask 077 in this practice shell, create protected, and write synthetic-only to protected/token.txt. The directory must be 700 and the file 600.
What you’re aiming for
- protected has mode 700.
- token.txt has mode 600 and contains only synthetic-only.
1. Prepare your practice folder
Use a Linux terminal, such as Ubuntu or WSL on Windows. These examples use Linux file permissions. In WSL, create your practice folder in your Linux home directory (~).
Create a new, empty folder for this exercise. If that name already exists, choose another new name. Continue only after you’re inside the new folder.
mkdir opsrung-linux-private-by-default && cd opsrung-linux-private-by-default
This task starts with an empty folder; no starter files are needed.
2. Try the task
Work toward the goal above. Start by inspecting the files or resources, then use a hint if you need one.
Hint 1
umask removes permission bits when new files are created.
Hint 2
Set the mask before mkdir and file creation.
Hint 3
Use umask 077, then create the directory and file.
3. Review your result
Use these commands to look at your result and compare it with the goals. The website does not run or verify them.
ls -ld protected ls -l protected/token.txt cat protected/token.txt
What you should see
- protected has mode 700.
- token.txt has mode 600 and contains only synthetic-only.
If your result differs: Compare the actual output with each goal. Keep your work inside this exercise’s folder and use only its named resources.
Compare with one possible solution
umask 077 mkdir protected printf '%s\n' 'synthetic-only' > protected/token.txt
Other approaches are fine if you reach the same goal. Opening this solution does not mark the exercise complete.
Finished this exercise?
You decide when you’re done. Your choice is saved in this browser, and you can change it later.