0% found this document useful (0 votes)
20 views64 pages

Rhcsa Cla

The document outlines a training schedule for a batch starting on April 15, 2024, covering various Linux commands and file management techniques over several days. It includes practical exercises on commands like 'mkdir', 'cp', 'mv', 'echo', and text editing using 'vi', as well as tasks involving file manipulation and data retrieval. The training emphasizes hands-on practice with file creation, copying, moving, and searching through files using command-line tools.

Uploaded by

jagdalesaee024
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views64 pages

Rhcsa Cla

The document outlines a training schedule for a batch starting on April 15, 2024, covering various Linux commands and file management techniques over several days. It includes practical exercises on commands like 'mkdir', 'cp', 'mv', 'echo', and text editing using 'vi', as well as tasks involving file manipulation and data retrieval. The training emphasizes hands-on practice with file creation, copying, moving, and searching through files using command-line tools.

Uploaded by

jagdalesaee024
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 64

15 april 2024 batch

Day 1
=============
17-4-2024
whoami
2 pwd
3 hostname
4 cd /
5 pwd
6 ls
7 cd
8 pwd
9 cd /bin
10 cd
11 pwd
12 cd /
13 ls
14 cd boot
15 cd
16 pwd
echo -e "hello all \n this is nice eve"
2 echo -e "hello all \nthis is nice eve"
3 echo -e "hello all \nthis is nice eve" > file
4 cat file
5 echo -e "hello all \t this is nice eve"
6 echo -e "hello all \v this is nice eve"
7 echo -e "hello all \t this is nice eve"
8 echo -e "hello all \v this is nice eve"

Day 2
==================
18-4-2024
1 touch test.txt
2 ls
3 ls -l
4 touch file1.txt
5 ls -l
6 cat file1.txt
7 touch unnati{1..100}
8 ls
9 touch unnati{1..100}.txt
10 ls
11 history
12 touch myfile testfile yfile jfile
13 ls
14 history
15 ls * --hide '*.txt'
16 history
17 ls --hide '*.txt'
18 ls -I 'unnati*'
19 tree
20 ls -I 'u*'
21 ls -I 'u*' > myfile.doc
22 cat myfile.doc
23 mkdir /mydata
24 cd /mydata/
25 ls
26 touch file{1..10}.txt
27 touch file{1..10}.doc
28 touch file{1..10}.html
29 ls
30 ls -I '*.txt'
31 ls -I '*.doc'
32 cd
33 ls
34 mkdir testdata
35 cd testdata/
36 cat myfile
37 cat > myfile
38 ls
39 cat myfile
40 cat > myfile
41 cat myfile
42 cat >> myfile
43 cat myfile
44 cd
45 mkdir unnati
46 cd unnati

========================
day3
20-4-2024

mkdir fold
2 ls
3 ls -ld fold
4 mkdir test
5 ls -ld test
6 mkdir redhat
7 ls -l
8 ls -ld redhat/
Day 4
22-4-2024
#mkdir data
2 #mkdir data
3 mkdir data
4 ls
5 pwd
6 mkdir unnati
7 ls
8 mkdir data/redhat unnati/data1
9 mkdir data/redhat/unnati unnati/data1/myfold /tmp/unnati /mnt/fold
10 cd data/redhat/unnati/
11 pwd
12 cd /root/unnati/data1/myfold/
13 pwd
14 cd /tmp/unnati/
15 pwd
16 cd /mnt/fold/
17 pwd
18 cd
19 mkdir /camera /insta /facebook
20 mkdir /camera/gallery /insta/mypic /facebook/mypost
21 mkdir /camera/gallery/favourite /insta/mypic/reel /facebook/mypost/mypic
22 cd /camera/gallery/favourite/
23 pwd
24 cd /insta/mypic/reel/
25 pwd
26 cd /facebook/mypost/mypic/
27 pwd
28 cd
29 mkdir unnati/data1/myfold/post
30 cd unnati/data1/myfold/post/
31 mkdir redhat
32 ls
33 history
34 cd
35 mkdir /gdata/mydata /jdata/hfold
36 mkdir /gdata/mydata /jdata/hfold -p
37 cd /gdata/
38 ls
39 cd /jdata/hfold/

Date 26/4/2024
mkdir /test
2 cd /test/
3 touch file1.txt
4 ls
5 cd
6 mkdir /data
7 cd /test/
8 cp file1.txt /data
9 ls
10 cd /data/
11 ls
12 cd
13 cd /test/
14 touch file2.txt
15 cd
16 mkdir /redhat
17 cp /test/*.txt /redhat/
18 cd /redhat/
19 ls
20 cd
21 mkdir /test1
22 cd /test
23 cd /test1
24 touch file.txt
25 ls
26 mkdir /mydata
27 ls
28 cp file.txt /mydata/
29 ls /mydata/
30 ls
31 cp /test/* /mydata/
32 ls /mydata/
33 ls

Day 5: 27-4-2024
copy:
mkdir /test
2 cd /test/
3 touch file{1..6}.doc
4 mkdir /redhat
5 cp *.doc /redhat/
6 cd /redhat/
7 ls
mkdir /test
2 cd /test/
3 touch file{1..7}.xls
4 touch file{1..7}.doc
5 touch file{1..7}.txt
6 mkdir /redhat
7 cp -v * /redhat/
mkdir /linux
10 touch /linux/file{1..6}.txt
11 mkdir /redhat
12 mkdir /pdata
13 cd /
14 ls
15 cd linux/
16 ls
17 cd
19 pwd
20 cp -v /linux/* /pdata
mkdir /linux
23 cd /linux/
24 mkdir test{1..7}
25 ls
26 mkdir /unnati
27 cd
28 cp /linux/* /unnati/ -v
29 cd /unnati/
30 ls
31 cp -rvf /linux/* /pdata/
28-4-2024 sunday
Day 6
29-4-2024 monday
move : mv
2 pwd
3 mkdir test
4 ls
5 cd test/
6 touch file{1..6}.txt
7 ls
8 cd
9 mkdir /linux
10 cd /linux/
11 pwd
12 cd
13 cd test/
14 pwd
18 ls
19 cd test/
20 pwd
21 cd
22 mv -vf /root/test/f* /linux/
23 cd test/
24 ls
25 cd /linux/
26 ls
~
cd test/
20 pwd
21 cd
22 mv -vf /root/test/f* /linux/
23 cd test/
24 ls
25 cd /linux/
26 ls
27 history
28 history > list
29 ls
30 cd test/
31 ls
32 touch file{1..6}.doc
33 ls
34 cd
35 mkdir /mdata
36 mv -vf /root/test/f* /mdata/
37 ls
38 cd test/
39 ls
40 cd /mdata/
41 ls

cd test/
44 mkdir test1{1..7}
45 ls
46 mkdir /mnt/pdata
47 cd
48 mv -vf /root/test/t* /mnt/pdata/

mkdir test
2 ls
3 cd test/
4 cat > testfile
5 cat testfile
6 cd
7 mkdir /linux
8 cd test/
9 pwd
12 mv -vf /root/test/testfile /linux/linuxfile
13 ls
14 cd /linux/
15 ls
16 cat linuxfile

Task
1).Make dir name mydata under /opt & create myfiles 1 to 10 with xls extension in it
Under mydata also create testfile 1 to 10 with doc extension & jpg extension
Copy txt extension files in /lindata,copy xls extension files in /kubedata
Move jpg extension files in /mypod

2) /data/redhat test.html 10 txt 10 xls 10 pdf 10


myfile.html 10 txt 10 xls 10 pdf 10
file.html 10 txt 10 xls 10 pdf 10
/pdata/mydata1/test1 html
/pdata/mydata2/test2 txt xls
/fdata/mydata3/test3 all
/fdata/mydata4/test4 redhat

=======================================================

Day 7 1&2-5-2024
Wed
Vi editor
# Vi <filename>
Insert mode: press i
Command mode : yl - copy a letter
yw - copy a word
yy -copy one line
2yy -copy 2 lines

cl -cut a letter
cw -cut a word
cc -cut one line
dl -delete a letter
dw -delete a word
dd -delete one line
2dd -delete two lines
y{ -copy paragraph above
y} -copy paragraph below
c{ -cut above paragraph
c} -cut below paragraph

Press p for paste

To enter in to command mode from insert mode press esc


Save and quit command
:w save
:q quit
:wq save and quit
:wq! Save and quit forcefully

Find a word -
/word to be searched

Find and replace string

:s/word to be search/word to be replace search a word and replace one time in one line
:s/search word/replace word /g search a word and replace no. of occurrences
in one line

:%s/search word/replace/g search and replace all occurrences from all lines in
whole file
A - end of line with insert mode
I - start of the line with insert mode
$- end of line without insert mode
^ - start of the line without insert mode
L - moving on letters forward direction
H-moving on letters in backward direction
J - jump one line downward
K - jump one line upward
w=jump on next words
b=jump on previous words
Ctrl +r =redoo or :redo
U = undo
o=space after the line
O =space before the line

===============================
Day 8
3-5-2024
Less,more,head,tail
ls
2 vi anaconda-ks.cfg
3 cp anaconda-ks.cfg test
4 vi test
6 less test
9 more test
16 head test
17 man head
18 head -n 2 test
19 head --lines=2 test
~
head -n 23 /etc/passwd
27 cat -n /etc/passwd
28 cat /etc/passwd | head -n 2
29 head /etc/passwd
30 head /etc/passwd | wc -l
31 wc /etc/passwd
32 clear
33 wc /etc/passwd
head /etc/passwd | wc
36 head /etc/passwd | wc -l
37 head /etc/passwd | wc -c
38 head /etc/passwd | wc -w
39 head /etc/passwd
40 head /etc/passwd > file1.txt
41 ls
42 cat file1.txt
43 vi file1.txt
mkdir /mydata
47 head /etc/passwd > /mydata/file1.txt
48 vi /mydata/file1.txt
49 cd /mydata/
50 ls
51 cat file1.txt
Tail
tail /etc/passwd
2 tail -n 2 /etc/passwd
3 tail -n 20/etc/passwd
4 tail -n 20 /etc/passwd
5 tail -n 15 /etc/passwd > /mydata/datafile
6 mkdir /mydata
7 tail -n 15 /etc/passwd > /mydata/datafile
8 vi /mydata/datafile
9 tail -n 5 /etc/passwd | wc -l
10 tail -n 5 /etc/passwd | wc -c
11 tail -n 5 /etc/passwd | wc -w
15 tail -f /var/log/messages `21`
16 man tail
17 lsmem

Task
1) Print middle 10 lines of /etc/passwd
2) Print how many number of characters in /etc/group file
3) Print how many lines in anaconda-ks.cfg file
4) Print middle 15 lines of anaconda-ks.cfg file
5) Print last 5 lines of /var/log/messeges
============================================================
Grep:
grep root /etc/passwd
15 man grep
16 ls
17 grep 'root' /etc/passwd
18 grep 'sbin' /etc/passwd
19 clear
20 grep 'root' /etc/passwd
21 grep 'bin' /etc/passwd
22 clear
23 vi /etc/passwd
24 grep '990' /etc/passwd
vi /etc/passwd
6 grep sbin /etc/passwd
7 grep -o sbin /etc/passwd
8 grep -o sbin /etc/passwd | wc -l
9 grep -o sbin /etc/passwd | wc -c
10 grep sbin /etc/passwd | wc -l
11 grep sbin /etc/passwd | wc -w
12 grep -o sbin /etc/passwd | wc -w
13 grep -o sbin /etc/passwd | wc -c
14 grep sbin /etc/passwd | wc -c
grep 'network' anaconda-ks.cfg
3 grep -o anaconda-ks.cfg
4 grep -o 'network' anaconda-ks.cfg
5 vi anaconda-ks.cfg
6 grep -i 'network' anaconda-ks.cfg
7 grep 'Network' anaconda-ks.cfg
8 man grep
9 grep '#' anaconda-ks.cfg
10 vi anaconda-ks.cfg
11 grep -v '#' anaconda-ks.cfg
12 grep -v '#' anaconda-ks.cfg > list
13 vi list
vi words
20 grep ^z /usr/share/dict/words
21 grep ^zoo /usr/share/dict/words
22 grep -o ^zoo /usr/share/dict/words
23 grep -io ^zoo /usr/share/dict/words
24 grep -io ^ich /usr/share/dict/words
25 grep -i ^ich /usr/share/dict/words
26 grep -i ich$ /usr/share/dict/words
27 grep ool words
28 grep -i 'rohan bairagi' /opt/mydata

Task :
1. How to find root & network word from anaconda-ks.cfg in single command?
2. Find system word with both capital & lower case & copy them in /mnt/testfile?
3. Find only word starts with zoo & copy them in /tmp/linuxfile?
4. Find lines that does not contain word root & copy them in /kdata/mytest_file?
5. Find lines having id 990 from file /etc/passwd & copy them in /pmdata/pm_file?

Day 9
7-5-2024
Cut
vi /etc/passwd
2 cut -d ':' -f 1 /etc/passwd
3 cut -d ':' -f 2 /etc/passwd
4 cut -d ':' -f 5 /etc/passwd
5 cut -d ':' -f 5,7 /etc/passwd
6 cut -d ':' -f 5-7 /etc/passwd
7 cut -d ':' -f 1-4 /etc/passwd
8 wq
9 vi test.txt
10 cut -d ";" -f 1 test.txt
11 cut -d ";" -f 1,3 test.txt
12 cut -d ";" -f 1,3 test.txt > test1.txt
13 vi test1.txt
14 cut -d "?" -f 1,3 test.txt > test1.txt
15 vi test1.txt
16 cut -d ";" -f 1,3 test.txt > test1.txt
17 cut -d ";" -f 1-3 test.txt
18 cut -c 4 test.txt
19 cut -c 1-4 test.txt
20 cut -c 1-10 test.txt
21 cut -c 3-6 test.txt
22 vi test.txt
23 cut -c -15 test.txt
24 cut -c ,15 test.txt
29 cut -d ";" -f 1 test.txt | sort
30 cut -d ";" -f 3 test.txt | sort
31 cut -d ";" -f 2 test.txt | sort
34 cut -d ":" -f 1 /etc/passwd | sort
35 cut -d ":" -f 3 /etc/passwd
36 cut -d ":" -f 3 /etc/passwd |sort
37 cut -d ":" -f 3 /etc/passwd |sort -n
38 cut -d ":" -f 1-3 /etc/passwd |sort
39 cut -d ":" -f 1-3 /etc/passwd |sort -n
49 cut -d ":" -f 1-3 /etc/passwd |sort -t ':' -k3 -n
50 cut -d ":" -f 1-3 /etc/passwd |sort -t ':' -k3 -n -r
free -m | cut -c 1-20
2 free -m | cut -c 1-20 | grep -i mem
free -m | cut -c 1-20 | grep -i mem > test2.txt
Lscpu
Cat /etc/os-release

Awk
Date 8-5-2024
vi /test.txt

name;address;course;fees
rachana;n-7;rhcsa;10000
madhuri;n-5;rhcsa;16800
rina;n-3;rhcsa;20000

3 awk '{print }' /test.txt


9 awk -F ';' '{print $1}' /test.txt
10 awk -F ';' '{print $1 $2}' /test.txt
11 awk -F ';' '{print $1 " " $2}' /test.txt
12 awk -F ';' '{print "my name is" $1 "& myaddress is " $2}' /test.txt
awk 'NR==3, NR==6 {print NR,$0}' /test.txt.txt

13 awk -F ';' '{print "my name is" $1 " " "& myaddress is " $2}' /test.txt
14 awk -F ';' '{print "my name is " $1 " " "& myaddress is " $2}' /test.txt
15 vi mytext
NR==2{print "my name is " $1 " " "& myaddress is " $2}

16 awk -F ';' -f mytext /test.txt


18 vi mytext
23 awk -F ';' -f mytext /test.txt
25 awk -F ';' '{print $3,$NF}' /test.txt
26 awk -F ';' 'NR==2,NR==4 {print $3,$NF}' /test.txt
27 awk -F ';' 'NR==2 || NR==4 {print $3,$NF}' /test.txt
28 awk -F ';' 'NR==1 || NR==2 {print $3,$NF}' /test.txt
29 awk -F ';' 'NR==1 || NR==2 {print $1,$NF}' /test.txt
vi test.txt
2 awk '{print}' test.txt
3 awk -F ';' '{print $3}' test.txt
4 awk -F ';' '/rhcsa/{print}' test.txt
5 awk -F ';' '/rachana/ {print}' test.txt
6 awk -F ';' '/rachana/ {print $4}' test.txt
7 awk -F ';' '/rachana/ {print $0}' test.txt
8 awk -F ';' '/rachana/ {print $1 $4}' test.txt
9 awk -F ';' '/rachana/ {print $1" " $4}' test.txt
10 awk -F ';' '/rachana/ {print NR $1" " $4}' test.txt
11 awk -F ';' '/rachana/ {print NR " " $1" " $4}' test.txt
12 awk -F ';' 'NR==3 {print NR " " $1" " $4}' test.txt
13 awk -F ';' 'NR==3 || NR==1 {print NR " " $1" " $4}' test.txt
14 awk -F ';' 'NR==3 || NR==1 {print NR " " $1" " $NF}' test.txt
15 #awk -F ';' -f myfile.doc test.txt
16 vi myfile.doc
awk -F ':' -f myfile.doc /etc/group

Sed 9-5-2024
vi /test.txt
name;address;course;fees
rachana;n-7;rhcsa;10000
madhuri;n-5;rhcsa;16800
rina;n-3;rhcsa;20000

32 vi mytext
33 sed 's/rachana/vru/' /test.txt
34 sed 's/rhcsa/vru/3' /test.txt
40 sed '3s/rhcsa/vru/' /test.txt
41 sed '3s/rhcsa/vru/g' /test.txt
43 sed '3s/rhcsa/vru/p' /test.txt
44 sed -n '3s/rhcsa/vru/p' /test.txt
45 sed -n '1,3s/rhcsa/vru/p' /test.txt
46 sed -n '2,$s/rhcsa/vru/p' /test.txt
47 sed -n '2,$s/rhcsa/vru/d' /test.txt
49 sed '2d' /test.txt
50 sed '3d' /test.txt
54 sed '/rhcsa/d' /test.txt
55 sed '/fees/d' /test.txt

Date 15-5-2024
User management
Useradd shyam
Passwd shyam
Set password for user
Vi /etc/passwd
shyam:x:1001:1001::/home/shyam:/bin/bash
1 2 3 4 5 6 7
1=username
2=password mask
3= user id
4=groupid
5=GECOS name
6=home directory
7=shell
Su - shyam
Pwd
Hostname
Whoami
Mkdir test
Touch test1
Exit
Useradd mahi
Passwd mahi
(Enter password)
Su - shyam
Su - mahi
Ask for password
Pwd
Whoami
Exit
Exit

Adduser on ubuntu machine


useradd shyam
4 passwd shyam
5 su - shyam
6 adduser shyam
7 adduser shyam1
8 su - shyam1

RHEL
useradd hari
2 passwd hari
3 tail -n 2 /etc/passwd
4 usermod -l developer hari
5 tail -n 2 /etc/passwd
6 su - hari
7 su - developer
8 useradd jay
9 passwd jay
10 su - jay
11 vi /etc/passwd
12 su - hari
13 su - developer
14 vi /etc/passwd
15 su - developer
16 vi /etc/passwd
17 passwd jay
18 tail /etc/passwd
19 usermod -u 2001 developer
20 tail /etc/passwd -n 2
21 su - developer
22 id jay
23 id developer
24 tail /etc/group
25 groupadd rhcsa7pm
26 tail /etc/group
27 usermod -g 1013 developer
28 tail -n 2 /etc/group
29 tail -n 3 /etc/group
30 tail -n 3 /etc/passwd
31 id jay
32 id developer

Useradd jay
Passwd jay
Mkdir /mydata
Usermod -d /mydata jay
Su - jay
Pwd
Mkdir test12
Error will show no perm

If dir is new & user also new


Useradd -d /unnati unnatiuser
Su - unnatiuser
Mkdir unnatidocs
Dir will create full perm is there

Usermod -s /sbin/nologin user1


Usermod -L user1
Vi /etc/shadow
Usermod -U user1
Passwd -l user1
Vi /etc/shadow

Tasks Que
1 create a user neha login name will be dataoperator password should be neha@1234 uid will be
3001 groupid will belongs from
dataoperator group home directory will shift to /dataibm

2 create a user nita login name will be programmer password should be programmer@985 uid will be
4002 groupid will belongs
from program_gp & home directory should be /prodata

3 create a user shyam login name will be projectanalyser password should be project$1234 uid will be
5034 groupid will belongs
from 'project gp' & home directory should be /analyserdata

4 create a directory /unnati by which all future users when create there home directory should create
under /unnati location

Date 21-5-2024
Useradd to group
vi /etc/login.defs
9 less /etc/login.defs
10 less /etc/profile
11 less /etc/bashrc
12 useradd jay
13 useradd viru
14 passwd jay
15 passwd viru
16 su - jay
17 groupadd admin
18 tail /etc/group | grep admin
19 usermod -G admin jay
20 usermod -G admin viru
21 usermod -G admin jay
22 tail /etc/group | grep admin
23 groupadd sales
24 tail /etc/group | grep sales
25 usermod -G sales jay
26 tail /etc/group | grep sales
27 tail /etc/group | grep admin
28 usermod -aG admin jay
29 tail /etc/group | grep sales
30 tail /etc/group | grep admin
31* useradd mahi ; useradd k
32 groupadd ibm
33 usermod -aG ibm viru
34 tail /etc/group | grep ibm
35 tail /etc/group | grep sales
36 tail /etc/group | grep admin
37 #groupamod -g 2001 sales
38 #groupmod -g 2001 sales
39 tail /etc/group | grep sales
40 groupmod -g 2001 sales
41 tail /etc/group | grep sales

Date 23-4-2024

mkdir /unnati
2 ls -ld /unnati/
3 useradd mahi
4 useradd gita
5 useradd sita
6 su - mahi
7 chmod o+w /unnati/
8 su - mahi
pwd
2 mkdir test
3 cd /unnati/
4 ls
5 touch file
6 exit
7 cd /unnati/
8 touch file
9 ll
10 exit
11 cd /unnati/
12 exit
13 ls /unnati/
14 exit
15 ls /unnati/
16 ls -l /unnati/
17 exit
9 su - gita
cd /unnati/
2 ls
3 touch file2
4 ll
5 exit
6 cd /unnati/
7 exit
10 su - sita
11 ls -ld /unnati/
12 chmod o-x /unnati/
13 su - mahi
14 su - gita
15 su - sita
cd /unnati/
2 touch file2
3 touch file3
4 ll
5 exit
6 cd /unnati/
7 exit
16 chmod o-r /unnati/
17 su - mahi
18 chmod o+r /unnati/
19 su - mahi
Date 24 -5-2024
mkdir /unnati
2 mkdir /project
3 mkdir /ibm
4 mkdir /data
5 useradd ganesh
6 useradd sita
7 useradd gita
8 ls -l /unnati/
9 ls -ld /unnati/
10 ls -ld /project/
11 ls -ld /ibm
12 ls -ld /data/
13 mkdir test
14 ls
15 cd test/
16 pwd
17 cd /unnati/
18 pwd
19 cd /ibm
20 pw
21 pwd
22 su - sita
23 su - ganesh
24 cd
25 ls -l
26 ls -l /
27 chmod o+w /unnati/
28 chmod o-x /ibm
29 chmod o-r /project
30 su - sita
31 ls -l /unnati/
32 ls -l /unnati
33 ls -ld /unnati
34 chmod o=r /unnati/
35 ls -ld /unnati
chmod o=rwx /unnati/
38 chmod o=rwx /ibm
39 su - sita
40 su - ganesh
41 su - sita
su - sita
cd /root/test
2 cd /home/ganesh
3 cd /home/
4 cd ganesh/
5 cd /unnati/
6 ls
7 touch file
8 cd /ibm/
9 ls
10 touch file
11 cd /project
12 ls
13 touch file
14 exit
15 cd /project
16 ls
17 touch file
18 ls -ld /project
19 cd /ibm/
20 ls -ld /ibm/
21 ls /ibm/
22 ls -l /ibm/
23 cd /unnati/
24 ls
25 touch file
26 ls -l
27 exit
28 cd /unnati/
29 touch file123
30 ls
31 ll
32 exit
33 cd /unnati/
34 ll
35 vi redhat
36 ll
37 cat redhat

Date 27-5-2024
mkdir /test
2 ls
3 ls -d /test/
4 ls -dl /test/
5 groupadd project
6 useradd haresh
7 useradd poonam
8 useradd rachan
9 useradd rachana
10 chmod o-x /test
11 ls -dl /test/
12 su - rachana
13 su - poonam
14 chgrp project /test
15 ls -dl /test/
16 su - poonam
17 usermod -G project poonam
18 usermod -G project rachan
19 usermod -G project haresh
20 tail -n 2 /etc/group
21 cat /etc/group | grep project
22 ls -dl /test/
23 touch /test/file
24 su - poonam
25 su - rachan
26 groupadd MIT
27 useradd HOD
28 useradd professor
29 useradd lab_technician
30 usermod -G MIT HOD
31 usermod -G MIT professor
32 usermod -G MIT lab_techician
33 useradd lab_technician
34 usermod -G MIT lab_techician
35 usermod -G MIT lab_technician
36 mkdir /MIT
37 ls -ld /MIT/
38 chgrp MIT /MIT/
39 ls -ld /MIT/
40 cat /etc/group | grep MIT
41 chmod g+w /MIT/
42 cat /etc/group | grep MIT
43 ls -ld /MIT/
44 su - lab_technician
45 su - HOD
echo "redhat" | passwd --stdin HOD
echo "redhat" | passwd --stdin lab_technician
echo "redhat" | passwd --stdin professor

28-5-2024
Groupadd & give perm to members
mkdir /unnati
2 useradd ashutosh
3 useradd rachana
4 useradd pawan
5 useradd ankush
6 groupadd unnati
7 ls -ld /unnati/
8 chgrp unnati /unnati/
9 ls -ld /unnati/
10 chmod g+w /unnati/
11 ls -ld /unnati/
12 cat /etc/group | grep unnati
13 usermod -G unnati ashutosh
14 usermod -G unnati rachana
15 usermod -G unnati ankush
16 usermod -G unnati pawan
17 cat /etc/group | grep unnati
18 su - ashutosh
19 echo "redhat" | passwd --stdin ashutosh
20 echo "redhat" | passwd --stdin ankush
21 echo "redhat" | passwd --stdin pawan
22 echo "redhat" | passwd --stdin rachana
23 su - ashutosh
24 passwd root
25 chmod g-x /unnati/
26 ls -ld /unnati/
27 passwd root
28 redhat
userdel pawan
31 tail /etc/passwd
32 cd /home/
33 ll
34 useradd harsh
35 ll
36 rm pawan
37 rm -rvf /pawan
38 ll
39 rm -rvf /pawan/*
40 ll
41 rmdir pawan
42 rm -rvf pawan
43 ll
44 userdel -r ankush
45 ll

30-5-2024
Owner perm
mkdir /project
2 ls -ld /project
3 useradd ashutosh
4 useradd rachana
5 useradd ankush
6 useradd pawan
7 useradd student
8 echo "redhat" |passwd --stdin rachana
9 echo "redhat" |passwd --stdin pawan
10 echo "redhat" |passwd --stdin ashutosh
11 echo "redhat" |passwd --stdin student
12 echo "redhat" |passwd --stdin ankush
13 ls -ld /project
14* groupadd projec
15 usermod -G project ankush
16 usermod -G project pawan
17 usermod -G project rachana
18 chgrp project /project
19 ls -ld /project
20 chown ashutosh /project
21 ls -ld /project
22 chmod u=wx /project/
23 ls -ld /project
24 su - ashutosh
25 chmod u+r /project
26 chmod g-r /project
27chmod o-rx /project 28 ls -ld /project
29 su - ashutosh
cd /project
2 touch file
3 ls
4 su - ankush
5 exit
6 cd /project
7 touch file4
8 su ankush
cd /projecttouch file3
ls
touch file4
touch file6
ls
su - rachana
cd /project/
ls
touch fi;lt6
su - pawan
cd /project
ls
touch fdj
su - student
cd /project

1-6-2024
Useradd hari
Useradd gopi
Mkdir /testunnati
Chmod o+rwx /testunnati
Su - hari
Cd /testunnati
Touch file123
ll
Exit
Su - gopi
Cd /testunnati
Rm file123
Ls
Exit
Chmod o+t /testunnati
Su - hari
Touch file1234
Exit
Su - gopi
Cd /testunnati
Rm file1234
Not removed
Exit

2-6-2024
Chmod g+s
useradd hari
16 useradd datta
17 groupadd saless
18 usermod -G sales hari
19 usermod -G saless hari
20 usermod -G saless datta
21 mkdir /unnati
22 ls -ld /unnati/
23 chgrp saless /unnati/
24 ls -ld /unnati/
25 chmod g+w /unnati/
26 ls -ld /unnati/
27 su - hari
cd /unnati/
2 touch file
3 ll
4 exit
28 su - datta
cd /unnati/
2 ll
3 vi file
4 exit
29 history
30 chmod g+w /unnati/file
31 ls -ld /unnati/file
32 chmod g+s /unnati/
33 ls -ld /unnati/file
34 su - hari
cd /unnati/
6 touch test
7 ll
8 mkdir test1
9 ll
10 chmod g+w test
11 ll
12 exit
35 su - datta
cd /unnati/
6 ll
7 vi test
8 ll
9 exit
10 cd /redhat/
11 ll
12 touch myfile
13 ll
14 exit
36 history
37 mkdir /redhat
38 useradd neha
39 useradd ganesh
40 groupadd admin
41 usermod -G admin neha
42 usermod -G admin ganesh
43 ls -ld /redhat
44 chmod o+w /redhat/
45 chmod g+s /redhat/
46 ls -ld /redhat
47 chgrp admin /redaht
48 chgrp admin /redhat
49 ls -ld /redhat
50 chmod g+w /redhat/
51 #chmod -R g+w /redhat/
52 su - neha
53 su - ganesh
54 chmod -R g+w /redhat/
55 ls -ld /redhat
56 ls -l /redhat
57 su - neha

Date 5-6-2024
Mkdir /redhat
Useradd user1
Passwd user1
Chown user1 /redhat
Chmod u+s /redhat
Su - user1
Touch file1
Exit

Useradd jaya
Useradd gopi
Useradd neha
Useradd nisha
Mkdir /mydata
Groupadd admin
Usermod -G admin gopi
Usermod -G admin neha
Chown jaya /mydata
Chgrp admin /mydata
Chmod 571 /mydata
Chmod 771 /mydata

Chmod 4117 /mydata


Chmod 2771 /mydata
Chmod 4000 /mydata
Chmod 2000 /mydata
Chmod 1000 /mydata
Chmod 7517 /mydata
Task :

1 create a dir name /unnati/kendata owner can read the data,access the
data,& write into it all users can
not remove or make changes into the location
note: password for all users will be mydata@123
owner berry
group disney tom,jerry --x
other farah --x

2 create a dir /redbus owner george_kent will only read the data from the location,
group will be redbus having members joy & robert having read,write
execute perm to the directory other can only execute the location
remember if members create any file the other member can edit the file
from same path.
password for owner will be redbus@88
group member will having password as joy@robert@123

3 create a dir /setsebool having owner as romie who will having full access
of the directory & only he can execute the file under this path no one can
not execute the file from this location nor remove the content of this path
group will be root having default permissionother will also having default
permission.
password of owner will be romie@987

Soft link
mkdir /data/data1/data2
2 mkdir /data/data1/data2 -p
3 cd /data/data1/data2/
4 touch file123
5 cat > file123
6 ls
7 cd
8 pwd
9 ls
10 ln -s /data/data1/data2/file123 testfile
11 ls -l
12 ls -lh
13 cat testfile
14 cat >> testfile
15 cat testfile
16 cat /data/data1/data2/file123
17 cat >> /data/data1/data2/file123
18 cat /data/data1/data2/file123
19 cat testfile
ls -l
22 cat testfile
23 cat /data/data1/data2/file123
24 rm testfile
25 ls
26 ll
27 cat /data/data1/data2/file123
28 ln -s /data/data1/data2/file123 myfile
29 ll
30 cat myfile
rm /data/data1/data2/file123
33 ll
34 cat myfile
touch /data/data1/data2/file123
37 ln -s /data/data1/data2/file123 testfile
38 ll
39 cat myfile
40 ln -s /data/data1/data2/file123 /tmp/mytest
41 ll
42 cd /tmp/
43 ll

Date 12-6-2024
cd /
2 ls -l
3 cd /usr/
4 ll
5 cd
6 mkdir /data/data1/data2/data3
7 mkdir /data/data1/data2/data3 -p
8 ln -s /data/data1/data2/data3/ mydata
9 ll
10 cd mydata/
11 touch file{1..10}.txt
12 touch file{1..10}.doc
13 ls
14 cd /data/data1/data2/data3/file
15 cd /data/data1/data2/data3/
16 ls
17 mkdir mydata{1..10}
18 ls
19 cd
20 cd mydata/
21 ls
22 cd
23 ls -l
24 rm mydata/
25 rm mydata/*
26 ls
27 cd mydata/
28 ls
29 rm -rvf *
30 ls
31 cd
32 rm mydata/
33 rmdir mydata/
34 rmdir mydata
35 rm -rvf mydata
36 ll
37 cd /data/data1/data2/data3/
38 ls
39 touch file{1..10}.txt
40 ls
41 cd
42 ln -s /data/data1/data2/data3/ mydata
43 ll
44 ls mydata/
45 rm -rvf /data/data1/data2/data3/
46 cd /data/data1/data2
47 ls
48 cd
49 ls
50 ll
51 cd mydata
52 mkdir /data/data1/data2/data3
53 ll
54 ls -inum mydata/
55 ls -inum -d mydata/
56 ls -inum -d /data/data1/data2/data3/
57 touch file123
58 ln -s file123 myfile
59 ll -inum
60 ls -l -inum
61 ll
62 ls -i -inum /bin
63 ls -d -inum /bin
64 ls -d -inum /usr/bin
65 ls -l /
66 ls -d -inum /lib
67 ls -d -inum /usr/lib
68 ls -d -inum /lib64
69 ls -d -inum /usr/lib64
70 ls -d -inum /sbin
71 ls -d -inum /usr/sbin
72 ls -ld -inum /usr/sbin
73 ls -l -inum /usr/sbin
74 history
75 ls -l
Hard link
76 touch myfile123
77 ln myfile123 hfile
78 ll
79 cat > myfile123
80 cat hfile
81 ll
82 ln myfile123 gfile
83 ll
84 ls -l
85 ls -inum
touch file123
2 ln hardlink file123
3 ln file123 myfile
4 ll
5 ln file123 /tmp/jfile
6 ln file123 /mnt/hfile
7 ls /tmp/
8 ls /tmp/ -l
9 ls /mnt/ -l
10 ls -inum -d file123
11 ls -l
12 ls -num
13 ls -inum
14 cat > file123
15 cat myfile
16 cat /tmp/jfile
17 cat /mnt/hfilefile
18 cat /mnt/hfile
19 ls -inum file123
20 find / -inum 36195
21 cat /mnt/hfile
22 rm file123
23 ls -l
24 cat myfile
25 rm myfile
26 ls -l
27 cat /tmp/jfile
root@rhel:~# history
1 touch file123
2 ln hardlink file123
3 ln file123 myfile
4 ll
5 ln file123 /tmp/jfile
6 ln file123 /mnt/hfile
7 ls /tmp/
8 ls /tmp/ -l
9 ls /mnt/ -l
10 ls -inum -d file123
11 ls -l
12 ls -num
13 ls -inum
14 cat > file123
15 cat myfile
16 cat /tmp/jfile
17 cat /mnt/hfilefile
18 cat /mnt/hfile
19 ls -inum file123
20 find / -inum 36195
21 cat /mnt/hfile
22 rm file123
23 ls -l
24 cat myfile
25 rm myfile
26 ls -l
27 cat /tmp/jfile
28 cat /mnt/hfile
29 mkdir /testdir
30 ln /testdir/ mydata
31 history
32 mkdir /data/unnati/redhat
33 mkdir /data/unnati/redhat -p
34 touch /data/unnati/redhat/myfile123
35 ln /data/unnati/redhat/myfile123 yfile
36 ll
37* ls -inum yfil
38 find / -inum 34773815
39 history
40 ls -l yfile
41 ls -l /data/unnati/redhat/myfile123
42 uptime
43 cat /data/unnati/redhat/myfile123
44 ls -ld /data/unnati/redhat/myfile123
45 cat > /data/unnati/redhat/myfile123
46 ls -ld /data/unnati/redhat/myfile123
47 ls -l yfile -d
At
date
4 uptime
5 at now+1min
6 atd
7 atq
8 uptime
9 ls
10 at now+1hour
11 uptime
12 atq
13 atrm 2
14 atq
15 which touch
rpm -qi at
2 rpm -qi tree
3 cat /etc/os-release
4 yum install at
5 systemctl start atd
6 systemctl enable atd
7 at now+2min
8 uptime
9 watch cat file1.txt
10 at now+2min
11 watch ls
12 at 4pm
13 uptime
14 at 11am
15 at 11am+today
16 at 11am + today
17 at today 11am
18 at today + 11am
19 at today 7pm
20 at today +7pm
21 man at
22 at 11am today
23 at 7pm today
24 atq
25 atrm 3
26 atrm 4
27 atrm 5
28 atq
29 at now+2min
30 uptime
31 cd /var/log/
32 ls
33 at now+2min
34 tail -f messages
35 cd
36 logger hello
37 tail /var/log/messages
38 cat /var/log/messages | grep hello
39 at 1pm
40 at tomorrow
41 uptime
42 at tomorrow 1pm
43 at 1pm tomorrow
44 at 31 jan
45 at 8pm 31 jan
46 atq
47 man at
48 at 31 may 2025
49 at 4pm 31 may 2025
50 at midnight
51 at noon
52 at teatime
53 at now+3min
54 uptime
55 watch cat /etc/passwd
56 at now+3min
57 uptime
58 watch cat /etc/shadow
Crontab
Date 17-6-2024
dnf install crontabs -y
3 systemctl status crond
4 systemctl enable crond
5 crontab -e
6 cat /etc/crontab
7 crontab -e
00 2 * * * /usr/bin/touch file123
8 uptime
9 date
10 uptime
11 crontab -e
04 14 17 jun mon /usr/bin/echo “hello” > file123
12 ls
13 crontab -e
*/1 14 17 jun mon /usr/bin/echo “ hello” >> file123
14 uptime
15 watch ls
16 crontab -l
*/2 14 18 6 tue /usr/sbin/useradd pankaj
*/3 14 18 jun 2 /usr/bin/echo "redhat" | passwd --stdin pankaj
20 14 18 6 2 /usr/bin/dnf install at -y
5-10 1,4 1-7 1-6 1,7 /usr/bin/systemctl restart atd
Crontab -e
For rucha & vasudha

at now+1min
warning: commands will be executed using /bin/sh
at> echo "happy birthday" >> file.txt
at> <EOT>
job 1 at Wed Jun 19 14:50:00 2024
root@rhel:~# ls
file.txt post-run.log rh-cloud.repo
google-cloud.repo post-run.log.done
root@rhel:~# cat file.txt
happy birthday
root@rhel:~# date
Wed Jun 19 02:51:46 PM UTC 2024
root@rhel:~# at 4pm
warning: commands will be executed using /bin/sh
at> touch file34
at> <EOT>job 2 at Wed Jun 19 16:00:00 2024
Cron.allow or cron.deny
cd
23 vi /etc/cron.deny
24 useradd yash
25 useradd pankaj
26 su - yash
27 su - hari
28 crontab -u yash -e
29 crontab -u hari -e
30 crontab -u pankaj -e
31 su - pankaj
32 vi /etc/cron.allow
33 su - pankaj
34 rm /etc/cron.deny
35 su - pankaj
36 rm /etc/cron.allow
37 su - pankaj
38 cd /etc/
39 ls cron*
40 vi cron.deny
41 su - pankaj

Date 25-6-2024
ls
2 cd /usr/
3 ls
4 cd
5 find / -name *.txt
6 vi /usr/share/cockpit/systemd/overview.js.LEGAL.txt
7 find / -name *.html
8 find / -name *.html > file.txt
9 vi file.txt
10 vi
/usr/lib64/google-cloud-sdk/lib/googlecloudsdk/core/credentials/oauth2_landing_error.html
11 history
12 find / -name ????
13 find / -name ????.txt
14 find / -name p*.txt
15 find / -name p*.*
16 find / -name 'p*.*'
17 find / -name 'p???.*'

Date 26-6-2024
Find again
find / -name passwd
2* vi /sys/fs/selinux/class/passwd
3 find / -name passwd > file.txt
4 vi file.txt
5 find / -name shadow
6 find / -perm 666
7 ls -ld /proc/1830/task/1830/attr/exec
8 find / -perm 666
9 find / -perm 666 | less
10 ls -ld /sys/fs/selinux/member
11 find / -name *.conf
12 find / -name *.conf -maxdepth 2
13 find / -name *.conf -maxdepth 3
14 history
15 find / -name *.conf -mindepth 2
16 mkdir /data
17 cd /data/
18 touch myfile{1..10}.txt
19 touch myfile{1..10}.html
20 mkdir /data1/data2/data3
21 mkdir /data1/data2/data3 -p
22 touch /data1/myfile{1..10}.conf
23 touch /data1/myfile{1..10}.txt
24 touch /data1/data2/myfile{1..10}.txt
25 touch /data1/data2/myfile{1..10}.doc
26 cd
27 find / -name ????
28 find / -name ?????
29 find / -name ????? -type f
30 find / -name ????? -type d
31 historyt
32 history
33 find / -name ????? -type f
34 ls -ld /usr/libexec/initscripts/legacy-actions/auditd/state
Userdata
useradd mahi
2 su - mahi
3 useradd mahi
4 useradd mahesh
5 su - mahesh
6 find / -user mahi
7 find / -user mahi -type d
8 find / -user mahi -type f
9 find / -user mahi -type f -perm 775
10 find / -user mahi -type f -perm 755
11 find / -user mahi -type d -perm 755
12 find / -user mahi -type d -perm 664
13 find / -user mahi -type f -perm 664
14 find / -user mahi -type f -perm 644
15 find / -user mahi -type f -perm 644 2> /dev/null

Date 27-6-2024
touch /tmp/myfile
16 ln ufile /tmp/myfile
17 ln /tmp/myfile ufile
18 ln /tmp/myfile /mnt/myfile123
19 ls -l
20 ll
21 cd /tmp/
22 ll
23 cd /m
24 cd /mnt/
25 ll
26 cd
27 ls -i
28 find / -inum 33575080
dd if=/etc/passwd of=redhat bs=1M count=50
2 ll
3 ll -h
4 ll -m
5 ll -M
6 du -h redhat
7 dd if=/dev/zero of=redhat1 bs=1M count=50
8 ll -h
9 dd if=/dev/zero of=redhat2 bs=1M count=80
10 ll -h
11 find / -size +49M -size -81
12 ll
13 find / -size +49M -size -80
14 find / -size +50M -size -80
15 find / -size +50M -size -80M
16 find / -size +49M -size -81M
17 find / -perm /4000
18 ls -l /usr/bin/chage
19 find / -perm -4000
20 find / -perm -2000
21 ll /run/log/journal
22 ll /run/log/journal -D
23 ll /run/log/journal -d
24 find / -perm -1000
25 ll -d /tmp/systemd-private-62aaea6577034dc6ba0d0bc04998ede5-dbus-broker.service-
dQeV5m/tmp

Date 28-6-2024
dd if=/etc/passwd of=test bs=1M count=30
2 ll -hd test
3 vi test
4 dd if=/dev/null of=test1 bs=1M count=50
5 ll -hd test1
6 dd if=/dev/zero of=test1 bs=1M count=50
7 ll -hd test1
8 dd if=/dev/zero of=test2 bs=1M count=80
9 find / -size +29M -size -51M
10 find / -size +49M -size -81M
11 find / -perm 4775
12 find / -perm 4777
13 find / -perm 4664
14 find / -perm 4644
15 find / -perm 775
16 find / -perm 775 > /data/file.txt
17 mkdir /data
18 find / -perm 775 > /data/file.txt
19 cd /data/
20 ls
21 cat file.txt
22 cd
23 cd /data/
24 ls
25 cd
26 find / -perm 775 -exec cp -rvf {} /data/ \;
27 cd /data/
28 ls
29 vi file.txt
30 cd /data/
31 ls
32 ll
33 cd /data/
34 ll
35 cd json/
36 ls
37 cd ..
38 cd /data/
39 ll
40 cd mail/
41 ls
42 ll
43 vi core
44 vi wkibbe
find / -name passwd
2 find / -name passwd > file.txt
3 vi file.txt
4 mkdir /redhat
5 find / -name shadow > /redhat/myfile.txt
6 cd /redhat/
7 ls
8 vi myfile.txt
9 cd
10 mkdir /test123
11 find / -size +30M
12 find / -size +30M > /test123/testfile
13 cd /test123/
14 ls
15 vi testfile
16 cd
17 find / -size +30M > /test123/testfile 2>/dev/null
18 find / -size +30M > /test123/testfile 0>/dev/null
19 find / -size +30M 1> /test123/myfile
20 find / -size +30M 1> /test123/myfile 2> /dev/null
find / -perm 555
23 find / -perm 555 > /tmp/udata
24 find / -perm /4000
25 ls -ld /usr/bin/umount
26 cd /tmp/
27 ls
28 ls -l
29 ls -lcd
30 find /usr -perm -2000
31 ls -ld /usr/libexec/utempter/utempter
32 find /usr -perm -1000
33 find / -perm -1000
34 find /tmp -perm -1000
35 find /tmp -perm -1000 -exec cp -rvf {} /redhat/ \;
36 cd /redhat/
37 ls
38 cd tmp/
find /tmp -perm -1000 -type d
42 find /var -perm -1000 -type d
43 find /var -perm -1000 -type f
44 find /var -perm -1000 -type d
45 find /var -perm -1000 -type d -maxdepth 2
46 find /var -perm -1000 -type d -maxdepth 1
47 find /var -perm -1000 -type d -maxdepth 3
48 find /var -perm -1000 -type d -maxdepth 3 -size 10M
49 find /var -perm -1000 -type d -maxdepth 3 -size 10G
50 find /var -perm -1000 -type d -maxdepth 3 -size -10G
51 find /var -perm -1000 -type d -maxdepth 3 -size -10M
52 find /var -perm -1000 -type d -maxdepth 3 -size -10M > file123
53 ls
54 vi file123
55 find /var -perm -1000 -type d -maxdepth 3 -size -10M -exec cp -rvf {} /mnt/ \;
56 cd /mnt/
57 ls
58 cd tmp/
59 ls

cat myfile.txt
/run/tpm2-tss/eventlog
/run/log/journal
/run/log/journal/0ba1be1199e74165a458a3bb0f65fb8f
/var/lib/tpm2-tss/system/keystore
/usr/bin/write
/usr/bin/locate
/usr/libexec/utempter/utempter
/usr/libexec/openssh/ssh-keysign
root@rhel:~# cat test.sh
(find / -perm /2000 -size -10G > myfile.txt)
Chmod o+x test.sh

Task :find
1) Create a path /tmp/mydata & copy the fstab file from system into given location.
2) Create a file mytest under /fdata dir & copy the names of all files having .txt extension
into the given path.
3) Find all html files from the /usr location & all file should cover 3rd location only & copy
the list into /mnt/myhtdata
4) Find conf files from /etc & copy the content to /ibm/hpv
5) Find the file having perm u+s from the system & copy the data into /kvm/kelvin
6) Find all files which are having size ranges between 10M to 20M & copy the data into
The /mdata/jenkins
7) Find all directory having perm g+s & copy the content into /bees/comp
8) Find all files which are having sticky bit perm & copy the list of data into
/opt/kinder
9)

ACL
Date 1-7-2024
mkdir /testdata
2 useradd mahi
3 useradd manisha
4 useradd mahesh
5 useradd natasha
6 useradd gita
7 ls -ld /testdata/
8 su - mahi
9 setfacl -m u:gita:--x /testdata
10 ls -ld /testdata/
11 getfacl /testdata/
12 setfacl -m u:manisha:-wx /testdata
13 getfacl /testdata/
14 setfacl -m u:mahi:rwx /testdata
15 getfacl /testdata/
16 setfacl -m u:natasha:--- /testdata
17 getfacl /testdata/
mkdir /testdata
2 useradd mahi
3 useradd manisha
4 useradd mahesh
5 useradd natasha
6 useradd gita
7 ls -ld /testdata/
8 su - mahi
9 setfacl -m u:gita:--x /testdata
10 ls -ld /testdata/
11 getfacl /testdata/
12 setfacl -m u:manisha:-wx /testdata
13 getfacl /testdata/
14 setfacl -m u:mahi:rwx /testdata
15 getfacl /testdata/
16 setfacl -m u:natasha:--- /testdata
17 getfacl /testdata/
18 history
19 getfacl /testdata/
20 su - mahi
21 su manisha
22 su - manisha
23 su manisha
24 ls -l /testdata/
25 cd /testdata/
26 su - manisha
27 su manisha
28 cd
29 groupadd umpire1
30 groupadd coach
31 setfacl -m g:umpire:rwx /testdata
32 setfacl -m g:umpire1:rwx /testdata
33 getfacl /testdata/
34 setfacl -m g:coach:rw- /testdata
35 getfacl /testdata/

To remove user from group


gpasswd -d hari admin

Date 2-7-2024
Setfacl
mkdir /test
2 useradd manish
3 useradd mani
4 groupadd admin
5 groupadd devops
6 groupadd devstorage
7 setfacl -m u:manish:rwx /test
8 setfacl -m u:mani:r-- /test
9 setfacl -m g:admin:rwx /test
10 setfacl -m g:admin:rw- /test
11 setfacl -m g:devstorage:rw- /test
12 setfacl -m g:devops:rw- /test
13 setfacl -m g:devops:-w- /test
14 getfacl /test
15 setfacl -m o::--x /test
16 mkdir /ibm
17 useradd jay
18 useradd jaya
19 useradd pramod
20 groupadd
21 groupadd ibm
22 ls -ld /ibm
23 chown jay /ibm
24 chgrp ibm /ibm
25 chmod 751 /ibm/
26 ls -ld /ibm
27 setfacl -m u:jaya:rwx /ibm
28 setfacl -m u:pramod:r-x /ibm
29 ls -ld /ibm/
30 getfacl /test/
31 getfacl /ibm

Tasks
1 create a dir /hpv create users myuser,developer,teja .
Myuser will read execute & write the data into the same location
Developer having limited perm like they can only execute the path
Teja user neither read,execute nor write the path.
Remember the owner & groupowner of the directory should be root only.
2 create a dir /sbi having user accounts ,sales_executive (rwx)
Deputy_manager who is the owner of dir with default permission
Security_guard will having –x perm , accountant will be the group owner of directory
Will having default permission remember all other can not remove or create or accessing the
path .
3 create dir /T-20 mahendra will user having rwx execute perm user viraj will only execute the
path mahesh will having rw- perm for same location,create a group coach from which user
mahendra & mahesh belongs group having rw- perm only othe user will having execute perm for
the same path owner & group owner will be root only.
==============================================================================

Date 3-7-2024
ACL how to add numeric perm & remove perm
useradd natasha
19 useradd saisha
20 groupadd sales
21 groupadd admin
22 mkdir /mytest
23 setfacl -m u:natasha:rwx /mytest
24 setfacl -m u:manisha:r-x /mytest
25 setfacl -m u:saisha:rw- /mytest
26 setfacl -m g:sales:rw- /mytest
27 setfacl -m g:admin:r-x /mytest
28 getfacl /mytest
29 setfacl -m x:natasha: /mytest/
30 setfacl -x u:natasha: /mytest/
31 getfacl /mytest/
32 setfacl -x g:sales: /mytest/
33 getfacl /mytest/
34 setfacl -b /mytest/
35 getfacl /mytest/
36 ls -ld /mytest/
37 setfacl -m u:natasha:7 /mytest
38 setfacl -m u:manisha:5 /mytest
39 setfacl -m u:saisha:6 /mytest
40 getfacl /mytest/
41 setfacl -m g:sales:6 /mytest
42 setfacl -m g:admin:5 /mytest
43 getfacl /mytest/
Tasks
Remove above all perm & restore all at one time
==========================
mkdir /mytest
2 useradd natasha
3 #setfacl -R -m u:natahsa:rwx /mytest
4 touch /mytest/myfile
5 ls -ld /mytest/
6 ls -ld /mytest/myfile
7 setfacl -R -m u:natahsa:rwx /mytest
8 setfacl -Rm u:natahsa:rwx /mytest
9 setfacl -m -R u:natahsa:rwx /mytest
10 setfacl -m u:natahsa:rwx /mytest -R
11 setfacl -Rm u:natasha:rwx /mytest
12 getfacl /mytest/
13 getfacl /mytest/myfile
14 getfacl -R /mytest > file
15 vi file
16 setfacl -Rb /mytest/
17 getfacl /mytest/*
18 getfacl /mytest
19 setfacl --restore=file
20 vi file
21 setfacl --restore=file
22 getfacl /mytest -R
Date : 6-7-2024
useradd hari
2 useradd mahi
3 mkdir /mydata/test
4 mkdir /mydata/test -p
5 getfacl /mydata/test/
6 setfacl -m u:hari:rwx /mydata/test/
7 setfacl -m u:mahi:1 /mydata/test/
8 getfacl /mydata/test/
9 setfacl -m m::--x /mydata/test/
10 getfacl /mydata/test/
11 su - hari
12 su - mahi
13 setfacl -x m::
14 setfacl -x m:: /mydata/test/
15 setfacl -x m::--x /mydata/test/
16 getfacl /mydata/test/
17 setfacl -m m::r-x /mydata/test/
18 getfacl /mydata/test/
19 su - hari
setfacl -m m::rwx /mydata/test/
root@rhel:~# getfacl /mydata/test/
getfacl: Removing leading '/' from absolute path names
# file: mydata/test/
# owner: root
# group: root
user::rwx
user:hari:rwx
user:mahi:--x
group::r-x
mask::rwx
Other::r-x

Date 9-7-2024
Hard disk Partitioning
lsblk
2 parted /dev/ |less
3 parted /dev/sda print free
4 parted /dev/sdb print free
5 truncate -s 10G /tmp/myfile
6 losetup /dev/loop1 /tmp/myfile
7 lsblk
8 parted /dev/loop1
9 lsblk
=============================

10-7-2024
truncate -s 10G /tmp/myfile
2 losetup /dev/loop1 /tmp/myfile
3 lsblk
4 parted /dev/loop1
5 lsblk
6 mkdir /redhat
7 mkfs.ext3 /dev/loop1p1
8 mount /dev/loop1p1 /redhat/
9 df -h
10 df -hT
11 mkfs.xfs /dev/loop1p2
12 mkdir /unnati
13 mount /dev/loop1p2 /unnati/
14 df -h
15 cd /unnati/
16 touch file{1..10}.txt
17 ls
18 cd
19 df -h

Date 18-7-2024
Swap partition
truncate -s 10G /tmp/myfile
2 losetup /dev/loop1 /tmp/myfile
3 lsblk
4 #parted /dev/loop1
5 free -m
6 parted /dev/loop1
7 partprobe /dev/loop1
8 mkswap /dev/loop1p1
9 blkid /dev/loop1
10 blkid /dev/loop1p1
11 blkid /dev/loop1p1 |cut -c 15-37
12 blkid /dev/loop1p1 |cut -c 15-52
13 blkid /dev/loop1p1 |cut -c 15-57
14 blkid /dev/loop1p1 |cut -c 15-57 >> /etc/fstab
15 vi /etc/fstab
UUID="7ee2577b-ab81-4ac9-acd5-6316f366f9d0" swap swap defaults 00
16 free -m
17 swapoff -a
18 swapon -a
19 swapoff -a
20 swapon -a
21 free -m
Storage link https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html/
managing_storage_devices/disk-partitions_managing-storage-devices#mbr-partition-types_disk-
partitions

======================
useradd jay
2 useradd nita
3 useradd nitesh
4 useradd jia
5 mkdir /testdata
6 ls -l /testdata/
7 ls -ld /testdata/
8 #setfacl -m
9 su - jay
10 su - nita
11 tail /etc/passwd
12 setfacl -m u:nita:rwx /testdata/
13 ls -ld /testdata/
14 getfacl /testdata/
15 su - nita
16 setfacl -m u:jay:r-- /testdata/
17 getfacl /testdata/
18 su - jay
19 setfacl -m u:nitesh:rw- /testdata/
20 getfacl /testdata/
21 su - nitesh
22 groupadd sales
23 setfacl -m g:sales:7 /testdata/
24 getfacl /testdata/
25 setfacl -m o::0 /testdata/
26 getfacl /testdata/
27 su - jaya
28 su - jia
Date 9-7-2024
parted /dev/sdb print free
23 parted /dev/sdc \print free
24 parted /dev/sdc
25 lsblk
26 #mkfs.ext4 /dev/sdc1
27 partprobe /dev/sdc
28 mkfs.ext4 /dev/sdc1
29 parted /dev/sdc print free
30 blkid /dev/sdc1
31 mkdir /data
32 mount /dev/sdc1 /data/
33 df -hT
34 cd /data/
35 touch file{1..10}.txt
36 ls
37 cd
38 lsblk
39 parted /dev/sdb
40 partprobe /dev/sdb
41 mkfs.ext4 /dev/sdb1
42 #mkfs.ext4 /dev/sdb5
43 lsblk
44 mkfs.ext4 /dev/sdb5
45 lsblk
46 parted /dev/sdb print free
47 blkid
48 blkid /dev/sdb1
49 blkid /dev/sdb5
50 mkdir /test1
51 mkdir /test5
52 vi /etc/fstab
53 man fstab
54 lsblk
55 mount -a
56 df -h
57 cd /test
58 cd /test1
59 touch file{1..10}.txt
60 ls
61 cd
62 history
63 lsblk
64 parted /dev/sdb
65 mkfs.xfs /dev/sdb6
66 mkfs.xfs /dev/sdb7
67 blkid /dev/sdb5
68 parted /dev/sdb print free
69 mkdir /redhat
70 mkdir /hdata
71 vi /etc/fstab
72 mount -a
73 df -h
74 df -hT
75 umount /dev/sdb6
76 df -hT
77 parted /dev/sdb
78 reboot
79 vi /etc/fstab
80 reboot
81 history
82 free -m
83 lsblk
84 free -h
85 parted /dev/sdb
86 partprobe /dev/sdb
87 mkswap /dev/sdb7
88 vi /etc/fstab
89 free -m
90 swapoff -a
91 free -m
92 swapon -a
93 free -m
94 df -h
95 history
96 free -m
97 parted /dev/sdb
98 mkswap /dev/sdb8
99 vi /etc/fstab
100 free -m
101 swapoff -a
102 free -m
103 swapon -a
104 free -m
105 parted /dev/sdb
106 lsblk
107 vi /etc/fstab
108 umount -a
109 df -h
110 parted /dev/sdb
111 partprobe /dev/sdb
112 udevadm /dev/sdb
113 mkfs.ext3 /dev/sdb1
114 mount /dev/sdb1 /redhat/
115 df -h
116 cd /redhat/
117 ls
118 touch file{1..10}.txt
119 ls
120 cd
121 umount /dev/sdb1
122 cd /redhat/
123 ls
124 cd
125 mount /dev/sdb1 /redhat/
126 cd /redhat/
127 ls
128 cd
129 ls
130 cd /
131 ls
132 mount /dev/sdb2 /test1
133 mkfs.ext4 /dev/sdb2
134 mount /dev/sdb2 /test1
135 df -hT
136 history
137 reboot
138 lsblk
139 parted /dev/sdb
140 mkfs.xfs /dev/sdb5
141 blkid /dev/sdb5
142 vi /etc/fstab
143 mount -a
144 df -h
145 mkfs.vfat /dev/sdb6
146 blkid /dev/sdb5
147 blkid /dev/sdb6
148 vi /etc/fstab
149 mount -a
150 mkdir /mydata
151 mount -a
152 df -h
153 mkdir Redhat
154 mkdir /Redhat
155 find / -name redhat
156 find / -iname redhat
157 find / -name redhat
158 ls -l /usr/lib/python3.9/site-packages/sos/presets/redhat
159 ls -ld /usr/lib/python3.9/site-packages/sos/presets/redhat
160 find / -name redhat -type f
161 find / -name redhat -type d
162 lsblk
163 parted /dev/sdb
164 lsblk
165 pvcreate /dev/sdb7 /dev/sdb8
166 pvs
167 vgcreate vg1 /dev/sdb7 /dev/sdb8
168 pvs
169 vgs
170 lvcreate -L 200M -n lv1 vg1
171 lvs
172 vgs
173 mkfs.ext4 /dev/vg1/lv1
174 blkid /dev/vg1/lv1
175 vi /etc/fstab
176 mount -a
177 df -h
Date 24-7-2024
To remove partition
lvs
181 df -h
182 vi /etc/fstab
183 df -h
184 umount /dev/vg1/lv1
185 df -h
186 vgs
187 lvs
188 lvremove /dev/vg1/lv1
189 lvs
190 vgs
191 vgremove vg1
192 vgs
193 pvs
194 pvremove /dev/sdb7 /dev/sdb8
195 pvs
196 parted /dev/sdb

Date 24-jul-2024
truncate -s 10G /tmp/myfile
2 losetup /dev/loop1 /tmp/myfile
3 lsblk
4 truncate -s 10G /tmp/myfile1
5 losetup /dev/loop2 /tmp/myfile1
6 lsblk
7 pvcreate /dev/loop1 /dev/loop2
8 pvs
9 vgcreate /dev/loop1 /dev/loop2
10 vgcreate data /dev/loop1 /dev/loop2
11 vgs
12 lvcreate -L 100M -n test data
13 lvs
14 pvs
15 vgs
mkfs.ext4 /dev/data/test
18 lsblk
19 mkdir /redhat
20 mount /dev/data/test /redhat/
21 mount /dev/data/test /redhat/ -t ext4
22 lsblk
23 df -ht
24 df -hT

Date 25-7-2024
How to extend LV from vg
parted /dev/sdb
210 partprobe /dev/sdb
211 pvcreate /dev/sdb1
212 pvs
213 vgcreate data /dev/sdb1
214 vgs
215 lvcreate -L 500M -n test data
216 lvs
217 mkfs.ext4 /dev/data/test
218 blkid /dev/data/test
219 vi /etc/fstab
220 mount -a
221 df -h
222 lvs
223 vgs
224 lvextend -L +472M /dev/data/test
225 lvs
226 vgs
227 df -h
228 #resize2fs /dev/data/test
229 df -hT
230 resize2fs /dev/data/test
231 df -h
232 lvs

How to extend vg & then lv


vgs
235 lvs
236 parted /dev/sdb
237 lsblk
238 pvcreate /dev/sdb2
239 vgextend data /dev/sdb2
240 vgs
241 lvextend -L +500M /dev/data/test
242 lvs
243 df -h
244 resize2fs /dev/data/test
245 df -h

Date 26-7-2024
How to create second lv mylv from same vg data
lsblk
248 lvs
249 vgs
250 lvs
251 lvcreate -L 472M -n mylv data
252 lvs
253* mkfs.xfs /dev/data/mylv
254 blkid /dev/data/mylv
255 blkid /dev/data/mylv |cut -c 15-59
256 blkid /dev/data/mylv |cut -c 16-59
257 blkid /dev/data/mylv |cut -c 17-59
258 blkid /dev/data/mylv |cut -c 17-59 >> /etc/fstab
259 vi /etc/fstab
260 lvs
261 df -h
262 mount -a
263 mkdir /AWS
264 mount -a
265 df -hT
266 vgs
267 parted /dev/sdb
268 lsblk
269 vgextend data /dev/sdb3
270 vgs
271 lvextend -L +972M /dev/data/mylv
272 lvs
273 df -h
274 df -hT
275 xfs_growfs /dev/data/mylv
276 df -hT
277 history

Date 29-7-2024
Physical extend

truncate -s 10G /tmp/myfile


2 losetup /dev/loop1 /tmp/myfile
3 lsblk
4 parted /dev/loop1
5 pvcreate /dev/loop1p1
6 pvs
7 vgcreate /dev/loop1p1 vg1
8 vgcreate vg1 /dev/loop1p1
9 vgdisplay
10 lvcreate -L 100Mb -n lv1 vg1
11 lvdisplay
12 lvcreate -L 350Mb -n lv2 vg1
13 vgs
14 lvdisplay
15 lvcreate -l 87 -n lv2 vg1
16 lvcreate -l 87 -n lv3 vg1
17 lvdisplay
18 vgs
19 vgdisplay
20 lvcreate -l 31 -n lv4 vg1
21 lvdisplay
Date 31-7-2024
Lvextend
vgdisplay
86 lvdisplay
87 lvs
88 bc
89 lvextend -l +32 /dev/vg1/lv1
90 vgdisplay
91 parted /dev/sdb
92 vgextend vg1 /dev/sdb3
93 vgdisplay
94 lvextend -l +32 /dev/vg1/lv1
95 lvs

Date 1-8-2024
/etc/shadow
useradd shyam
139 tail -n2 shyam
140 tail -n 2 /etc/shadow
141 chage -l
142 chage -l shyam
143 passwd shyam
144 tail -n 2 /etc/shadow
145 chage -l shyam
146 chage -m 2 shyam
147 chage -l shyam
148 chage -M 100 shyam
149 chage -l shyam
150 chage -w 2 shyam
151 chage -W 2 shyam
152 chage -l shyam
153 date
154 date --date now+6months
155 date --date now+6months +%F
156 chage -E 2025-02-01 shyam
157 chage -l shyam
158 chage -I 3 shyam
159 chage -l shyam
160 var=$(date --date now+6months +%F)
161 var=$(date --date now+1year +%F)
162 echo var
163 echo $var
164 chage -E $var shyam
165 chage -l shaym
166 chage -l shyam

Date 5-8-2024
Umask setting
#] Umask 546 ===temporary umask
Vi /etc/bashrc
Umask 456 ===permanent umask
Source /etc/bashrc
Useradd jj
Su - jj
Mkdir mydata
Ls -l
Perm check== 321 directory perm
220 file perm
Su - user1
Vi .bashrc
Umask 433
Mkdir test1 r– -wx -wx
Touch file1 r– -w- -w-
Exit

Date 6-8-2024
which useradd
2 useradd jj
3 su - jj
4 cat /etc/group | grep wheel
5 usermod -aG wheel jj
6 cat /etc/group | grep wheel
7 su - jj
8 passwd jj
9 su - jj

Date 7-8-2024
useradd jay
2 passwd jay
3 usermod -aG wheel jay
4 su - jay
5 vi /etc/sudoers
6 su - jay
7 useradd umesh
8 passwd umesh
9 vi /etc/sudoers
10 su - umesh
11 which mkfs
12 visudo
13 truncate -s 10G /tmp/my
14 losetup /dev/loop1 /tmp/my
15 lsblk
16 which lsblk
17 passwd umesh
18 su - umesh
19 visudo
20 su - umesh
21 visudo
22 su - umesh
23 su - jay
24 history
25 cat /etc/sudoers | grep root -A 10
26 history
root@rhel:~# cat /etc/sudoers | grep root -A 4
## the root user, without needing the root password.
##
## Examples are provided at the bottom of the file for collections
## of related commands, which can then be delegated out to particular
## users or groups.
--
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
umesh ALL=(ALL) /sbin/parted,/sbin/mkfs.ext3,/usr/bin/mkdir /test
#%wheel ALL=(ALL) ALL

## Same thing without a password


%wheel ALL=(ALL) NOPASSWD: ALL

Date 13-8-2024
Zip
Mkdir /test
Cd /test
Touch myfile{1..10}.txt
Zip myfile.zip *.txt
Ls
Cp myfile.zip /tmp
Cd /tmp
unzip myfile.zip
Cd /test
Touch test.txt
Zip -u myfile.zip test.txt
Vi myfile.zip
Zip -d myfile.zip test.txt
Vi myfile

Date 14-8-2024
Tar
Mkdir
dnf install at
15 mkdir /test
16 cd /test
17 touch file{1..10}
18 ls
19 cd
20 ls -ldh /test
21 du -h /test/
22 tar -cvf test.tar /test/*
23 vi test.tar
24 ls -lh test.tar
25 mkdir /data
26 cp test.tar /data/
27 ls
28 cd /data/
29 ls
30 vi test.tar
31 tar -xvf test.tar
32 ls
33 cd test
34 ls
35 cd
36 #tar -cvf
37 cd /test/
38 tar -cvf mytest.tar *
39 ls
40 vi mytest.tar
41 mkdir /unnati
42 cp mytest.tar /unnati/
43 cd /unnati/
44 ls
45 tar -xvf mytest.tar
46 ls
47 rm f*
48 ls

Date 22-8-2024
Ssh port
4 vi /etc/ssh/sshd_config
5 systemctl restart sshd
6 firewall-cmd --permanent --add-service=ssh
7 firewall-cmd --reload
8 firewall-cmd --list-all
9 netstat -tunlp |grep ssh
10 semanage-port -l
11 semanage port -l
12 semanage port -l | grep ssh
13 man semanage port
14 semanage port -a -t ssh_port_t -p tcp 5000
15 semanage port -a -t ssh_port_t -p tcp 5001
16 semanage port -a -t ssh_port_t -p tcp 5007
17 semanage port -l | grep ssh
18 netstat -tunlp |grep ssh
19 vi /etc/ssh/sshd_config
20 systemctl restart sshd
21 netstat -tunlp |grep ssh
22 firewall-cmd --permanent --add-port=5007/tcp
23 firewall-cmd --list-all
24 firewall-cmd --reload
25 firewall-cmd --list-all
26 useradd farah
27 passwd farah

Date 23-8-2024
useradd poonam
2 su - poonam
3 useradd nita
4 su - nita
5 su - poonam
6 cd /tmp/test.key
7 ll /tmp/test.key
8 chown nita:nita /tmp/test.key
9 ll /tmp/test.key
10 chmod 600 /tmp/test.key
11 mv /tmp/test.key /home/nita/
12 ls -ld /home/nita/test.key
13 su - nita
ssh [email protected]
2 ssh-keygen
3 ssh-copy-id [email protected]
4 cd .ssh/
5 ls
6 ssh [email protected]
7 history
8 cd
9 cp .ssh/id_rsa test.key
10 ll
11 chmod 600 test.key
12 ssh -i test.key [email protected]
13 vi cd
14 cd
15 exit
16 cp test.key /home/nita/
17 cp test.key /tmp/

Date 24-08-2024

date
2 dnf install chronyd
3 dnf install chrony
4 vi /etc/chrony.conf
5 systemctl restart chronyd
6 systemctl enable chronyd
7 timedatectl
8 timedatectl list-zone
9 timedatectl list
10 timedatectl --list
11 timedatectl --help
12 timedatectl list-timezone
13 timedatectl --help
14 timedate list-timezones
15 timedatectl list-timezones
16 timedatectl list-timezones | grep India
17 timedatectl list-timezones | grep Asia
18 #timedatectl set-timezones Asia/Srednekolymsk
19 #timedatectl list-timezone
20 timedatectl list-timezones
21 #timedatectl set-timezones Asia/Srednekolymsk
22 systemctl stop chrony
23 systemctl stop chronyd
24 systemctl status chronyd
25 timedatectl
26 timedatectl --help
27 timedatectl set-time 22:10
28 timedatectl --help
29 timedatectl
30 timedatectl sun 2024-09-10
31 timedatectl Sun 2024-09-10
32 timedatectl 2024-09-10
33 timedatectl 19:45
34 timedatectl 23:19
35 timedatectl set-time Sun 2024-09-10
36 timedatectl set-time "2024-09-10"
37 timedatectl
38 systemctl restart chrony
39 systemctl restart chronyd
40 timedatectl
Ssh
Ssh
Port assigning
Server
netstat -tunlp
2 netstat -tunlp | grep ssh
3 ss -tunlp | grep ssh
4 man semanage port
5 semanage port -a -t ssh_port_t -p tcp 5009
6 semanage port -l
7 semanage port -l | grep udp
8 semanage port -l | grep tcp
9 semanage port -l | grep ssh
10 ss -tunlp | grep ssh
11 vi /etc/ssh/sshd_config
12 ss -tunlp | grep ssh
13 systemctl restart sshd
14 systemctl enable sshd
15 ss -tunlp | grep ssh
16 exit
17 firewall-cmd --permanent --add-port=5009/tcp
18 firewall-cmd --reload
Client
ssh root@rhel
2 ssh -p 5009 root@rhel

Create user on server as jay with password “redhat”


Create user gauri on client machine
Login via gauri user from client machine
useradd jay
22 passwd jay
25 su - jay
26 vi /etc/ssh/sshd_config
27 systemctl restart sshd
su - gauri
Last login: Tue Sep 10 13:23:35 UTC 2024 on pts/0
2 ssh jay@rhel -p 5009
3 ssh -p 5009 jay@rhel
4 exit
5 ssh -p 5009 jay@rhel

ssh-key copy to another user


Server
useradd devops
2 passwd devops
3 su - devops
4 vi /etc/ssh/sshd_config
5 systemctl restart sshd
6 systemctl enable sshd
7 su - devops
8 vi /etc/ssh/sshd_config
9 systemctl restart sshd
Su - kk
ssh-keygen
ssh-copy-id devops@rhel2
ssh devops@rhel2
ls -a
cd .ssh/
ls
cp id_rsa test.key
cp test.key /home/kk/
ls
rm test.key
cd
ls
ll
chmod 600 test.key
ssh -i test.key devops@rhel2
ssh -i /home/kk/test.key devops@rhel2
exit
cp test.key /home/jay/
cp test.key /tmp/
cd /tmp/
ls
Ll
Su - root
useradd kk
2 passwd kk
3 su - kk
4 useradd jay
5 passwd jay
6 su - kk
7 cd /tmp/
8 ll
9 chown jay:jay test.key
10 ll
11 mv test.key /home/jay/
12 su - jay
ls
2 ll
3 vi test.key
4 ssh -i test.key devops@rhel2

Changed port no & key access


server
man semanage port
12 semanage port -a -t ssh_port_t -p tcp 5009
13 vi /etc/ssh/sshd_config
14 systemctl restart sshd
15 ss -tunlp | grep ss
16 firewall-cmd --permanent --add-port=5009/tcp
17 firewall-cmd --reload
client
su - kk
Last login: Fri Sep 13 05:56:39 PDT 2024 on pts/0
[kk@rhel3 ~]$ ssh -i /home/kk/test.key devops@rhel2
ssh: connect to host rhel2 port 22: Connection refused
[kk@rhel3 ~]$ ssh -p 5009 -i /home/kk/test.key devops@rhel2
Last login: Fri Sep 13 06:02:32 2024 from 10.5.1.95
[devops@rhel2 ~]$ exit
logout
Connection to rhel2 closed.
[kk@rhel3 ~]$ exit
logout
root@rhel3:~# su - jay
Last login: Fri Sep 13 06:12:46 PDT 2024 on pts/0
[jay@rhel3 ~]$ ssh -i test.key devops@rhel2
ssh: connect to host rhel2 port 22: Connection refused
[jay@rhel3 ~]$ ssh -p 5009 -i test.key devops@rhel2
Last login: Fri Sep 13 06:21:42 2024 from 10.5.1.95

Scp
1 scp root@client1:/tmp/file1.txt .
2 ls
3 touch test.txt
4 scp test.txt root@client1:/tmp/
5 exit

Date 26-8-2024
Scp
Client

cat > myfile1.txt


2 scp myfile1.txt root@client1:/tmp/
3 cat > myfile1.txt
4 scp myfile1.txt root@client1:/tmp/
5 cat >> myfile1.txt
6 scp myfile1.txt root@client1:/tmp/

Date 27-8-2024
NFS server
dnf install nfs-utils -y
2 mkdir /data
3 vi /etc/exports
cat /etc/exports
/data *(rw,sync)
4 exportfs -r
5 exportfs -rv
6 vi /etc/exports
7 exportfs -rv
8 vi /etc/exports
9 exportfs -rv
10 systemctl start nfs-utils
11 systemctl enable nfs-utils
12 firewall-cmd --permanent --add-service=nfs
13 firewall-cmd --reload
ip a
3 mkdir /nfs
4 dnf install nfs-utils
5 mount -t nfs rhel:/data /nfs
6 mount rhel:/data /nfs
7 mount 10.5.0.75:/data /nfs
8 mount rhel:/data /nfs
9 mkdir /mydata
10 mount rhel:/data /mydata
11 vi /etc/fstab
12 mount -a
13 mount rhel:/data /mydata
14 mount rhel:/test /mydata
15 systemctl daemon-reload'
16 systemctl daemon-reload
17 mount rhel:/test /mydata
18 df -h
19 cd /mydata/
20 touch file{1..10}.txt
21 ll

Date 30-8-2024
Nfs autofs
Server
dnf install nfs-utils -y
2 vi /etc/exports
3 exportfs -rv
4 mkdir /mydata/server -p
5 exportfs -rv
6 vi /etc/exports
7 exportfs -rv
8 vi /etc/exports
9 exportfs -rv
10 systemctl restart nfs-server
11 systemctl enable nfs-server
12 firewall-cmd --list-all
13 firewall-cmd --permanent --add-service=nfs
14 firewall-cmd --reload
15 cd /mydata/server
16 ls
17 touch file{1..10}.doc
18 ls

Client
1 dnf install nfs-utils autofs -y
2 mkdir /mydata
3 vi /etc/auto.any
4 vi /etc/auto.master
5 vi /etc/auto.any
6 systemctl restart autofs
7 systemctl enable autofsdnf install http -y
2 dnf install httpd -y
3 cat > /var/www/html/index.html
4 hostname
5 ip a
6 systemctl status httpd
7 systemctl start httpd
8 firewall-cmd --set-default-zone=public
9 firewall-cmd --list-all
10* firewall-cmd --
11 firewall-cmd --list-all
12 firewall-cmd --reload
13 firewall-cmd --list-all
14 firewall-cmd --permanent --remove-service=http
15 firewall-cmd --reload
16 firewall-cmd --permanent --add-service=http
17 firewall-cmd --reload
18 systemctl stop httpd

9 cd server
10 ls
11 df -hT
12 cd
13 systemctl restart autofs
14 df -hT

Firewall
1 firewall-cmd --set-default-zone=block
2 firewall-cmd --list-all
3 firewall-cmd --reload
4 firewall-cmd --list-all
5 firewall-cmd --permanent --add-service=ssh
6 firewall-cmd --list-all
7 firewall-cmd --reload
8 firewall-cmd --list-all
9 vi /etc/ssh/sshd_config
10 systemctl restart sshd
11 firewall-cmd --permanent --remove-service=ssh
12 firewall-cmd --reload
13 firewall-cmd --set-default-zone=drop
14 firewall-cmd --reload
15 firewall-cmd --list-all
16 firewall-cmd --set-default-zone=block
17 firewall-cmd --reload
18 firewall-cmd --get-active
19 firewall-cmd --set-default-zone=internal
20 firewall-cmd --reload
21 firewall-cmd --list-all
22 firawalld.richlanguage
23 man firawalld.richlanguage
24 man firawall
25* man firwalld
26 man firewalld.richlanguage
27 firewall-cmd --permanent --add-rich-rule "rule family="ipv4" source address="10.5.1.125/32"
service name="ssh" limit value="1/m" accept"
28 firewall-cmd --list-all
29 firewall-cmd --permanent --remove-service=ssh
30 firewall-cmd --reload
31 firewall-cmd --list-all
32 firewall-cmd --permanent --remove-rich-rule "rule family="ipv4" source
address="10.5.1.125/32" service name="ssh" limit value="1/m" accept"
33 firewall-cmd --reload
34 firewall-cmd --list-all
35 firewall-cmd --permanent --add-rich-rule "rule family="ipv4" source address="10.5.1.125/32"
service name="ssh" limit value="1/m" drop"
36 firewall-cmd --list-all
37 firewall-cmd --reload
38 firewall-cmd --list-all
39 firewall-cmd --permanent --add-service=ssh
40 firewall-cmd --reload
41 firewall-cmd --list-all
Http
Date 10-9-2024
Port forwarding
vi /var/www/html/index.html
2 systemctl restart httpd
3 systemctl enable httpd
4 firewall-cmd --permanent --add-service=http
5 firewall-cmd --reload
6 firewall-cmd --list-all
7 man semanage-port
8 semanage port -a -t http_port_t -p tcp 5009
9 netstat -tunlp
10 netstat -tunlp |grep http
11 ss -tunlp |grep http
12 semanage port -l |grep http
13 vi /etc/httpd/conf/httpd.conf
14 systemctl restart httpd
15 netstat -tunlp |grep http
Php web page hosting
dnf install php
11 systemctl restart httpd
12 history
13 dnf install php
14 vi /var/www/html/index.php
<?php
phpinfo();
?>

15 vi /etc/httpd/conf/httpd.conf
(DIRECTORY INDEX index.php)
16 cat /var/www/html/index.php
17 vi /etc/httpd/conf/httpd.conf
18 systemctl restart httpd

Ubuntu
Apache2
apt-get update
2 halt
3 apt install apache2
4 cat /etc/os-release
5 cat > /var/www/html/index.html
6 systemctl restart apache2
7 systemctl enable apache2
8 vi /etc/apache2/sites-enabled/
9 vi /etc/apache2/sites-enabled/000-default.conf
10 vi /etc/apache2/apache2.conf
11 ufw status
12 ufw active
13 ufw allow apache2
14 ufw enable
15 ufw active
16 ufw status
17 ufw allow apache2
18 ufw allow apache

You might also like