104.5 Manage file permissions and ownership Flashcards

1
Q

What is a synonym of ‘permission’ for a directory or file?

A

Mode

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the symbolic ways to represent modes or permissions on a file?

A

r,w,x (read-write-execute)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does the write permission mean in a directory or file?

A

Someone can write to the directory or file or change its name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does the “x” permission mean for a directory?

A

Someone can execute the action of opening that directory (cd into it).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the octal values of permission symbols?

A

r=4
w=2
x=1
-=0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the command to change the permissions of a file?

A

chmod

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the command to change the permissions of a file for others(world) with the symbolic method removing the read permission?

A

chmod o-r

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you change the permissions of files (remove read from others) within a directory recursively without changing the directory’s permissions?

A

chmod -R o-r /*

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you remove group and world permissions from a file using octal notation, keeping read and write for the user(owner)?

A

chmod 600

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What command do you use to change the owner of a file or directory?

A

chown or #chgrp

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you change the group ownership on a file or a directory for a group?

A
#chown : 
#chgrp
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the only user that can change the user ownership of a file?

A

Root

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What happens if the uid of the user matches the owner of a file or directory?

A

Those permissions apply and the user can open the file or directory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What happens if the uid of the group matches the group of a file or directory?

A

Those permissions apply and the group members can open the file or directory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What happens if the uid of the user or the group don’t match?

A

The ‘other’ permissions apply.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Can any user change his own password using the passwd command?

A

Yes, any one can in spite of the user and group being root:root

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is the ‘s’ in -rwsr-xr-x within the user’s column?

A

The ´s´ stands for SUID (set User ID bit)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What does the SUID (set User ID bit) do?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What command do you use to set the SUID (set User ID) to a file in octal notation?

A
It uses a 4 as the leading number preceding the usual 3 permissions:
#chmod 4777 test.sh
20
Q

What command do you use to set the SUID (set User ID) to a file in symbolic method?

A

chmod u+s test.sh

21
Q

What command do you use to remove the SUID (set User ID) to a file in octal?

A
It uses a 0 as the leading number preceding the usual 3 permissions:
#chmod 0777 test.sh
22
Q

What command do you use to remove the SUID (set User ID) from a file in symbolic method?

A

chmod u-s test.sh

23
Q

What command shows you what groups you currently belong to?

A
#id
#groups
24
Q

How do you switch from one user’s account to another in the CLI?

A

su -

25
Q

What is the SGID?

A

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.

26
Q

What is the SGID useful for?

A

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.

27
Q

What command do you use to set the SGID (set Group ID) to a directory in octal?

A
It uses a 2 as the leading number preceding the usual 3 permissions:
#chmod -R 2777
28
Q

Once you set the SGUI to a directory, what happens to the new files created there after in that directory?

A

Only the new ones inherit the group ownership.

29
Q

Once you set the SGUI to a directory, what happens to the new files created there after in that directory?

A

Only the new ones inherit the group ownership.

30
Q

What is the sticky bit?

A

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

31
Q

What command do you use to assign a sticky bit to a file?

A

chmod 1777

32
Q

What numbers represent the SUID, the SGID and the sticky bit when adding them to a file or directory?

A

SUID: 4
SGID: 2
Sticky bit: 1

33
Q

What other command is usually used with the xargs command?

A

find

34
Q

What does the #umask command display?

A

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.

35
Q

What are the default permissions given to a directory when it is created?

A

777

36
Q

What are the default permissions given to a file when it is created?

A

666

37
Q

How is the output of the #umask command interpreted for an ordinary user?

A
#umask
0002:  
0 special permissions (SUID, SGID or sticky bit)
0 user or owner 
0 group
2 others or world
38
Q

How is the output of the #umask command interpreted for the root user?

A
#umask
0022:  
0 special permissions (SUID, SGID or sticky bit)
0 user or owner
2 group
2 others or world
39
Q

What is the umask for root and for ordinary users?

A

Users: 0002
Root: 0022

40
Q

What is the result of applying a umask of 0002 for regular user´s files and directories?

A

Umask Users: 0002
Directories: 0777 - 0002 = 775
Files: 666-0002 = 664

41
Q

What is the result of applying a umask of 0022 for root’s files and directories?

A

Umask for root: 0022
Directories: 0777 - 0022 = 755
Files: 666-0022 = 644

42
Q

Which is the file that mandates what the umask is for the whole system?

A

/etc/bashrc

43
Q

Which is the file that mandates what the umask is for the individual users?

A

/home/user/.bashrc

44
Q

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?

A

$umask u+rwx,g-rwx,o-rwx (new umask is 0077)

45
Q

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?

A

source .bashrc