Controlling File and Directory Permissions Flashcards
How do you grant ownership of a file to another user?
With chown command
~~~
$ chown user file
~~~
How do you grant ownership of a file to a group?
With chgrp command
~~~
$ chgrp <group-name> <file>
~~~</file></group-name>
What are the default permissions for created files and directories?
666 for files and 777 for directories.
How can you change the default permissions in linux?
By editing the umask value in the /home/user/.profile file.
How does a umask works?
The umask has the same three bits, and its value is subtracted from the default ones. So if the umask value is set to 022, then the default permissions would be 644 for files and 755 for directories.
Is the umask value unique to all users of the system?
No, each user can have a personal umask value.
What are the three special permissions in linux?
- Set user ID (SUID)
- Set group ID (SGID)
- Sticky bit
What is the SUID permission? Describe a situation where it is used.
It’s a way of allowing an user to execute a file with the permissions of its owner. One possible situation is when an user wants to change his password. The SUID will grant him temporarily root privilleges to change the shadow file.
How do you set the SUID bit for a file?
By inserting the number 4 before the usual permissions, as in
~~~
$ chmod 4644 filename
~~~
True or False:
The permissions granted by SUID don’t extend beyond the use
of the file.
True.
What is the SGID permission?
The Set Group ID permission is a way of allowing an user to execute a file with the privilleges of the file owner’s group.
What happens when a directory has the SGID bit set?
Every file created in that directory will be own by the directory creator’s group rather than the file creator’s group.
How do you set the SGID bit for a file?
By inserting the number 2 before the usual permissions, as in
~~~
$ chmod 2644 filename
~~~
What command can be used to look for files starting from the root folder that belongs to the root user and have the SUID bit set?
$ find / -user root -perm -4000
or
~~~
$ find / -user root -perm -u=s
~~~