Linux User Management Deep Dive Flashcards

1
Q

What 2 shortcuts of cding into home dir do you know?

A

cd ~

cd $HOME

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

How to create a new user with his full name description, specify and create new home dir, set primary and secondary group, set a password, specify a shell, and specify UID all with a SINGLE COMMAND?

A

useradd -c “[user description]” -d [path to home dir] -m -g [primary group] -G [secondary group] -p [password] -s [path to shell] -u [uid] [username]

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

How to change users primary group, change secondary group, append secondary group?

A

usermod -g [primary group] -G [secondary group] [user name] - change primary group, and set secondary group to the one typed in this command
usermod -aG [group] [user] - append secondary group

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

How to change user’s home directory to a new one, and move content of the old home dir into the new one?

A

usermod -d [new home dir path] -m [username]

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

Where are default new user’s profile files stored?

A

/etc/skel

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

Whrere is GID conf file stored?

A

/etc/login.defs

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

How to create a group with GID of 30045?

A

groupadd -g 30045 [groupname]

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

What is the difference between primary and secondary group?

A

Primary group – Specifies a group that the operating system assigns to files that are created by the user. Each user must belong to a primary group.

Secondary groups – Specifies one or more groups to which a user also belongs. Users can belong to up to 15 secondary groups.

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

How to change group ID and group name?

A

groupmod -g [new GID] -n [new name] [old name]

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

Can you remove a group that is some user’s primary group?

A

yes, with a grupdel -f [groupname] command

without “-f” the shell won’t allow us to do this

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

How to change password for a group? How to remove it?

A

gpasswd [groupname] - changes password

gpasswd -r [groupname] - removes it

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

How to add many users to a group with a single command?

A

gpasswd -M [user1],[user2],[user3] [group name]

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

How to run a integration test of user and group config files?

A

pwck

grpck

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

How the “last resort” troubleshooting /etc/passwd and /etc/group commands work?

A

The pwconv command creates shadow from passwd and an optionally
existing shadow.

   The pwunconv command creates passwd from passwd and shadow and
   then removes shadow.

   The grpconv command creates gshadow from group and an optionally
   existing gshadow.

   The grpunconv command creates group from group and gshadow and
   then removes gshadow.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What types of UID there are?

A

0 - root
1-999 - system/application users
1000+ normal users

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

What is a shell and what are a few of it types? Where are they located?

A

Simply put, the shell is a program that takes commands from the keyboard and gives them to the operating system to perform. In the old days, it was the only user interface available on a Unix-like system such as Linux. Nowadays, we have graphical user interfaces (GUIs) in addition to command line interfaces (CLIs) such as the shell.

Bourne-Again Shell - /bin/bash
Bourn Shell - /bin/sh
Korn Shell - /bin/ksh

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

How to print a message for given user login attempt, and not allow that user to login into system?

A

We would have to change his login bash to /sbin/nologin. We would have to put message into /etc/nologin.txt file.

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

How to not allow an user to log in into the system at all?

A

Change user shell to /bin/false

or /sbin/nologin

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

How to allow only the root user to login into the system?

A

We have to create /etc/nologin file. (we can write the message in it that will display upon user’s login attempt)

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

Give a few examples of config files from user’s home directory?

A

.bash_profile
.bashrc
.bash_logout

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

How is /etc/passwd built?

A

username:x:UID:primary group GID:comment:home dir:login shell
x - password is stored in /etc/shadow file

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

How is /etc/gshadow built?

A

groupname:password:group admins:group members

password field can either have:

  • encrypted password
  • ”!” - no user is allowed to access the group using the newgrp command.
  • ”!!” - A value of !! is treated the same as a value of ! — however, it also indicates that a password has never been set before.
  • null - If the value is null, only group members can log into the group.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

how is /etc/shadow built?

A

username:password:days after the 1.1.1970 that the password was last changed:minimum amount of days that the password can be changed:maximum amount of days before the password has to be changed:days before password expiration that the users gets warning message:days after password expiration that the user is disable:days since 1.1.1970 that the password expires

password field can either have encrypted password, or “!!” which means that the account is locked, as the password has never been set

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

how is /etc/group built?

A

name:x:GID:to which users group is set as secondary

x indicated that password info is stored in /etc/gshadow

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

Where can you disable automatic creation of home directories with useradd (eg. useradd user1)

A

/etc/login.defs

CREATE_HOME no

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

How to remove user account and his home directory with a single command?

A

userdel -r [user]

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

How to remove a group?

A

groupdel

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

What is the difference between .bashrc and bash_profile file?

A

.bash_profile is read and executed when Bash is invoked as an interactive login shell, while .bashrc is executed for an interactive non-login shell.

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

What is the difference between login and non-login shell?

A

A Login shell is started after a successful login, A Non login shell is started by a program without a login.

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

What does “!!” in /shadow mean?

A

That the account is locked, and the password had never been set. (if it doesn’t have encrypted password following “!!”)

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

What does “!” in /gshadow mean?

A

no user is allowed to access the group using the newgrp command.

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

What is hashed password with salt? And how does it look like in linux files?

A

When a password has been “hashed” it means it has been turned into a scrambled representation of itself. A user’s password is taken and – using a key known to the site – the hash value is derived from the combination of both the password and the key, using a set algorithm.

Salting is simply the addition of a unique, random string of characters known only to the site to each password before it is hashed, typically this “salt” is placed in front of each password.

In linux encrypted password has this format:
$5$saaNd4DIN34$asidasojnasd
Fields are seperated by a “$”. First fields is for ID for hashing algorithm, second is the salt, and third is the hashed password string

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

How to lock, unlock, delete, expire user’s password with a command?

A

passwd -l -u -d -e [username]

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

How to set the number of days after the password expires that the account is going to be disabled?

A

chage -I [days] [username]

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

How to set minimum amount of days between password changes?

A

chage -m

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

How to set maximum password life time?

A

passwd -x [days] [username]
or
chage -M [days] [username]

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

How to change amount of days before password expires that the user will get a warning message?

A

passwd -w [days] [username]

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

How to display password status? What does it show?

A

chage -l

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

How to display password status with a command different than passwd -S?

A

chage -l [username]

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

How to change aging information for an user with a single command?

A

chage [username]

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

How to change account expiration day?

A

chage -E [days after 1970.1.1] [username]

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

With what two commands you can change user/password expiration configuration?

A

chage, passwd

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

How to set account expiration to never with a single command?

A

chage -E -1 [username]

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

How to expire account immediately

A

chage -E 0 [username]

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

What are .rpmnew and .rpmsave files?

A

When an upgrade includes changes to a default configuration file, instead of overwriting the configuration file on your system — and possibly nuking the changes you have made — the package will write one of these file types. An .rpmnew file contains the new default configuration file and leaves your original configuration file untouched. By contrast, and .rpmsave file is a copy of your original configuration file, which has been replaced by the new default file.

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

What does everything in this line of sudoers file stand for, and what does command do?
[username] ALL=(ALL) NOPASSWD:ALL

A

[username] - user
ALL - on all hosts
=(ALL) - as any user
ALL - can run any commands

So bassicaly you give give user root privilages with that line

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

What visudo is for?

A

visudo checks the file syntax before actually overwriting the sudoers file

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

What sign states that “we are talking” about groups in /etc/sudoers file?

A

%
example:
%wheel ALL=(ALL) NOPASSWD:ALL

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

How to allow anyone that belongs to an xyz group to run ‘touch’ and ‘mkdir’ command as any host and as any user without prompting for password, and run the pwd command in the same fashion but with prompting for passwd?

A

By adding this line to /etc/sudoers file:

%xyz ALL=(ALL) NOPASSWD: /bin/touch, /bin/mkdir PASSWD: /bin/pwd

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

What is the purpose of /etc/sudoers.d/90-cloud-init-user file?

A

It is used for cloud users configuration

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

What is the purpose of /etc/sudoers.d/ssm-agent-users file?

A

It is used for ssm-agent user configuration

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

How to run a command in a backgroung?

A

[command] &

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

How to see given user’s processes?

A

ps U [user]

54
Q

How to search through system for files owned by a user?

A

find -user [user]
or
find [directory] -user [user]

55
Q

How to find files that might have belonged to user whose account has been deleted?

A

find -nouser

56
Q

What would be the correct proccess of deleting an user?

A

First we would delete files (or change permission) that the user owns, and kill all user’s processes. Then we can safely delete the account.

57
Q

what does grep -i do?

A

It greps with ignoring case sensetivity

58
Q

What are 3 special file permissions?

A

setuid - When an executable file’s setuid permission is set, users may execute that program with a level of access that matches the user who owns the file.

setgid - affects both files and directories. When used on files, is very similar to setuid. A process, when executed, will run as the group that owns the file.
Setting the setgid permission on a directory (chmod g+s) causes new files and subdirectories created within it to inherit its groupID, rather than the primary groupID of the user who created the file (the ownerID is never affected, only the groupID). Newly created subdirectories inherit the setgid bit.

sticky bit - When a directory’s sticky bit is set, the filesystem treats the files in such directories in a special way so only the file’s owner, the directory’s owner, or root user can rename or delete the file. Without the sticky bit set, any user with write and execute permissions for the directory can rename or delete contained files, regardless of the file’s owner. Typically this is set on the /tmp directory to prevent ordinary users from deleting or moving other users’ files.

59
Q

What does capital S in this file permissions stand for? rwxrwSr–? (or T for directories in rwxrw-rwT)

A

That there is setgid bit, but the file has no execute permissions for group. (T means that it has sticky bit added for others, but there is no executable permission for this directory)

60
Q

What does setgid do for files and directories?

A

When used on files a process, when executed, will run as the group that owns the file.
Setting the setgid permission on a directory (chmod g+s) causes new files and subdirectories created within it to inherit its groupID, rather than the primary groupID of the user who created the file (the ownerID is never affected, only the groupID). Newly created subdirectories inherit the setgid bit.

61
Q

What is a sticky bit?

A

When a directory’s sticky bit is set, the filesystem treats the files in such directories in a special way so only the file’s owner, the directory’s owner, or root user can rename or delete the file. Without the sticky bit set, any user with write and execute permissions for the directory can rename or delete contained files, regardless of the file’s owner. Typically this is set on the /tmp directory to prevent ordinary users from deleting or moving other users’ files.

62
Q

What is setuid?

A

When an executable file’s setuid permission is set, users may execute that program with a level of access that matches the user who owns the file.

63
Q

What does read write and execute permissions on directory do?

A

The read bit (r) allows the affected user to list the files within the directory
The write bit (w) allows the affected user to create, rename, or delete files within the directory, and modify the directory’s attributes
The execute bit (x) allows the affected user to enter the directory, and access files and directories inside

rw- —-> only lists the contents of directory
r-x ——-> access, lists directory, access the files inside, but cannot create new files or modify current files attributes (renaming, deleting itp.)
rwx ——–> do everything

64
Q

What does “.” and “+” mean in the last spot of permission? (eg. rwx—rw-+ rwx—rw-.)

A

+ means that the file has additional ACLs set

. indicates a file with an SELinux security context, but no other alternate access method.

65
Q

What is SELinux?

A

Security-Enhanced Linux (SELinux) is a security architecture for Linux systems that allows administrators to have more control over who can access the system.

66
Q

What is the ACL?

A

Access control list (ACL) provides an additional, more flexible permission mechanism for file systems. It is designed to assist with UNIX file permissions. ACL allows you to give permissions for any user or group to any disc resource

67
Q

What is ACL mask?

A

The mask entry indicates the maximum permissions allowed for users (other than the owner) and for groups. The mask is a quick way to change permissions on all the users and groups.

For example, the mask:r– mask entry indicates that users and groups cannot have more than read permissions, even though they might have write/execute permissions.

68
Q

What does 4, 2, 1 and 0 stand for in the first number of umask? (EG. 4777)

A

0755 —- None of the special bits set
1755 —- Sticky bit set
2755 —- SGID bit set
4755 —- SUID bit set

69
Q

How to check file’s ACL?

A

getfacl [filename]

70
Q

How to set ACL for files or directories?

A

setfacl

71
Q

What is ACL mask?

A

ACL mask defines the maximum effective permission for named users, named groups, or the group owner of a file

72
Q

How to change file/dir mask? (no umask!)

A

setfacl -m mask:[permissions] [file/dir]

73
Q

What does change in displayed permission (rwx–xrwx…) when a file/dir has an mask set?

A

Instead of group permissions it will display mask permissions.

74
Q

What will happen, when we give “xyz” group rwx permission to some file, that has a mask set to rw? How to exclude execute permission from that file using file’s mask?

A

The mask will recalculate, so it will change to rwx.

We would have to set up the mask again with setfacl -m command.

75
Q

How to restrict some user’s permission to a file, so he won’t have any?

A

setfacl -m u:[user]:-

76
Q

How to give some single user rw permission using ACL?

A

setfacl -m u:[user]:rw

77
Q

How to remove named entry from ACL? (eg. single user’s permissions, single group permissions)

A

setfacl -x g:[group]

setfacl -x u:[user]

78
Q

What does lsblk command do?

A

lsblk lists information about all available or the specified block devices

79
Q

What are block devices in linux?

A

A block device is a device you can read blocks from. For example hard disks, cdrom drives and floppies are block devices, but not the keyboard. You can receive data from the keyboard and regard them as blocks, but you cannot seek on the keyboard. You can tell a hard disk “give me block 5433”, then block 7707, then block 1807 and you cannot do this with a keyboard, so, a keyboard is no block device.

A Block Device is a device whose driver communicates by sending entire blocks of data.

80
Q

What is a device driver?

A

A device driver (often referred to as ‘driver’) is a piece of software that controls a particular type of device which is connected to the computer system. It provides a software interface to the hardware device, and enables access to the operating system and other applications.

A driver provides a software interface to hardware devices, enabling operating systems and other computer programs to access hardware functions without needing to know precise details about the hardware being used.

81
Q

What are blocks in linux?

A

Disk drives are like post office boxes. They are numbered from one to whatever, and each one holds just a small amount of information. Each of these “boxes” is called a block.

blocks - these are the discrete units of storage. You can’t have a large # of blocks of small size because you’ll need to keep track of what files are written to what blocks. More, smaller blocks = less wasted space due to partially used blocks, but you need a bigger “index” to keep track of what file is in what block.

82
Q

What are character devices?

A

A Character Device is a device whose driver communicates by sending and receiving single characters (bytes, octets). Example - serial ports, parallel ports, sound cards, keyboard.

83
Q

What does fdisk command do?

A

fdisk also known as format disk is a dialog-driven command in Linux used for creating and manipulating disk partition table. It is used for the view, create, delete, change, resize, copy and move partitions on a hard drive using the dialog-driven interface.

84
Q

How to create a new partition on xvdb disk? How to set up Quotas on that new partition for app group? Explain what commands we have to use and what are the steps.

A

This will show us what disks are available:
# lsblk
The first available 2 GB disk is /dev/xvdb, so we’ll create a partition on that one:

# fdisk /dev/xvdb
We'll be prompted to answer some questions. Press these keys:

n to make a new partition
p for a primary type partition
Enter to choose 1 as a default partition number
Enter to pick the default as the first sector
Enter to pick the default as the first sector
w to write the changes to the disk.

Run partprobe afterward, to ensure the partition table has been updated. If we run lsblk again, we’ll see that the xvdb disk has one 2G partition, xvdb1.
Let’s create an ext4 filesystem on the /dev/xvdb1 partition:
# mkfs -t ext4 /dev/xvdb1

Create the Directory for the Mount Point and Change the Group to app
We’ll create the mount point with this:

# mkdir /app
Configure /etc/fstab with the UUID of /dev/xvdb1 and Mount the Filesystem
We're going to make an entry in /etc/fstab, but first we need the UUID for /dev/xvdb1. Let's grab it with this:
# blkid /dev/xvdb1
The output should look something like this:

/dev/xvdb1: UUID=”d6a5691b-a045-463f-bf2b-74d0c71895e2” TYPE=”ext4”

We can copy that UUID and paste it into an /etc/fstab entry. Get fstab open in a text editor, then make a line with the following options:
UUID=d6a5691b-a045-463f-bf2b-74d0c71895e2 /app ext4 defaults,grpquota 1 2

Now we can mount our newly added filesystems with this:
# mount -a
Now let's make sure that the app group owns it:
# chgrp app /app

Install the quota Package, Create the Quota Files for the /app Filesystem, and Generate the Table of Current Disk Usage for Each Filesystem
Let’s install the quota package with the yum command:

# yum install -y quota
Now let's create the quota files for the /app filesystem:
# quotacheck -cug /app
Generate the table of current disk usage per filesystem:
# quotacheck -avug
We can ignore that error about journaled quota.

Assign a Soft Quota of 512 KB and a Hard Quota of 1M (1024KB) to the app Group, Then Turn Quotas on and Check the Group Quota Configuration for /app
Let’s assign a soft quota of 512 KB, and a hard quota of 1M (1024KB), to the app group:

$ edquota -g app
That command will fire up a Vim session where we can change the soft and hard quotas like this:

Disk quotas for group app (gid 1004):
Filesystem blocks soft hard inodes soft hard
/dev/xvdb1 0 512 1024 0 0 0

Turn quotas on for the filesystem:
$ quotaon -vug /app

Verify the group quota configuration for /app:
$ repquota -g /app

85
Q

What’s the difference between primary and extended partition?

A

Historically, hard drives were only been able to contain at most four partitions because of the originally defined format of the partition table. This is not specific to operating systems. You simply can’t create more than four primary partitions under the original PC partition scheme (MBR partitions).

In order to circumvent this limit and still remain compatible with older systems, you can create an extended partition however. An extended partition can contain multiple logical partitions within it. This allows you to create more than four partitions in total, without having to change the format of the partition table.

More precisely: an extended partition contains itself again a partition table, which can hold up to four partitions, each of which can in turn be an extended partition which holds a partition table … leading to a 4-ary tree of partition tables. Or actually, a linked list, since DOS itself only supports one primary and one extended partition per partition table. In other words: an extended partition is a primary partition which itself contains another partition table, a logical partition is a primary partition which does not sit in the root partition table.

86
Q

What is a partition?

A

When referring to a computer hard drive, a disk partition or partition is a section of the hard drive that is separated from other segments. Partitions enable users to divide a physical disk into logical sections. For example, allowing multiple operating systems to run on the same device.

87
Q

What is a primary partition?

A

Primary partitions / system partitions hold the operating system files and can be made “Active” partition to boot the computer from. A maximum of 4 Primary partitions can be created, or 3 Primary and an Extended partition.

88
Q

How to inform the OS of partition table change?

A

partprobe

89
Q

What is a file system?

A

A filesystem is the software that converts from documents and folders the way users like to see them to the blocks that disk drives hold. For every file, there is some information about who owns it, when they last changed it, which blocks hold the actual data, and so on.

90
Q

How to create ext4 file system on a newly created partition?

A

mkfs -t ext4 [path to partition]

91
Q

What is a mount point?

A

Mount point is a directory (typically an empty one) in the currently accessible filesystem on which an additional filesystem is mounted (i.e., logically attached).
File systems on different partitions and removable devices, such as CDs, DVDs, or USB flash drives, must be attached to the directory hierarchy to be accessed. To attach a partition or device, a mount point must be created. A mount point is simply a directory created with the mkdir command. After a directory, or mount point, is created, attach the partition by using the mount command.

92
Q

What is UUID in Linux?

A

UUID is a unique identifier used in partitions to uniquely identify partitions in Linux operating systems.

93
Q

What is /etc/fstab for?

A

The /etc/fstab file is a system configuration file that contains all available disks, disk partitions and their options. Each file system is described on a separate line. Each line contains six fields separated by one or more spaces or tabs. If you add a new hard disk or have to repartition the existing one, you’ll probably need to modify this file.

The /etc/fstab file is used by the mount command, which reads the file to determine which options should be used when mounting the specified device.

94
Q

What are the options inside of /etc/fstab?

A

Device – the first field specifies the mount device. These are usually device filenames. Most distributions now specify partitions by their labels or UUIDs.

Mount point – the second field specifies the mount point, the directory where the partition or disk will be mounted. This should usually be an empty directory in another file system.

File system type – the third field specifies the file system type.

Options – the fourth field specifies the mount options. Most file systems support several mount options, which modify how the kernel treats the file system. You may specify multiple mount options, separated by commas.

Backup operation – the fifth field contains a 1 if the dump utility should back up a partition or a 0 if it shouldn’t. If you never use the dump backup program, you can ignore this option.

File system check order – the sixth field specifies the order in which fsck checks the device/partition for errors at boot time. A 0 means that fsck should not check a file system. Higher numbers represent the check order. The root partition should have a value of 1 , and all others that need to be checked should have a value of 2.

95
Q

How to mount all filesystems mentionen in fstab?

A

mount -a

96
Q

What does “mounting filesystem” mean?

A

Mounting a filesystem simply means making the particular filesystem accessible at a certain point in the Linux directory tree.

97
Q

What is Linux Quota?

A

It’s a system that allows to gain to separate users or group assigned (among others) limit to how much disk space can they use.

98
Q

How to create quota files for filesystem?

A

quotacheck -cug [partition path]

99
Q

How to generate the table of current disk usage per filesystem?

A

df -h

100
Q

Assign a Soft Quota of 512 KB and a Hard Quota of 1M (1024KB) to the app Group, Then Turn Quotas on and Check the Group Quota Configuration for /app

A

edquota -g app (That command will fire up a Vim session where we can change the soft and hard quotas)

Turn quotas on for the filesystem:
quotaon -vug /app

Verify the group quota configuration for /app:
repquota -g /app

101
Q

Where are linux logs stored?

A

/var/logs

102
Q

What are 5 main logs files in Red Hat OS and what do they do? (/var/logs/..)

A

secure - logs all authentication related system errors
mailog - logs all mail server system events
cron - logs all cron system events
boot.log - logs all system startup events
messages - logs all other system events

103
Q

What is syslog?

A

It’s a standard network-based logging protocol that works on an extremely wide variety of different types of devices and applications, allowing them to send free text-formatted log messages to a central server.

104
Q

Where can we configurate what syslog does with error messages?

A

/etc/syslog.conf

105
Q

What is a “pam” in Linux?

A

Pluggable Authentication Modules, basically, it is a flexible mechanism for authenticating users.

106
Q

How to search for keywords in all files in a xyz directory?

A

grep [keyword] /xyz/*

107
Q

Tell us what are the commands (in correct sequence) needed, to install user and group quota on the new partition? And how to create that partition. (From linux academy lab)

A

groupadd [group]
change users primary group to [group]

lsblk

fdisk [path to disk device] (n p w)

partprobe

mkdir [dir to mount point]

chgrp [group for quota] [dir to mount point]

mkfs -t ext [partition]

blkid [path to disk device]

vim /etc/fstab (uuid, mount point, filesystem defaults,grpquota,userquota 1 2)

mount -a

yum install -y quota

quotacheck -cug [mount point]

quotacheck -avug

edquota -g [group]

edquota -u [user]

quotaon -vug [mount point]

quota [user]
quota -g [group]
repquota -g /app
repquota -u /app

108
Q

What is the difference between “sudo su -“ and “sudo su”?

A

sudo su: Calls sudo with the command su. Bash is called as interactive non-login shell. So bash only executes .bashrc.

sudo su -: This time it is a login shell, so /etc/profile, .profile and .bashrc are executed and you will find yourself in root’s home directory with root’s environment.

109
Q

What for is the /etc/sudoers.d/ ?

A

Changes made to files in /etc/sudoers.d remain in place if you upgrade the system. This can prevent user lockouts when the system is upgraded. Ubuntu tends to like this behavior. Other distributions are using this layout as well.

So you can create some files, and give root or some permissions there to specific users, instead of adding them in the /etc/sudoers file.

use visudo -f /etc/sudoers.d/[file] to create/edit sudoers.d files

110
Q

What permissions should files in /etc/souders.d/ have?

A

0440

111
Q

How to create alias command group? And assign it to users?

A

Cmnd_Alias [Aliasname] = full paths to commands

[user] ALL = [aliasname]

112
Q

Difference between public and private ip?

A

Private IP address is used with a local network and public IP address is used outside the network. Public IP address is provided by ISP, Internet Service Provider. … Private IP Address is used to communicate within the network. Public IP Address is used to communicate outside the network

113
Q

How to set minimum password length to 12 characters?

A

Set the minimum password length to 12 characters:

  1. Run the command vim /etc/pam.d/common-password.
  2. At the end of the first uncommented line after the “# here are the per-package modules (the “Primary” block)” line add minlen=12, one space after sha512.
114
Q

What for is the /etc/pam.d/ directory?

A

When a PAM aware privilege granting application is started, it activates its attachment to the PAM-API. This activation performs a number of tasks, the most important being the reading of the configuration file(s): /etc/pam.conf. Alternatively, this may be the contents of the /etc/pam.d/ directory. The presence of this directory will cause Linux-PAM to ignore /etc/pam.conf.

115
Q

What for is the /etc/login.defs file?

A

The /etc/login.defs file provides default configuration information for several user account parameters. The useradd, usermod, userdel, and groupadd commands, and other user and group utilities take default values from this file. Each line consists of a directive name and associated value.

116
Q

How to change default minimum and maximum days between password changes?

A

By editing the PASS_MAX_DAYS, PASS_MIN_DAYS lines in /etc/login.defs.

117
Q

How to search in vim/vi for keywords?

A

”/[keyword]”
n - next word
N - previous word

118
Q

Where can we configure the account lockout settings?

A

in /etc/pam.d/common-auth

119
Q

How to set expiration date with command other then passwd and use the calendar notation?

A

chage -E “yyyy-mm-dd” [user]

120
Q

What is symlink?

A

A symlink (also called a symbolic link) is a type of file in Linux that points to another file or a folder on your computer. Symlinks are similar to shortcuts in Windows. Some people call symlinks “soft links” – a type of link in Linux/UNIX systems – as opposed to “hard links.”

121
Q

How to create links?

A

with ln command
ln -s [file] [symlink]
hardlinks:
ln [file] [hardlink]

122
Q

How will permissions look for symlinks or hard links?

A

lrwxlrwxlrwx. “l” for symlinks

no indication for hard links

123
Q

How will permissions look for symlinks or hard links?

A

lrwxlrwxlrwx. “l” for symlinks
no indication for hard links

For hard links you would want to check files inodes with ls -i command. They will have the same inode

124
Q

How to create symlinks, so we can safely move file to other directory?

A

create symlinks with absolute path

125
Q

How to check inode of files?

A

ls -i

126
Q

How to check inode of files?

A

ls -i

127
Q

What is an inode?

A

There is a thing called the “primary key” - often a ‘number’ that is unique in the database, so it points to a unique record of data.

An inode is that “primary key” - it is the unique key on a single file system that tells the system where a particular file is located.

You can see the inode by $ ls -i

Now, note I said “on a single file system” above? It’s because a different file system can have ‘the same’ inode number pointing to a different file.

This means that you can do a “hard link” to a file on the same file system with two different file names pointing to the same inode (and thus the same file on that filesystem), but if you want to link two file names across different file systems, you have to use a “soft-link” - you can not “hard link” across filesystems.

Think of all your files as logical and all the locations on disks as physical. The inode is the “glue” that holds it together.

In Linux the file doesn’t point to a physical location. After all you can have files that point to other files such as a link.

So the files point to an inode and the inode tells where the actual data is on the disk

128
Q

How to login as some user and choose the login shell?

A

(sudo) su - [user] -s [path/to/shell]

129
Q

Where to set user default umask?

A

/etc/.bash_profile

130
Q

How to set default ACL for a group in a given directory?

A

setfacl -m d:g:[groupname]:[permissions] [directory]