CDAC Linux
CDAC Linux
Administration
Abrar Ali Khan Zai - Blr, Kar, IN
[email protected]
9880331503
Meeting ID: 37
Passcode: 370626
https://docs.google.com/document/d/1LNAwT_IkQl2_PiBLlq6VgnexBGUgOWA_AxCc36vuxMM/edit?usp=sharing
1.
Day 1: Tue, 5 Mar. ‘24
1.
Download Links:
https://aka.ms/vs/17/release/vc_redist.x64.exe
https://the.earth.li/~sgtatham/putty/latest/w64/putty-64bit-0.80-installer.msi
Lab Manual
1. Setup VirtualBox VM
https://docs.google.com/document/d/1X8ptyuI5p3efjkqSpxsqursNMfSbm0Pkwl7-PRibsBM/edit?
usp=sharing
/docs.google.com/document/d/169zigjAdYms9c3LHGoDloa4NETXSPf31csV1PreIBC8/edit?usp
=sharing
https:/
Ess_LabManual_02_Organise_Files
4. Changing FIle Permissions & Ownership
https://docs.google.com/document/d/154o-PHpZiO36PZ7koh9cBVqbNz6CRxsArfOLOTd18lI/edi
t?usp=sharing
When you power on your Linux system in text mode you get a login screen.
eg:
student
password
Once you login to your account you get a command prompt
eg:
[student@vm1-abrar ~]$
[student@vm1-abrar ~]$
Student is the username
vm1-abrar is the computer name
tilde ( ~ ) represent you are in your home directory ( /home/abrar/ )
The dollar symbol ( $ ) means you are a normal user not administrator
[root@vm1-abrar ~]#
The pound symbol ( # ) means you are a privileged user or administrator
Be very careful in the root account; any accidental errors can impact all users on the system.
You have been warned.
13 whatis mkdir
14 man mkdir
15 mkdir os
16 ll
17 mkdir hardware
18 ll
19 mkdir software
20 ll
21 mkdir firmware
22 mkdir ransomware
23 ll
24 man rmdir
25 rmdir ransomware/
26 ll
27 rmdir firmware/
33 cd os
34 pwd
35 ll
36 mkdir unix
37 ll
38 cd unix
39 pwd
40 mkdir solaris
41 ll
42 cd solaris
43 pwd
44 cd
45 pwd
46 ll
47 ll os
48 ll os/unix
49 ll os/unix/solaris
50 pwd
51 touch linux
52 ll
53 touch dos
54 ll
55 touch unix
56 ll
57 touch MacOS
58 ll
59 mkdir Operating System
60 ll
61 mkdir -v my_os
62 ll
63 mkdir your-os
64 ll
65 mkdir -v their.os
66 ll
67 mkdir -v "my work"
68 ll
69 rm dos
70 ll
71 rm unix
72 ll
73 rm -v linux
74 ll
75 rm macos
76 rm -v MacOS
77 ll
78 rmdir myos
79 rmdir my_os
80 ll
81 rmdir your-os
82 ll
83 rmdir -v their.os
84 ll
85 ll os
86 rmdir -v os
87 rm -v os
88 rm -rv os
89 ll
90 mkdir -v grandpa
91 mkdir -v grandpa/father
92 mkdir -v grandpa/father/son
93 mkdir -v grandpa/father/son/grandson
94 ls
95 ls -R grandpa
96 rm -rv grandpa
97 history
98 mkdir -pv grandma/mother/daughter/son
99 ls -R grandma
100 whatis nano
101 man nano
102 which nano
103 which tree
104 whoami
105 su - root
106 whatis touch
107 whatis tree
108 whatis nano
109 which tree
110 which nano
111 ll
112 tree grandma
113 tree
114 nano basic-commands.txt
115 ll
116 cat basic-commands.txt
117 ls -a
118 cat .bashrc
119 ls -a
120 cat .bash_profile
121 ls -a
122 cat .bash_logout
123 cat basic-commands.txt
124 history
cat .bashrc
22 cat -n .bashrc
23 cat -n .bash_profile
24 cat -n .bash_logout
25 whatis wc
26 wc -l .bashrc
27 wc -w .bashrc
28 wc -c .bashrc
29 wc -lwc .bashrc
30 cat .bashrc
31 head .bashrc
32 tail .bashrc
33 head -n 3 .bashrc
34 head -n 7 .bashrc
35 tail -n 7 .bashrc
36 tail -n 17 .bashrc
37 tail -n 1 .bashrc
38 ls -a
39 cat .bashrc
40 whatis grep
41 grep function .bashrc
42 grep bin .bashrc
43 grep path .bashrc
44 grep -i path .bashrc
45 ll /etc/group
46 cat -n /etc/group
47 grep 10 /etc/group
48 grep body /etc/group
49 history
9 whatis mv
10 mv -v wednesday wed
11 ll
12 mv -v weekdays week
13 ll
14 touch fri
15 mkdir -v end
16 ll
17 mv -v fri friday
18 mv -v end weekend
19 ll
20 mkdir -v linux
21 touch redhat rocky centos
22 ll
23 mv -v centos linux
24 ll
25 mv -v redhat linux
26 ll
27 mv -v rocky linux
28 ll
29 tree linux
30 mkdir -v unix
31 touch solaris aix hpux
32 ll
33 mv -v aix hpux solaris unix
34 ll
35 tree unix
36 history
45 mkdir -v planets
46 touch mercury venus earth mars
47 ll -tr
48 mv -v venus mercury planets
49 cp -v mars earth planets
50 ll -tr
51 tree planets
52 mkdir march
53 touch feb
54 rmdir march
55 rm feb
56 mkdir 2024
57 touch 2024/march
58 rm -rv 2024
59 mkdir april
60 touch april/wise
61 touch april/fool
62 tree april
63 # -i means interactive; this applies to cp mv rm
64 rm -ivr april
65 tree april
66 mkdir microsoft
67 touch microsoft/dos
68 touch microsoft/windows
69 tree microsoft
70 rm -ivr microsoft
71 tree microsoft
72 history
4 whatis useradd
5 useradd user1
6 ll /home
7 useradd user2
8 ll /home
9 tail /etc/passwd
10 useradd user3
11 tail /etc/passwd
12 passwd user1
13 tail /etc/shadow
14 passwd user2
15 tail /etc/shadow
16 passwd user3
17 tail /etc/shadow
18 su - user1
19 whoami
20 history
grep text filename shows lines containing specified grep body /etc/passwd
word in text file
File operations
72 useradd sales
73 tail /etc.passwd
74 tail /etc/passwd
75 whatis usermod
76 usermod -u 1234 sales
77 tail /etc/passwd
78 usermod -c 'sales account' sales
79 tail /etc/passwd
80 group buisness
81 groupadd buisness
82 usermod -G buisness sales
83 whatis chage
84 chage -l sales
85 passwd sales
86 chage -l sales
87 chage -M 60 sales
88 chage -l sales
89 chage -W 5 sales
90 chage -l sales
91 chage --help
92 man chage
93 useradd ceo
94 passwd ceo
95 chage -l ceo
96 chage -E 2025-11-30 -W 5 -M 120 ceo
97 chage -l ceo
98 tail /etc/shadow
99 history
5 date
6 date > today
7 ll -tr
8 cat today
9 who
10 who > loggers
11 ll
12 cat loggers
13 ls /
14 ls / > main-dirs
15 ll
16 cat main-dirs
17 whoami
18 ls -R /tmp
19 ls -R /tmp 2> tmp-err
20 ll
21 cat tmp-err
22 ls -R /boot
23 ls -R /boot > boot-out
24 ls -R /boot > boot-out 2> boot-err
25 ll
26 head boot-err boot-out
27 history
1 whoami
2 id -u
3 pwd
4 ll -a
5 id student
6 date
7 date > >
8 date > today
9 ll -tr
10 cat today
11 who
12 who > loggers
13 ll -tr
14 cat loggers
15 ls /
16 ls / > main-dirs
17 ll
18 cat main-dirs
19 whoami
20 ls
21 ls -R /tmp
22 ls -R /tmp 2> tmp-err
23 tmp err
24 ll
25 ls -R /boot
26 ls -R /boot > boot-out
27 ls -R /boot > boot-out 2> boot-err
28 ll
29 head boot-err boot-out
30 history
31 ls -R /etc
32 ls -R /etc &> etc-both
33 cat etc-both
34 grep -i permission etc-both
35 ls -R /home
36 ls -R /home &> home-errs
37 ll
38 cat home-errs
44 history | wc
45 history | head
46 history | tail
47 history | tail -n 15
48 history | grep cat
49 history | grep id
50 history | grep cp
51 who
52 who | wc -l
53 cal 2024
54 cal 2024 | head -n 15
55 cal 2024 | tail -n 15
56 ll /
57 ll / | grep bin
58 ll / | grep lib
59 ll / | grep tmp
5 date
6 date > today
7 ll -tr
8 cat today
9 who
10 who > loggers
11 ll
12 cat loggers
13 ls /
14 ls / > main-dirs
15 ll
16 cat main-dirs
17 whoami
18 ls -R /tmp
19 ls -R /tmp 2> tmp-err
20 ll
21 cat tmp-err
22 ls -R /boot
23 ls -R /boot > boot-out
24 ls -R /boot > boot-out 2> boot-err
25 ll
26 head boot-err boot-out
27 history
5 date
6 date > today
7 ll -tr
8 cat today
9 who
10 who > loggers
11 ll
12 cat loggers
13 ls /
14 ls / > main-dirs
15 ll
16 cat main-dirs
17 whoami
18 ls -R /tmp
19 ls -R /tmp 2> tmp-err
20 ll
21 cat tmp-err
22 ls -R /boot
23 ls -R /boot > boot-out
24 ls -R /boot > boot-out 2> boot-err
25 ll
26 head boot-err boot-out
27 history
5 date
6 date > today
7 ll -tr
8 cat today
9 who
10 who > loggers
11 ll
12 cat loggers
13 ls /
14 ls / > main-dirs
15 ll
16 cat main-dirs
17 whoami
18 ls -R /tmp
19 ls -R /tmp 2> tmp-err
20 ll
21 cat tmp-err
22 ls -R /boot
23 ls -R /boot > boot-out
24 ls -R /boot > boot-out 2> boot-err
25 ll
26 head boot-err boot-out
27 history
When we use the ls -l command we can see the file permissions and ownership
eg:
rwx r- - - - - abrar
mail filename
In the symbolic method the symbols in the below table are used
FIle Permissions
user u
group g
other o
all a
read r
write w
execute x
not set -
add +
remove -
assign absolutely =
39 mkdir access
40 ll
41 cd access
42 ll
43 touch file-{a,e,i,o,u}
44 ll
45 grep student /etc/passwd
46 grep student /etc/group
47 ll
48 mkdir dir-{A..E}
49 ll
50 chmod -v g+w dir-A
51 chmod -v o-rx dir-B
52 chmod -v g+w,o-rx dir-C
53 chmod -v ugo+x file-a
54 chmod -v u+x,g+w,o-r file-e
55 chmod -v a+x file-i
56 chmod -v ugo=r file-o
57 chmod -v u=rwx,g=r,o=--- file-u
58 ll
Changing FIle ownership and Group ownership
eg:
86 mkdir project
87 cd project
88 touch task-{1..5}
89 ll
90 id student
91 chown -v student task-1
92 id pupil
93 chown -v pupil task-2
94 grep developers /etc/group
95 lid -g developers
96 ll
97 chgrp -v developers task-3
98 grep wheel /etc/group
99 chgrp -v wheel task-4
100 ll
101 chown -v student:mail task-5
102 ll
103 mkdir notebook
104 touch notebook/page-{1..7}
105 ll
106 ll notebook
107 ll
108 chown -v student notebook
109 ll
110 ll notebook
111 chown -vR student notebook
112 ll notebook
113 chgrp -v mail notebook
114 ll
115 ll notebook
116 chgrp -vR mail notebook
117 ll notebook
118 ll
119 chmod -v o-rx notebook
120 ll
121 ll notebook
122 chmod -vR o-rx notebook
123 cd
rwx r- - - - - 740
1 ll .bashrc
2 mkdir sample
3 cd sample
4 touch sample-{1..7}
5 ll
6 chmod -v 777 sample-1
7 chmod -v 775 sample-2
8 chmod -v 755 sample-3
9 chmod -v 700 sample-4
10 chmod -v 711 sample-5
11 chmod -v 666 sample-6
12 chmod -v 640 sample-7
13 ll
14 history
Managing Processes
ps
ps a
ps au
ps aux
ps -ef
etc.
kill -15 <PID> kill a process gracefully; this is the recommended approach
kill -9 <PID> kills a process abruptly; this should be used only when signal 15 is not taking
effect.
4 ps au|head
5 ps aux | head
6 ps aux | wc -l
7 ps aux | grep bash
8 ps aux | grep cron
9 ps aux | grep ssh
10 sleep 3
11 sleep 60 &
12 ps aux | grep sleep
13 whatis kill
14 sleep 200 &
15 ps aux | grep sleep
16 kill -15 3350
17 sleep 100 &
18 ps aux | grep sleep
19 kill -15 3365
20 ps aux | grep sleep
21 cd /proc
22 ls
23 s basleep 50 &
24 ls
25 cd 3377
26 ls
27 cat comm
28 cd
29 sleep 200 &
30 kill -9 3394
31 ps aux | grep sleep
32 ps aux
33 whatis top
34 top
35 sleep 30 &
36 top
37 dd if=/dev/zero of=/dev/null &
38* ps aux | grep
39 ps aux | grep -w dd
40 top
41 dd if=/dev/zero of=/dev/null &
42 top
43 history
hist
The vi Editor
To create and edit text files in Linux we have gedit, nano and vi.
vi works in 3 modes
1. command mode
2. insert mode
3. extended mode
In command mode we can navigate the file (up, down, right, left) etc
In extended mode we do file operations like saving, quitting, saving and quitting, quitting
without saving etc
Some Vi command ( in command mode)
j go down
k go up
l go right
h go left
gg go to 1st line
G go to last line
w go forward a word
b go back a word
yy copy a line
ESC
:q quit file
vi is a modal editor
we have 4 modes:
command mode
insert mode
extended mode
visual mode
Managing Services
systemctl
systemctl | grep <service-name>
eg:
Control Services
15 systemctl
16 history
17 systemctl is-active crond
18 systemctl is-active sshd
19 systemctl is-active atd
20 systemctl is-enabled atd
21 systemctl is-enabled sshd
22 systemctl is-enabled crond
23 systemctl stop crond
24 systemctl is-active crond
25 systemctl stop atd
26 systemctl is-active atd
27 systemctl start atd
28 systemctl is-active atd
29 systemctl start crond
30 systemctl is-active crond
31 systemctl restart sshd
32 systemctl status crond
33 systemctl status sshd
34 history
A web server is a system that holds web pages to be shown to users asking for them through
web browsers.
Package: httpd
Service: httpd
Port: 80/tcp
Configuration FIle: /etc/httpd/conf/httpd.conf
The directory where we keep web pages is called the DocumentRoot which is /var/www/html/
by default.
lsblk
fdisk -l
Mount the formatted drive on new mount point mount -v /dev/sdb1 /mnt/new-data
Check if the device has got mounted correctly findmnt | grep sdb1
Store some data to new partition to test cp -rv /boot /var/log /mnt/new-data
pvcreate /dev/sdb2
pvcreate /dev/sdb3