linux basic security Flashcards

1
Q

explain what this does and every part:
cat /etc/passwd | grep “/root”

A

This command will display the information related to user accounts where the home directory is set to “/root”

1) cat displays file content of /etc/passwd
2) /etc/passwd is a system file that stores information about users
3) | a command-line operator that allows the output of one command to be passed as input to another command
4) grep “/root” filters out results to display the lines that match the search criteria

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

explain what this does and every part:
cat /etc/passwd | grep “seed”

A

1) cat displays file content of /etc/passwd
2) /etc/passwd is a system file that stores information about users
3) | a command-line operator that allows the output of one command to be passed as input to another command
4) grep “seed” filters out results to display the lines that match the search criteria

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

what is and what does it contain:
/etc/passwd

A

1) it is a plain text file that stores essential information required during login for every user account
2) contains user fields separated by comma
e.g.
name:password:UID:GID:User info:Directory:Shell
sarah:x:1001:Sarah Selama:/home/sarah:/bin/bash

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

what type of access does /etc/passwd have and why:

A

1) read only
2) because many command utilities and system processes rely on it to map user IDs (UIDs) to user names

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

which user has write access to the /etc/passwd file:

A

root user (superuser)

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

length of user in /etc/passwd

A

1-32 characters

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

x in /etc/passwd

A

1) an encrypted password saved in the /etc/shadow file
2) can be used ONLY by root to verify/write a user password

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

what are the UID numbers reserved for in /etc/passwd

A

1) zero for /root
2) 1-99 are for predefined accounts
3) 100-999 are reserved by system for
administrative and system accounts/groups

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

what happens when a user tries to log in

A

1) the operating system will compare username and password with those in the /etc/passwd file, once authentication..
2) the operating system creates an initial process specifically for that user (user’s login shell)
3) UID of this initial process is set based on the third field of the corresponding entry in the /etc/passwd file

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

two ways to add a user

A

1) use adduser command
2) manually add a new record to the /etc/passwd and /etc/shadow files

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

what will this display:
grep seed /etc/group

A

groupname:x:GID:user1:user2:….:usern

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

what will this display:
groups

A

the names of all the groups for the currently logged-in users

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

break this down and what it does:
sudo usermod -a -G prof user1

A

> sudo: execute superuser commands
usermode: modify user
-a: append
-G: groupname, followed by username

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

what is:
sudo groupadd prof

A

> creates a group called “prof”

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

types of access on files and explain each:

A

– read (r): user can view the contents of the file
– write (w): user can change the contents of the file
– execute (x): user can execute or run the file if it is a program or script

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

types of access for directories and explain each

A

– read (r): user can list the contents of the directory (e.g., using ls)
– write (w): user can create files and sub-directories inside the directory
– execute (x): user can enter that directory (e.g., using cd)

17
Q

the two categories that rights are divided into

A

> permission
ownership

18
Q

difference between:
ls -al and ls -ls

A

-al includes all the files that start with a “.”
-ls excludes all the files that start with a “.”

19
Q

columns of ls:

A

file size (blocks)
file type
owner access rights
group access rights
other access rights
number of links
user owning the file
groups owning the file
file size (bytes)
date: MDY
filename

20
Q

what is umask

A

a system setting that determines the default permissions for newly created files and directories

21
Q

which commands do you use to set permissions to a file and create it

A
  • umask (umask value)
  • touch (filename.type)
22
Q

which command do you use to create new directory in the current directory

A
  • mkdir (new_directory)
23
Q

what happens if mkdir (new_directory) throws an error and how do you handle it

A
  • it means directory already exists
  • create a parent directory using:
    $ mkdir -p main_directory/intermediate_directory/target_directory
    which then you can use to add your new directory
24
Q

what is ls -l t*

A

a command that shows details of every file that starts with the letter t
* represents any character after t

25
Q

what happens if you run
- umask 022
- touch t1
but file t1 exists

A

it will update the timestamp and that’s it

26
Q

what is the ACL (access control list) model

A

a model that allows file owners or privileged users to grant rights to specific subjects (users, or group of users)

27
Q

difference between traditional model and ACL model

A
  • the traditional model has a fixed number of permission sets (owner, group, others)
  • the ACL model allows for additional entries to specify permissions for specific users or groups.

ACL provides more flexibility in assigning permissions, allowing for more customized access control

28
Q

the length of permission list and the subjects in ACL

A
  • length is 3 (rwx)
  • subject is either owner, group, or other
29
Q

difference between getfacl and setfacl

A
  • getfacl retrieves the ACL entries for a file or directory and displays them
  • setfacl sets or modifies the ACL entries for a file or directory, allowing you to define or change the access control settings
30
Q

breakdown:
setfacl {-m, -x} {u,g}:<name>:[r,w,x] <file,directory></name>

A

> setfacl: modified the ACL entries for a file or directory
-m: modify ACL entries
-x: removes ACL entries
u: for user
g: for group<name>: of user or group
[r,w,x]: rwx permissions
<file,directory>: specifies the file or directory for which the ACL entries are being set or modified
</name>

31
Q

what does the + indicate here:
-rw-rw-r–+

A

that ACLs are defined

32
Q

what is the structure of the password entry in the /etc/shadow file

A

$id$salt$password_hash$
> id: specifies the algorithm id
> salt: random numbers added to password to make them complex
> password_hash: output of user’s password that was passed into a hash function

33
Q

what does “!” mean in the password field

A

account has been locked or disabled