Create a user named test with home directory
Create a user named finley. This user should have a comment (GECOS field) that reads "Financial Auditor". Ensure the user is created without a home directory.
Verify all users' creation
Verify user is created with/without a home directory
Delete all the users, even in home directory
Solution
sudo useradd test
sudo useradd -c "Financial Auditor" -M finley
grep finley /etc/passwd
ls /home
sudo userdel -r test
sudo userdel -r finley
Find the manual page that describes the configuration file for the local password database (not the command to change the password, but the file where user information is stored).
Identify the section number (e.g., 1, 5, or 8)
Solution
man -k password | grep file --> Found passwd (5) = Section 5 contain password files
man 5 passwd
Create a file named /home/anil/list.txt.
The file must contain 10 lines.
Lines 1 through 5 should say "Primary".
Lines 6 through 10 should say "Secondary".
Use vim recording.
Solution
Create user anil at home directory
sudo useradd anil
Check user created or not
grep anil /etc/passwd
ls /home
Create Password
sudo passwd anil
Switch user
su - anil
Open vim
vim
Press Esc to make sure in Normal Mode
Insert 10 lines
10i --> Enter --> Esc
Get back to top
gg
Start recording a
qa
Insert mode
I
Type Primary
Quit Insert mode
Esc
Move to next line
j
End recording
q
Run recording a
4@a
Start recording b
qb
Insert mode
I
Type Secondary
Quit Insert mode
Esc
Move to next line
j
End recording
q
Run recording b
4@b
Press Esc to make sure in Normal Mode.
Save as list.txt
:w list.txt
Exit vim
q!
Check file
ls
Within the /tmp directory, create a directory structure that looks like this: deploy/scripts/backup.
You must create all three levels with a single command.
Solution
Back to root directory
cd /
Check tmp directory
ls
Direct to tmp directory
cd tmp
Create directory
-p means parent directory, create if parent (/deploy & /script) directory is missing
mkdir -p deploy/scripts/backup
Check directory
ls