Skip to content

Instantly share code, notes, and snippets.

@paulghaddad
Created October 13, 2014 16:11
Show Gist options
  • Save paulghaddad/5fe0e09a3bbedc9778af to your computer and use it in GitHub Desktop.
Save paulghaddad/5fe0e09a3bbedc9778af to your computer and use it in GitHub Desktop.
Level Up 1: Understands Unix file permissions
1. Use touch to create a new file in the /tmp directory. What permissions do user / group / and world have to that file by default?
cd /tmp
touch new_file.txt
# The permissions of user, group and world are:
user: read, write
group: read
world: read
2. Use chown to change ownership of that file to the root user and root group.
Ask the group about this one
sudo chown root new_file.txt
# illegal group name for the root group on Macs, but this will work on Linux:
sudo chown :root new_file.txt
3. So that we can continue to use it, use chmod to grant read and execute permissions to everyone for that file using the 'absolute' syntax.
sudo chmod 755 new_file.txt
4. We also want to remove the ability for the root group to write the file. Use the 'symbolic' syntax to remove that permission.
sudo chmod g-w new_file.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment