linux security and file permissions Flashcards

1
Q

what does /etc/passwd store ?

A

stores the user account records.

Each line of text contains one user account record.

Fields in each record are delimited by colons.

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

what are the fields in /etc/passwd user account records

A

user name
user password
user identifier (uid)
group identifier (gid)
gecos field
home directory
shell program

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

description of User name

A

This field contains the user name used to log into the system.

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

description of user password

A

This field contains the hash value of the user password. If the value is set to set to “x”, the actual password is stored in a separate shadow password file.

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

description of User identifier
(UID)

A

This field contains a number used internally by the system to identify the user.

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

description of group identifier

A

This field contains a number which identify the primary group of the user. All files
that are created by this user initially belong to this group.

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

description of gecos field

A

This field contains comments describing the account.

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

description of Home directory

A

This field contains the home directory of the user.

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

description of Shell program

A

This field contains the shell program to start when the user logs into the system.

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

what are the field names in etc/shadow.

A

user name
passwords
last change
minimum
maximum
warning
inactive
expire

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

what does cat /etc/shadow | tail -n 1

A

returns the last line of the contents of the shadow password file.

shadow file contains a hash for each user and therefore the last line is not very meaningful

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

what does cat /etc/shadow | head -n 1

A

returns the first line of the contents of the shadow password file.

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

what does cat /etc/shadow | tail -n 1 | tr “:” “\n”

A

cat /etc/shadow | tail -n 1 | tr “:” “\n” will display the last line of the contents of the shadow password file, with each field separated by a colon (“:”) replaced with a newline.

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

how to check if user login is disabled ?

A

use the grep “guest” /etc/shadow

if it return something like this
guest:!!::43nijnroi32

the !! means user login is disabled

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

how to lock the passwd for guest

A

passwd -l guest

to verify use the grep “guest” /etc/shadow

if it return something like this
guest:!!::43nijnroi32

the !! means user login is disabled

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

how to unlock the passwd for guest

A

passwd -u guest

17
Q

how to add users

A

adduser [name]

18
Q

how to add groups in linux

A

groupadd [options] groupname

19
Q

what is visudo

A

cmd allows you to edit the sudoers file, which controls who is allowed to use the sudo command and what actions they are permitted to perform.

20
Q

what happens if i add User_Alias IT2524_STUDENT = guest, karthik to user_aliases in sudoers file

A

Any time you want to give the users “guest” and “karthik” the same permissions, you can use the “IT2524_STUDENT” user alias in the sudoers file instead of listing the users individually.

21
Q

what happens over here

Command Aliases
These are groups of related commands…
Cmnd_Alias IT2524_COMMAND = /usr/sbin/visudo

A

The command alias “IT2524_COMMAND” is defined to include the command “/usr/sbin/visudo”.

This means that any time you want to give permission to execute the command “/usr/sbin/visudo”, you can use the “IT2524_COMMAND” in the sudoers file instead of listing the command individually.

22
Q

how to check id of user

A

id student

23
Q

what does usermod -a -G student may

A

it will add the user “may” to the group “student”

The -a option is used to append the user to the specified group, which means that it will add the user to the group without removing them from any other groups they may already be a member of.

The -G option is used to specify the group that the user should be added to. In this case, the group is “student”.

24
Q

what does chmod g+s project do ?

the user is student

A

if you have a group “student” and you want to allow the group to create files and directories in a shared directory, you can set the setgid bit on the directory with chmod g+s <directory_name>, this way any files and directories created by any member of the group "student" will be owned by the group "student" and the members of the group will have the permissions to access and modify those files.</directory_name>

25
Q

setgid bit will only take effect on ?

A

setgid bit will only take effect on directories, not on regular files.

26
Q

what happens If a user who is not a member of a group

A

If a user who is not a member of a group sets the setgid bit on a directory, new files and directories created within that directory will inherit the group ownership of the parent directory, but the user will not have any permissions to access or modify those files, as they are not part of the group.