104.5 Manage file permissions and ownership Flashcards
What is a synonym of ‘permission’ for a directory or file?
Mode
What are the symbolic ways to represent modes or permissions on a file?
r,w,x (read-write-execute)
What does the write permission mean in a directory or file?
Someone can write to the directory or file or change its name
What does the “x” permission mean for a directory?
Someone can execute the action of opening that directory (cd into it).
What are the octal values of permission symbols?
r=4
w=2
x=1
-=0
What is the command to change the permissions of a file?
chmod
What is the command to change the permissions of a file for others(world) with the symbolic method removing the read permission?
chmod o-r
How do you change the permissions of files (remove read from others) within a directory recursively without changing the directory’s permissions?
chmod -R o-r /*
How do you remove group and world permissions from a file using octal notation, keeping read and write for the user(owner)?
chmod 600
What command do you use to change the owner of a file or directory?
chown or #chgrp
How do you change the group ownership on a file or a directory for a group?
#chown : #chgrp
What is the only user that can change the user ownership of a file?
Root
What happens if the uid of the user matches the owner of a file or directory?
Those permissions apply and the user can open the file or directory.
What happens if the uid of the group matches the group of a file or directory?
Those permissions apply and the group members can open the file or directory.
What happens if the uid of the user or the group don’t match?
The ‘other’ permissions apply.
Can any user change his own password using the passwd command?
Yes, any one can in spite of the user and group being root:root
What is the ‘s’ in -rwsr-xr-x within the user’s column?
The ´s´ stands for SUID (set User ID bit)
What does the SUID (set User ID bit) do?
Applications with an ‘s’ in the place of the ‘x’ permission within the user’s column allow any user to run the program as if they were the owner of the application
What command do you use to set the SUID (set User ID) to a file in octal notation?
It uses a 4 as the leading number preceding the usual 3 permissions: #chmod 4777 test.sh
What command do you use to set the SUID (set User ID) to a file in symbolic method?
chmod u+s test.sh
What command do you use to remove the SUID (set User ID) to a file in octal?
It uses a 0 as the leading number preceding the usual 3 permissions: #chmod 0777 test.sh
What command do you use to remove the SUID (set User ID) from a file in symbolic method?
chmod u-s test.sh
What command shows you what groups you currently belong to?
#id #groups
How do you switch from one user’s account to another in the CLI?
su -
What is the SGID?
It is the ´set group id bit’. Files and folders with the ´s´in the place of the ´x´permission within the group´s column have this set. This assigns group membership to files.
What is the SGID useful for?
It is useful for group directories. Multiple members of the same group can write to any files created by any members of the group, regardless of who created the files.
What command do you use to set the SGID (set Group ID) to a directory in octal?
It uses a 2 as the leading number preceding the usual 3 permissions: #chmod -R 2777
Once you set the SGUI to a directory, what happens to the new files created there after in that directory?
Only the new ones inherit the group ownership.
Once you set the SGUI to a directory, what happens to the new files created there after in that directory?
Only the new ones inherit the group ownership.
What is the sticky bit?
This permission has a ´t´in place of the ´x´in the other´s column. This permission allows only the creator of a file to remove the file: rwx rwx rwt
What command do you use to assign a sticky bit to a file?
chmod 1777
What numbers represent the SUID, the SGID and the sticky bit when adding them to a file or directory?
SUID: 4
SGID: 2
Sticky bit: 1
What other command is usually used with the xargs command?
find
What does the #umask command display?
It shows the current umask settings for a user (what is taken away from the default permissions for files and directories when they are created).
It can also be used to set a new umask value for the current shell session.
What are the default permissions given to a directory when it is created?
777
What are the default permissions given to a file when it is created?
666
How is the output of the #umask command interpreted for an ordinary user?
#umask 0002: 0 special permissions (SUID, SGID or sticky bit) 0 user or owner 0 group 2 others or world
How is the output of the #umask command interpreted for the root user?
#umask 0022: 0 special permissions (SUID, SGID or sticky bit) 0 user or owner 2 group 2 others or world
What is the umask for root and for ordinary users?
Users: 0002
Root: 0022
What is the result of applying a umask of 0002 for regular user´s files and directories?
Umask Users: 0002
Directories: 0777 - 0002 = 775
Files: 666-0002 = 664
What is the result of applying a umask of 0022 for root’s files and directories?
Umask for root: 0022
Directories: 0777 - 0022 = 755
Files: 666-0022 = 644
Which is the file that mandates what the umask is for the whole system?
/etc/bashrc
Which is the file that mandates what the umask is for the individual users?
/home/user/.bashrc
What command would you use to set the umask for a regular user in which new files and directories only have owner full permissions and none for the group or others?
$umask u+rwx,g-rwx,o-rwx (new umask is 0077)
What command do you use to force your current shell environment to use your new .bashrc file to re-read a new mask entered and have it used in a new session?
source .bashrc