0% found this document useful (0 votes)
48 views55 pages

LINUX Short Notes For Beginners

This notes helps beginners to learn about Linux and its basic commands easily. These notes are like a crash course for beginners. These includes basic Linux OS commands, types of Linux , their features, and some important operation in Linux.

Uploaded by

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

LINUX Short Notes For Beginners

This notes helps beginners to learn about Linux and its basic commands easily. These notes are like a crash course for beginners. These includes basic Linux OS commands, types of Linux , their features, and some important operation in Linux.

Uploaded by

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

LINUX

____________________________________________________________________________

# 3 major source to run an application :-


1.) RAM
2.) CPU
3.) HardDisk

# Operating System :-
Operating system is a platform between Application & Hardware.
It is an interface between Application and hardware. And it will manage the Hardware resources for
application. It is a collection of programs.

A
# Linux :-
Linux is an open source operating system.
● Kernel is the heart of the application manager for all resources.
● Applications run in shall → kernel provide resources .

R
D
N
JE
A

# Properties of open sources :-


• Free availability.
• Visible source code.
G

• Customizable.
• Secure after customization.

# Flavours of Linux are :-


• Android -> It is a customised linux flavour.
• Puppy -> Puppy linux works at 256 kb.
• Kali Linux -> secure.
• Parrot -> secure.

# Linux does not work in Graphics.

1
LINUX
____________________________________________________________________________

Linux file system :


/ is the top or root directory in the linux file system.:
Root have all permissions in work in /
Other user have not all permissions in work in /

A
R
DIRECTORIES OF / :
● /bin/ => binary file => store general commands D
● /sbin/ => system binary file => store system related files
● /etc/ => it store system configuration files (it is like a control panel of windows)
N
● /dev/ => device driver => it contains device files
● /var/ => variable type data => it stores that directories which size is not fix
Example: /var/spool/mail/ => store users files
JE

● /usr/ => user related data


● /proc/ => system hardware information (like memory , CPU , partisan)
● /opt/ => optional directory =>
● /home/ => it contains users’ personal directories
● /media/ => graphical mount point => The /media directory is where external storage will be
automatically mounted when you plug it in and try to access it.
A

● /boot => it contains files required for starting your system


● /lib => it contains libraries. Libraries are files containing code that your applications can
use.
● /mnt/ => This is where you would manually mount storage devices or partitions.
G

● /root/ => it is the home directory of the superuser (also known as the “Administrator”) of the
system.
● /run/ => /run is another new directory. System processes use it to store temporary data for
their own nefarious reasons.
● /srv/ => The /srv directory contains data for servers. If you are running a web server from
your Linux box, your HTML files for your sites would go into /srv/http (or /srv/www). If you were
running an FTP server, your files would go into /srv/ftp.
● /sys/ => /sys is another virtual directory like /proc and /dev and also contains information
from devices connected to your computer.

2
LINUX
____________________________________________________________________________

● /tmp/ => /tmp contains temporary files, usually placed there by applications that you are
running.
For detailed notes of linux file system please visit this links :
● https://www.linux.com/training-tutorials/linux-filesystem-explained/ (linux.com)
● https://www.geeksforgeeks.org/linux-file-hierarchy-structure/ (geeksforgeeks)

A
R
D
N
JE

Linux commands:-
GUI —---> TERMINAL —-----> COMMAND LINE SHALL —----> EXECUTE COMMAND

Terminal : it is an application that will help you to provide a command line shall .
A

In Execute mode we see :

[root@localhost ~]# => when login with root user.


G

[root@localhost ~]$ => when login with a user


$ —> no administrator privilege (user have only some particular power )

3
LINUX
____________________________________________________________________________

A
SYNTAX FOR APPLY COMMAND :
command -[options] argument
Ctrl + shift + (+) => increase font size.

R
Ctrl + shift + (-) => decrease font size.
Ctrl + Alt + Enter => full screen

● uname -[options] => to check the operating system.


whoami => for show user name list

hostname => for show host name


D
N
● hostnamectl set-hostname <hostname> => for change hostname
exec bash => execute bash : for show changes like changed hostname
JE

● date => for show date & time

● cal => for show current month calendar

● cal (year) => for show calendar of whole year which you enter

● cal (month) (year) => for show entered month calendar


A

● pwd => present working directory(folder) : for show directory name

● ls => list short : for show current Directory


G

● ll => long list :

● ls --help => for help of ls command

● ls -a => for show hide files

● ll -h => for show files in kb

● wc (file name) => for show the list of lines , words & characters of entered file

● cat (file name) => for read entered file

4
LINUX
____________________________________________________________________________

● cat => for enter any input { cat redirection = cat > (path) }
(for stop insert in cat , press ctrl +c )

● history => for show list of history

● !(history list number) => for open file from history list

● head <file name> => for show 10 upper lines of entered file

● head -n (no. Of lines) (file name) => for show upper entered no. of lines of entered file

A
● tail (file name) => for show 10 lower lines of entered file

● tail -n (no. Of file) (file name) => for show lower (from end) entered no. of lines of
entered file

R
● clear (ctrl+l) => for clear all screen content

● touch (filename) => to create a new file.


D
mkdir (folder name) => to create a new folder.

gedit (filename) => to change file name


N
● file (file name) => to show the type of file

● cd (directory path) => for change directory.


JE

● rmdir (directory name) => to delete empty directory/directory.

● rm -[options] (file name) => for delete file ( ex. rm kabra)


● rm -r (directory name) => for delete directory.
● rm -f (filename) => for forcefully delete the file
● rm -v (file name) => to delete the file and show the process of removal.
A

● rm -fv (file name) => for show command deletion process.


G

● echo “(any text )” => to print anything.

● du -h (file name) => to show file/folder size

● command --help => for help for use the given command

● man command => for read the manual of given command for help about that
q for quit manual

● less (file name ) => for read any file without using graphical interface (use with
pgup / pgDn key)

5
LINUX
____________________________________________________________________________

● more (file name ) => for read any file without using graphical interface (use with
Enter key)

● Command for copy (cp) :

Syntax :
cp -[options] source_path destination_path : To copy file from
source_path to destination_path

When we paste any file at the destination , we can rename that file name.
Options :
-r (recursive) -> for copy any directory

A
-v (verberose) -> for list the process of copy

❖ cp (any character)* destionation_path => to copy all the files from pwd which
starts from a given character and paste that at destination.

R
Example : cp d* /home/gt => to copy all the files from pwd which starts from d and
paste that at /home/gt.

D
❖ cp -rv (any character)* destionation_path => to copy all the files & folders from
pwd which starts from a given character and paste that at destination with show the process.

* means it takes all the files/folders from given info.(path or


N
character).

● Command for move (mv):


JE

Syntax:
mv -[options] source_path destination_path : To cut file/folder
from source_path & paste that at destination
Options :
-v (verberose) -> for list the process of move
A

SOME COMMANDS FOR CHANGE TARGET OR SHELL TYPE {GRAPHICAL / CLI } :


● systemctl get-default => to check default target
● systemctl isolate multiuser.target => to change target in runtime
● systemctl set-default multiuser.target => to set default target (cli)
G

● systemctl set-default graphical.target => to set default target (graphical)

ASSIGNMENT - 1
1. Display your current directory.
pwd

2. Change to the /etc directory.


cd /etc

6
LINUX
____________________________________________________________________________

3. Now change to your home directory using only three key presses.
cd (and the enter key)

4. Change to the/boot/grub directory using only eleven key presses.


cd /boot/grub (use the tab key)

5. Go to the parent directory of the current directory.


cd .. (with space between cd and .. )

6. Go to the root directory.


cd /

A
7. List the contents of the pwd.
ls

R
8. List a long listing of the root directory.
ls -l

9. Stay where you are , and list the contents of /etc.


ls /etc D
10. Stay where you are , and list the contents of /bin and /sbin.
ls /bin /sbin
N
11. Stay where you are and list the contents of ~
ls ~
JE

12. List all the files (including hidden files ) in your home directory.
ls -al ~

13. List the files in /boot in a human readable format.


ls -lh /boot

14. Create a directory testdir in your home directory.


mkdir ~/testdir
A

15. Change to the /etc directory , stay here and create directory newdir in your home
directory.
cd /etc ; mkdir ~/newdir
G

16. Create in a command the directories ~/dir1/dir2/dir3 (dir3 is a subdirectory from dir2 and
dir2 is a subdirectory from dir1.)
mkdir -p ~/dir1/dir2/dir3

17. Remove the directory testdir.


rmdir testdir

TO SEE THIS ANSWERS PRACTICALLY PERFORMED please click on the link:-


https://docs.google.com/document/d/1bd67SOoRXxWXNdCsdy0ujjwjJz5yMVcLWOkGMxu_jpE/e
dit?usp=sharing

7
LINUX
____________________________________________________________________________

Path:-

A
R
(~) means login user with home directory.

There are two types of path:-


1.) Absolute path
2.) Relative path
D
N
1.) Absolute path:-
This path always starts from / .
End at destination.
Examples:- (all examples gives from diagram)
● If pwd is a & destination is Movies directory.
JE

Path => /root/movie/


● For go to game directory
path => /home/Game/
First / is used for the top directory and 2nd / is used for entering in the directory.

● For go to b directory
path=> /root/proj/b/
A

2.) Relative Path:-


it is start from ( . , .. , ~)
G

End at destination.
( . ) means current directory.
( .. ) means parent directory.
Examples:-
● pwd= Test & dest. = Game
path => .. /Game/

● pwd = Home & dest. = test


path => . /Test/

● Pwd = a & dest. = Movie


path => .. /../movie/

8
LINUX
____________________________________________________________________________

Some examples for path:-


● Pwd = Test & dest = Movie
Absolute path => /root/movie/
Relative path => .. /../root/movie

● pwd = root & dest = b


Absolute path => b/root/proj/
Relative path => . /proj/b/

A
R
Vim Editor:-
D
" Vi " is the graphical editor in linux. And its latest version is " vim ".

vim (file name ) => to open a file to edit


N
* For more information and detail notes about vim please visit this: Vim Cheat Sheet

Vim has 3 modes :


JE

1.) Insert mode [ESC +i ] => editing mode ( used for edit file content)
2.) command mode [ESC + : ]
3.) Execute mode [ESC] => Default mode

Esc + i => it use to go insert mode


Esc + : => it use to go command mode
Esc => it use to go exitude mode
A

Ctrl + Alt + Enter => it use to full screen

vim (file name) + (line no.) => to open the file in vim editor with the cursor position at the given line.
G

command mode:-

● Esc + : => first come in command mode then apply these commands.

● Set number => it use to show number row

● Set nonumber => it use to remove line number

● W => for save file in vim

● q => for quit vim editor

9
LINUX
____________________________________________________________________________

● q! => for forcely quit vim editor

● wq => for save and quite file editing

● /(Word which we want to search)=> for search word in file

● noh => for remove highlights or stop searching

● %s/( Search word)/ ( replace word)/g => for find word and replace any word in whole file

A
Execute mode:-

R
Esc => to come in execute mode first then apply these commands.

● yy => for copy single line in which cursor is bb link

● p => for paste copied line at cursor position


D
np = > paste the copied line n no. Of times (n=1, 2,3,4,5….)

nyy => for copy n no. Of lines from the cursor (n=1, 2,3,4,5……)
N
● dd => for delete single line

● ndd => for delete n no. Of lines.


JE

● x => to delete a single character.

● u => for undo

● Shift + G => for move cursor at end position


A

● Shift + H => to move the cursor at top position.

● n => to jump to the next highlight.


G

● Shift + n => for jump back highlight.

● Shift + zz => save and quit.

Softlink and hard link :-

Hardlink - when a file have to path to access it called Hard link

10
LINUX
____________________________________________________________________________

Process:-
● touch (filename) = to create a new file in pwd
Example : touch bac
Command filename
● ls -li = for long list of for inode no. of any file
example:- 135003728 -rw-r--r--. 1 root root 0 Dec 19 04:18 bac
Inode no. permissions owner group file date time file name
● State (filename) = is used to list the metadata of inode ( info about file in inode )
Example :
File: bac
Size: 0 Blocks: 0 IO Block: 4096(size of one block in bytes) regular
empty file
Device: 10303h/66307d Inode: 135003728 Links: 1

A
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
(permissions)
Context: unconfined_u:object_r:admin_home_t:s0
Access: 2021-12-19 04:18:14.175701739 -0800 (last acces info)

R
Modify: 2021-12-19 04:18:14.175701739 -0800 (last edit info.)
Change: 2021-12-19 04:18:14.175701739 -0800 (last changes details)
Birth: -

● ln (path of any file ) = for creating the link

Example : ln /root/bac/ /root/abc1

absolute path
D
For creating the link always use absolute path relative path is not used

Command file path whose you want to create a link new link file name with
N
● ln {file path} { destination path}
JE

Ex ln root/file root/rinku/file 1

● stat (file name ) => for complete information about file

● ls -li => for see current file information

● lsblk => To see directories of linux


A
G

USER PART:-
CUM centralised user management : different multiple accounts working on
different things active directory with help of cum.
TYPES OF ACCOUNTS :
1. Administrator user account (root)
2. Regular user account
3. system / application / service account

11
LINUX
____________________________________________________________________________

UID : (user id)


0 → for administrator
1000 - 60000 → for regular user
1-999 → service / application accountACCESS :
● Administrator → complete access of /home directory
● Regular account => complete access of home directory / limited access of os / home /
● System / application account => only access of application working directory

DIRECTORES :
Administrator → /root
User regular → /home/
Application → application working directory

A
R
D
N
Command syntax : useradd -[option] user_name
JE

● useradd (users name) => for add a user


● man useradd => to see complete manual of useradd command

● id (username) => for check user id of user

● su - (users name) => for login with another user


A

● logout => for logout present user account


EXAMPLE:
G

User account details:

12
LINUX
____________________________________________________________________________

useradd renu:-

A
● /etc/passwd (it stores the information of user account)
renu : x : 1001 : 1001 : hii : /home/renu : /bin/bash
login_name: link for password: UID : GID : comment : home_dir : shell

R
/etc/shadow (it stores the password related information)
D
/etc/group (it stores the information of group account)

SHELL : 1 bash → in this user can login and run the programs
N
Location : /bin/bash/

NOLOGIN SHELL : it cannot access and do not run any command in system
Location : /sbin/nologin
JE

SHADOW FILE : it stores password related info.


Location : /etc/shadow

PASSWD FILE : it stores the information of user account


Location : /etc/passwd
In this file some characters means are:
● !! → means no password add os save of that user at that time
A

● ! → means locked by password


● -- → means no password for login
G

13
LINUX
____________________________________________________________________________

A
R
D
N
JE
A
G

14
LINUX
____________________________________________________________________________

A
● passwd (username) => for set password , change password of any user

● gpasswd (group name) => for set password , change password of any group

R
● (command) --help => for help for use any command / to see all options of any command

● man (command) => see relative all options of any command / manual of any command

● chage -[options] (user name. ) => for change user policies


D
Like age of password, age of account expiration date , change password day, warnings days etc

groupadd {group name} =>It use to add group


N
● usermod [options] =>It is used to edit user dir,uid, group etc.

● groupmod -[options] => It use to install edit group information


JE

● groupdel -[options] group name =>It use to delete group

● userdel -[options] user name => It use to delete user and dir etc
A

ASSIGNMENT - 2
1. Add a group account database with group id 2001.
Ans : groupadd -g 2001 database
G

2. Add a group account animal with group id 2008.


Ans : groupadd -g 2008 animal

3. Add a user arpit with user id 4444


a. User is having non interactive shell
b. User home directory will be created under /mnt
c. The user primary group is animal and supplementary group is database
d. Update your mobile no. at comment section of user

15
LINUX
____________________________________________________________________________

Ans : useradd -u 4444 -s /sbin/nologin -b /mnt -g animal -G database -c


9909999 arpit

4. Assign a password india to the arpit user.


Ans :

5. Configure password policy of arpit user i.e.


a. Arpit can't change the password within 3 days after the last password change .
b. Arpit user password will expire after every 45 days of last password change.
c. The user password will inactive after 1 day of password expiration.
d. The user account will expire on 26th january 2023.

A
Ans : - chage arpit
- chage -l arpit

6. Change user id of arpit and assign a new user id 1001.

R
Ans : - usermod -u 1001 arpit

7. Change the home directory of arpit to /var/shivani .


Ans : - mkdir /var/shivani
- usermod -d /var/shivani arpit
- vim /etc/passwd
D
N
8. Try to login with a div user (if there is no login ,make it login).
Ans : - su - div

9. Create a group account name ibm with group id 4001.


JE

Ans : - groupadd -g 4001 ibm


- vim /etc/group

10. Change login name of arpit user to shivani.


Ans : - usermod -l shivani arpit
- id shivani (check user id)
A

11. Change the user id of shivani to 6666.


Ans : - usermod -u 6666 shivani
G

12. Make ibm a supplementary group for user shivani.


Ans : - usermod -G ibm shivani

13. Check the database and ibm both are supplementary group for user shivani (user option
-a -G ).
Ans : usermod -a -G database shivani

16
LINUX
____________________________________________________________________________

PERMISSIONS:-
There are two types of permission:-
1.) Authentication :- who can enter the machine.

2.) Authorization :- Once a person enters a machine, what can they do?

How permission work :-

A
● Execution mode of the program is called process.
● Files always have permissions for users.

User -------> program (command) -------> process ---------------> resources (files / directory

R
Examples (how it work) :-
Sachin (user) ----> cat (command for read file) ---> process (cat) ---> file1
(sachin owner)
D (check permission for sachin user)

Kushal -----> cd (command for change directory) -----> process (cd) kushal ----> directory
(check permission for kushal
N
user)

There are three types of universal permissions:-


JE

Permissions Symbolic Representation Numeric Representation

Read r 4

Write w 2
A

Execute x 1

Role of r, w, x on file/directory:-
G

File (4+2=6) (by default) :-


r ----> user can read the file.
w ------> user can edit the file.

Directory:-
r -------> user can list the content of the directory.
w ------> user can create or delete file / directory inside it.
x -------> user can switch inside directory.
Rt

17
LINUX
____________________________________________________________________________

● Directory must have the execute permission for read and write.
● File must have the read permission for write.
● By default execute permission is not given in the file. It is not necessary for the file because it
may be risky for the machine (for security purposes).

There are three categories for permission in directory:-

Owner group other


root admin
rwx r-x ---

A
Tata - chif
Local —>
Root
Ll

R
commands used in permissions:-


D
ls -l (file name) => to check the permission of the file.

ls -ld (directory name) => to check the permission of the directory.


Example:-
N
- rw- r-- r-- 1 root root 191 nov 9 23:58 testk
- Owner per. || group per. || other per. || 1 || owner || group ||
JE

(-) used in the above example means regular file.


d means directory file.
l means shortcut file.
b means block file.
s means socket file.
A

● id (user name) => for checking user basic info.


G

● chown (owner name) ( file/dir. Name) => to change the owner of the file.

● chgrp (group name) (file/dir. Name) => to change the group of files.

● chown (owner name) :(group name) (file/dir.name) => for changing the owner & group both
of file/dir.

How to modify permissions:-

18
LINUX
____________________________________________________________________________

● chmod (permission) (file/directory) => to change the permission / to modify the permission.

Representation of permission categories:-


● Owner = u
● Group = g
● Other = o

Operators used in command for modify permission:-

● + (for add any permissions)


● - (for remove any permission)

A
● = (for assign permissions)

Symbolic way for modify permissions:-

R
Directory 1

Owner group other (categories)


rwx

Examples Commands:-
rwx r-x
D (permissions on categories)

● chmod g-w Directory1(path of any directory) => to remove the write


N
permissions for the group from directory 1.
● chmod u+w, g-w Dir. 1 => add write permission for owner and remove write
permission for group from directory 1.
JE

● chmod ugo+rx Dir. 1 => for add read and execute permission for owner,
group, other all from dir. 1
● chmod a-w Dir. 1 => to remove the write perm. For all categories (ugo) .

Numeric way:- [ugo => format] In this way assign all three values . Same time.
Permissions Numeric Representation
Read [r] 4
A

Write [w] 2
Execute [x] 1
G

rwx 4+2+1= 7
r-x 4+1=5
-wx 2+1=3
rw- 4+2=6

Ugo = 777

Examples Commands:-
● chmod 750 Dir1 => to assign rwx-for u ; r-x- for g ; --- for o.
● chmod 664 dir. 1 => to assign rw- for u ; rw- for g ; r-- for o.

19
LINUX
____________________________________________________________________________

Important points:-
● All users have all permission in /.
● File owner has permission to read any file at home.
● Any user does not have permission to read any file in the root directory.

A
R
D
N
Sticky bit / o+t / 1 : it will apply to the directory.
JE

Acl ( access control list ) :


Commands :
● setfacl -m u:(user name):(permissions) (path of file)
Example : setfacl -m u:sachine:rwx /ee
A

● setfacl -m g:(group name):(permissions) (path of file)

● getfacl (path of file) => for check acl perm. On file


G

● setfacl -x u:(user name) (file path) => to remove acl perm.

● Setfacl -b => remove acl perm. For all (user / group)

Redirection :- it is used to save output/input/errors etc. in a file.

20
LINUX
____________________________________________________________________________

If we enter the wrong path or location of a fine that time itself, make a new file there and save the given
data in those.

A
R
D
N
Mode of redirection :
> ( overwrite)
>> ( append)
JE

Types of Redirection :
1.) Input redirection :

Command > (path of file with file name)


(Input)
Command >> (path of file with file name)
A

Example : cat > /var/stat => to enter any input in the stat file . (for stop input writing press
Ctrl + c )
2.) Output Redirection :
G

Command > (path of file with file name)


(output)
Command >>(path of file with file name)

3.) Error Redirection :

Command 2> (path of file with file name)


(error)
Command 2>> (path of file with file name)

21
LINUX
____________________________________________________________________________

4.) Output & error Redirection :

Command &> (path of file with file name)


Command &>> (path of file with file name)

GREP COMMAND :

A
Globally search for regular expression and print .
It searches only a given pattern , not the location of any file .

R
Command :
● Grep -[option] pattern file1 file2 file3 => to search any pattern in
different files.
Some options of grep :
D
-i (ignore case)
-v (invert)
-w (word)
N
-c (count)
-n (line number)
JE

Example :
Pwd = root
● touch arya => to make an arya named file in pwd(root).
● vim arya => for edit arya file open vim editor
● Esc + i => to open insert mode in editor.
Type something there…………(like : hii grass , it is a company…… etc.
A

anything which you want, can write here )


● Esc + : => for open command mode in editor
● Wq => to save and quit the editor .
G

● cat arya => to read arya file (what you write in them)
● grep grass arya /etc/passwd => to search grass in arya and passwd file
( which is in /etc) (case sensitive)
● grep -i grass arya => for search all response related to grass (it is not
case sensitive)
● grep -iv grass arya => it will show all lines without containing grass
pattern related response.
● grep -ic grass arya => to print no. of lines in which grass response
founded.
● grep -c grass arya => to print no. of lines in which grass pattern is found.

22
LINUX
____________________________________________________________________________

● grep -in grass arya => to show line no. with grass response lines.
● grep -inw grass arya => to search only grass words.

PIPELINE (|) :
It will contain two or more than two commands.

A
Format :
command1 | command2 | command3
Output —--> input
Output —--->input

R
Output —--> show on screen.

Example :
● history | less => to show historyD
● history | grep -i useradd | less => to show useradd related
response lines.
N
BACKUP :
JE

For large data files we create archive files via compression method .
A
G

COMPRESSION :
1.) Lossy compression
2.) Lossless compression

1. Lossy compression :
Data —----> compression —------> data loss

23
LINUX
____________________________________________________________________________

In this we cannot get the data again in actual size.


Example : in this we compress images , videos etc.

2. Lossless compression :
Data —----> compression —---> archive file —--> extract —--> data
Example : documents

DATA TRANSFER :
Process of data transfer in normal whatsapp:
Data (50mb) —-------> network —------->

A
Whatsapp1 —-------> network —-------> whatsapp2
Image —------> reduce size —----> network —--------> image (in reduced size)
Document —----> compress —----> network —----> extract —-----> document (actual size)

R
Lossless compression :
Create an archive file by tar (compress in min. size) , tar.gzip
(compress in min. Size compared to tar ) , tar.bzip2 (compress in min. Size compared to
tar.gzip ). D
Latest method in linux for compress file is tar.bzip2
N
Command :
● tar -[options] (filename or location where you want to create new
archive file) (location of file which you want to create an archive file)
JE

Options : -c (create a archive file)


-v (verbose) (for show process)
-f (archive file name)
-t (list)
-x (extract )
● tar -cvf………………… filename.tar (for create tar file)
A

● tar -cvzf………………… filename.tar.gz (for create tar.gzip file)


● tar -cvjf………………… filename.tar.bz2 (for create tar.bzip2
file)
G

Example :
● tar -cvf /home/backup.tar /mnt => for create a backup.tar
(compressed) file of /mnt folder
● du -h (file name) => to show file/folder size
● tar -tvf /home/backup.tar | grep passwd => to list backup.tar file data
(without extract) and search passwd pattern in that .

FOR EXTRACT :
● tar -xvf /home/backup.tar.bz2 -C /mnt

24
LINUX
____________________________________________________________________________

ASSIGNMENT -3
1. Display the first 12 lines of /etc/services.
Ans : head -12 /etc/services

2. Display the last line of /etc/passwd.


Ans : tail -1 /etc/passwd

A
3. Use cat to create a file named count.txt that looks like this:
Ans : cat > count.txt
One

R
Two
Three
Four
Five (followed by Ctrl+d)
D
4. Use cp to make a backup of this file to cnt.txt.
Ans : cp count.txt cnt.txt
N
5. Use cat to make a backup of this file to catcnt.txt.
Ans : cat count.txt > catcnt.txt
JE

6. Display catcnt.txt ,but with all lines in reverse order ( the last line first).
Ans : tac catcnt.txt

7. Use more to display /etc/services.


Ans : more /etc/services
A

8. Display the readable character strings form the /usr/bin/passwd command .


Ans : strings /usr/bin/passwd

9. Use ls to find the biggest file in /etc.


G

Ans : ls -lrS /etc

10. Open two terminal windows (or tabs) and make sure you are in the same directory in
both. Type echo this is the first line > tailing.txt in the first terminal , then
issue tail -f tailing.txt in the second terminal. Now go back to the first terminal
and type echo This is another line >> tailing.txt (note the double >>) , verify
that the tail -f in the second terminal shows both lines. Stop the tail-f with Ctrl+C.
Ans :

25
LINUX
____________________________________________________________________________

11. Use cat to create a file named tailing.txt that contains the contents of tailing.txt
followed by the contents of /etc/passwd.
Ans : cat /etc/passwd >> tailing.txt

12. Use cat to create a file named tailing.txt that contains the contents of tailing.txt
preceded by the contents of /etc/passwd.
Ans : mv tailing.txt tmp.txt ; cat /etc/passwd tmp.txt > tailing.txt

A
PASSWORD CRACK MECHANISM : (in linux)
For crack the root password follow these steps -

R
➢ First of all, restart the machine.
➢ Then click the cursor in shown screen
➢ Press PgDn ↓ key
➢ Select first row through take cursor there
➢ Press e
➢ Go at initrd and press ←
➢ Type : rd.break
D
N
JE

➢ Press ctrl+x
➢ mount (for check file system)
A
G

➢ mount -o remount,rw /sysroot

26
LINUX
____________________________________________________________________________

➢ mount
➢ chroot /sysroot
➢ ls
➢ passwd
➢ Enter new password
➢ touch /.autorelabel
➢ exit

A
➢ exit

R
D
N
JE
A
G

27
LINUX
____________________________________________________________________________

BOOTING PROCESS :

A
R
D
N
JE
A
G

➢ Power on

28
LINUX
____________________________________________________________________________

➢ SMPS
➢ BIOS {Post (Power on self test)} / {USEP(More Secure)}
➢ Bootable device (Check)
➢ Bootable order 1. cd/dvd
2 .harddisk
3. pendrive
4. pxe.boot
➢ In hard drive
MBR(Master boot Recorder)
size = 512 kb
446 Byte is information of BOOT loader

A
64 byte information of Partition
2 byte information of MBR validation Check
➢ MBR >>> Bootloader
➢ Three BOOT LOADER

R
1.LILO (work on rhel <6)
2.GRUB (Linux and windows both )
3. GRUB2


D
Bootloader >>> Kernel >>extract>>initramfs>>extract>>initrd
kernel>>systemd{First program Start on Operating system )
systemd>>Default target >>Login Screen
init 0-6 (7 Targets)
N
➢ poweroff.target 0
➢ resuce.target 1
➢ emergency.target 2
➢ multiuser.target 3
JE

➢ Future Reserved 4
➢ Graphical.target 5
➢ reboot 6

SOME COMMANDS FOR CHANGE TARGET OR SHELL TYPE {GRAPHICAL / CLI } :


● systemctl get-default => to check default target
A

● systemctl isolate multiuser.target => to change target in runtime


● systemctl set-default multiuser.target => to set default target (cli)
● systemctl set-default graphical.target => to set default target (graphical)
G

29
LINUX
____________________________________________________________________________

PROCESS MANAGEMENT / SYSTEM MONITORING :

A
R
D
N
JE
A
G

TYPES OF PROCESS :
➢ User process
➢ Kernel process
➢ Daemon process
1. USER PROCESS : (work : run the commands)

30
LINUX
____________________________________________________________________________

● Started by user
● End at task completion
● Foreground
● We can decide their behaviour at run time
● User space
● We can control and monitor
2. KERNEL PROCESS :
Kernel manages hardware resources of the operating system. It is the
heart of the OS.
● Started at boot time
● End at power off

A
● Background
● We cannot change their behaviour at run time
● Kernel space
● We cannot control and monitor this

R
3. DAEMON PROCESS :
● Also known as ghost process
● Started at host time
● End at power off
● Background D
● We can control their behaviour via config file
● We can control and monitor
N
JE
A
G

31
LINUX
____________________________________________________________________________

A
R
D
N
JE
A

Command :
● systemctl => to control daemon
● free -h => to check ram in machine (ram memory status)
G

● lscpu => check CPU information


● hostnamectl => complete detail about machine
● w => to check details of login user
● uptime => gives the machine uptime details
● tty => to check terminal type
● ctrl + alt + F1 => tty1
● ctrl + alt + F2 => tty2

➢ TTY —-----> TERMINAL ( terminal is a physical console from which a task is executed.)
➢ There are 7 types of physical terminals .

32
LINUX
____________________________________________________________________________

➢ 1 physical terminal is GUI which is default tty2


➢ Virtual terminal (sudo terminal ) is CLI or GUI

PROCESS MONITORING :
COMMANDS:
● ps =>check process run in current console
Here , PID = process id

A
TTY = console info.
TIME = running time of process
CMD = bash , pd ->process

R
● ps -aux => to listed every process in standard sequence
Here , VSI = virtual size (physical memory + swap memory)
MEM = memory
? ->means background process
start= staring time D
● ps -ef => list every process in bsd syntax.
Here , PPID = parent process id
C = CPU count
N
● pstree => to show process in tree syntax
● top => it gives the live output of process (it refresh within every 3 seconds)
In this command , shift + m => sort in memory shifting
JE

shift + p => sort in CPU account shifting


z => to change syntax colour
q => for quite
● sleep (seconds) => to run the system in a given time.
Example : sleep 1000
● (any command) & => to run given command in background (this is a user command ,
A

it called jobs )
● jobs => to list background commands / jobs
● fg %(jobs id) => to take the job in foreground
G

● pgrep (command) => for check process id of any command


Example : pgrep bash => for check process id of bash command
pgrep sleep=> for check process id of sleep command
● kill => it is used to send a signal to a process
kill -l => to list all signals
Syntax : kill -(signal no.) (process id)
Example : kill -19 3071 => to stop the command which process id is 3071
15 No signal is used by default if we do not use any signal.
● ctrl +z => to stop the process
● ctrl + c => to terminate the process
● man ps => to check manual

33
LINUX
____________________________________________________________________________

● renice –help => help for changing the priority

STORAGE MANAGEMENT CONCEPTS :


File Systems and Mount Points :
To make the contents of a file system available in the file-system hierarchy, it must be mounted on an
empty directory. This directory is called a mount point. Once mounted, if you use ls to list that directory,
you will see the contents of the mounted file system, and you can access and use those files normally.

A
Many file systems are automatically mounted as part of the boot process.
If you have only worked with Microsoft Windows drive letters, this is a fundamentally different concept.
It is somewhat similar to the NTFS mounted folders feature.

R
File Systems, Storage, and Block Devices :
Low-level access to storage devices in Linux is provided by a special type of file called a block device
These block devices must be formatted with a file system before they can be mounted.
Block device files are stored in the /dev directory, along with other device files. Device files are created
D
automatically by the operating system. In Red Hat Enterprise Linux, the first SATA/PATA, SAS, SCSI, or
USB hard drive detected is called /dev/sda, the second is /dev/sdb, and so on. These names represent
the entire hard drive.
Other types of storage will have other forms of naming
N
Disk Partitions :
Normally, you do not make the entire storage device into one file system. Storage devices are typically
divided up into smaller chunks called partitions.
JE

Partitions allow you to compartmentalize a disk: the various partitions can be formatted with different
file systems or used for different purposes. For example, one partition can contain user home
directories while another can contain system data and logs. If a user fills up the home directory partition
with data, the system partition may still have space available.
Partitions are block devices in their own right. On SATA-attached storage, the first partition on the first
disk is /dev/sda1. The third partition on the second disk is /dev/sdb3, and so on. Paravirtualized storage
A

devices have a similar naming system.


An NVMe-attached SSD device names its partitions differently. In that case, the first partition on the
first disk is /dev/nvme0p1. The third partition on the second disk is /dev/nvme1p3, and so on. SD or
G

MMC cards have a similar naming system.


A long listing of the /dev/sda1 device file on host reveals its special file type as b, which stands for
block device.

PARTITION :
Some basic commands:
● fdisk -l => to check partitions
● df -f => to show partition of linuX
● cat /proc/swaps
● cat /proc/partitions => to show all partitions

34
LINUX
____________________________________________________________________________

A
R
Letus take a example for make partition: D
● First we create an extra space hard disk in our machine by
● For better understanding please visit this link of practical video :
https://drive.google.com/file/d/1fPD5Ll7taBVOLzlYROWCyxHEGV_dT4EY/view?usp=shari
N
ng
● follow the following steps through photos
a. First go on machine name right click on mouse the go to setting then click on
JE

setting
A
G

b.

35
LINUX
____________________________________________________________________________

c. Then you will get this page

A
R
d.
D
e. Click on add for add new an extra hard disk than follow the instructions
N
JE
A
G

36
LINUX
____________________________________________________________________________

f. Than click on SATA and then next

A
R
g. Than you can increase the hard disk size and Click on next
D
N
JE
A
G

37
LINUX
____________________________________________________________________________

h. Then click on finish

A
R
D
2. Than create a partition so first type lsblk
N
JE
A
G

● fdisk /dev/sdb
● In that /dev/sdb type n for new partition
● Press e for extended partition
● Than press enter , than enter then type the size of new partition like +5G
● Then create a one more partition by pressing n
● Then press e
● Than press enter enter enter
● Than wq & enter like this:

38
LINUX
____________________________________________________________________________

A
R
D
N
● Than type lsblk for check hardware details and partitions also
● Like the partitions are Sda
↳sda1
JE

↳sda5
● mkfs.xfs /dev/sda5 => to format the partition sda5 like this
A
G

● partprobe /dev/sda5 => partprobe is send it to kernel


● mount /dev/sda5 /mnt
● cd /mnt

39
LINUX
____________________________________________________________________________

● mkdir gt

A
R
QUERY : When i create an extra partition by adding an extra hardware SATA drive then after
restart my machine this is reinstalling so what to do??
ANS: this time we should set default NVM harddrive from it’s booting setting for this please
visit this link and watch this video :
D
https://drive.google.com/file/d/1QVbMHODCJQfMXVmD2qxUmtTxNxeA76jg/view?usp=sharing
N
SWAP PARTITION :
JE

● For swap partition repeat the partition process AND when when we make a partition by
command fdisk /dev/sda that time in this
● we have to type l for the list of partition Hex code
● then press t for give partition type
● than enter then give the Hex code [ for swap partition the type the code 82 ]
● Than type command mkfs.xfs /dev/sda6
A

● Than mkswap /dev/sda5


● swapon /dev/sda5
For this understand this steps practically on vmware please visit this link for a video of practical
G

performance of SWAP PARTITION :


https://drive.google.com/file/d/1WvsHBYhWQe3hJjtyQYjfY5-XC-qpbd-Z/view?usp=sharing

40
LINUX
____________________________________________________________________________

LVM(Logical volume manager):


For more detailed notes of lvm please visit
this link :
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/deployment_guide/ch-l
vm
Logical Volume Manager (LVM) is used on Linux to manage hard drives and other
storage devices. As the name implies, it can sort raw storage into logical volumes,
making it easy to configure and use.
Logical volume manager (LVM) introduces an extra layer between the physical disks

A
and the file system allowing file systems to be :
– resized and moved easily and online without requiring a system-wide outage.
– Using discontinuous space on disk

R
– meaningful names to volumes, rather than the usual cryptic device names.
– span multiple physical disks

D
N
JE
A

Physical Volume (PV)


G

Each Physical Volume can be a disk partition, whole disk, meta-device, or a


loopback file. Use the command pvcreate to initialize storage for use by LVM.
Initializing a block device as physical volume places a label at the start of the
device.

Volume Group (VG)

41
LINUX
____________________________________________________________________________

A Volume Group gathers together a collection of Logical Volumes and Physical


Volumes into one administrative unit. Volume group is divided into fixed size
physical extents. The command vgcreate creates a new volume group using the
block special device Physical Volume path previously configured for LVM with
pvcreate.

– VGs are made up of PVs, which in turn are made up of physical extents (PEs).
The size of PE can differe in different VGs and is defined at the time of creating VG.
– The default size of PE is 4MB, but you can change it to the value you want at the

A
time of VG creation.
– Generally, larger the PE size, better the performance (though less granular control
of LV).

R
Logical Volume (LV)

D
A Logical Volume is the conceptual equivalent of a disk partition in a non-LVM
system. Logical volumes are block devices which are created from the physical
extents present in the same volume group. You can use command lvcreate to create
N
a logical volume in an existing volume group.

File system
JE

File systems are built on top of logical volumes. The command mkfs can be used to create file
system on top of a logical volume. Once the file system is created we can mount the logical
volume as per our need.
A

Lets Get Started


The example
In the example below we would :
1. Create Physical volumes from physical disks (/dev/sda).
G

2. /dev/pv3
3. Create a Volume group from these PVs (/dev/vg3).
4. Create a Logical Volume in this VG (/dev/vg3/lv3).
5. Create a File system on this LV and mount it (/data).

42
LINUX
____________________________________________________________________________

A
Steps for create lvm :
1. lsblk
2. fdisk /dev/sda

R
3. Than create 2 partitions and in last press t and thant type the Hex code 8e for
lvm
4. Than save it and quit it by wq
5. lsblk
6. fdisk -l
D
7. pvcreate /dev/sda5 => to create a pv(physical volume) partition
8. pvdisplay => to display created pv
N
9. vgcreate vg3 /dev/sda5 => to create a vg( volume group) partition
10. vgdisplay => to display created vg
11. lvcreate -L +2G -n lv3 vg3 => to create a lv(logical volume) partition of 2GB
JE

12. lvdisplay => to display created lv


13. mkfs.xfs /dev/vg3/lv3 => to format lvm
14. mount /dev/vg3/lv3 /mnt => to mount lv3 in mnt
15. cd /mnt
16. mkdir gt
17. Now our lvm is created than we add a junk files to fulfil that and than expend
A

that
18. dd if=/dev/zero of=hi count=1000 bs=1M => copy the junk file hi in mnt
19. ll
20. dd if=/dev/zero of=hi1 count=2000 bs=1M
G

21. ll
22. lvextend -L +2G /dev/vg3/lv3 => after filling full space we extend the lv3 with
2GB size so now the size of lv3 is 4GB
23. lvdisplay
24. lsblk

43
LINUX
____________________________________________________________________________

YUM :
YELLOW DOG UPDATER & MODIFIER
YUM is the primary package management tool for installing, updating, removing, and
managing software packages in Red Hat Enterprise Linux. YUM performs
dependency resolution when installing, updating, and removing software packages.
YUM can manage packages from installed repositories in the system or from .
It is a helping tool which works on RPM .
It works on Repositories (collection of data) .

A
For full detailed notes please visit this link:
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_admini
strators_guide/ch-yum

R
YUM commands :
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/deployment_g
uide/s1-yum-useful-commands

D
Some important commands of yum which are basically used :
● yum help => to Show yum subcommands and options
● yum list => displays installed and available packages.
N
● yum info PACKAGENAME => it used for detailed information about a package, including the
disk space needed for installation.
● yum install PACKAGENAME => obtains and installs a software package, including any
dependencies.
JE

● yum update PACKAGENAME => obtains and installs a newer version of the specified package,
including any dependencies.
● yum remove PACKAGENAME => removes an installed software package, including any
supported packages.
● yum list all => to List installed and available packages
● yum list installed => to List all installed packages.
A

● yum clean all => to Clean out all packages and meta data from cache.
● yum list updates => for check updates of repositories
● yum repolist all => command to list all repositories on the system
G

Creating Yum local Repositories :


Steps:
● mount /dev/cdrom /mnt

44
LINUX
____________________________________________________________________________

A
● Than we create a repository in /etc/yum.repos.d/ ,let i create a file repo g.repo
● vim /etc/yum.repos.d/g.repo

R
● Than add AppStream and BaseOS in that file with base url like this

● Than save it and exit from it






mkdir /s
D
Than we create a directory at anywhere , let i create a directory named s in /

Than move the /etc/yum.repos.d directory content in /s


mv /etc/yum.repos.d/* /s
N
● Than run a command to clean all cheche of yum
● yum clean all
● Then copy the g.repo file from /s to /etc/yum.repos.d/
JE

● cp /s/g.repo /etc/yum.repos.d/
● Than install any package like i install httpd package
● yum install httpd
A
G

45
LINUX
____________________________________________________________________________

A
R
D
N
JE
A

In the new repository file we use gpgcheck . This gpgcheck is the command which is used to
G

verify the signature of a package's repository of a company for privacy or security purposes.
If we write gpgcheck=0 means it is un-enabled and means that it does not verify the sign.
If we write gpgcheck=1 that means it is enabled or at that time we have required a gpgkey
which is provided in public by the company . so we have to give the path of that key also.
The gpgkey of centOS is
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY.centosofficial

The gpgkey of RHEL 8 is


rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

46
LINUX
____________________________________________________________________________

A
R
D
N
JE
A
G

47
LINUX
____________________________________________________________________________

A
R
D
N
JE
A
G

NETWORKING :
Network is a system of interconnected devices that can
communicate, share information and resources, such as files, printers, applications, and
Internet connection. Each of these devices has a unique Internet Protocol (IP) address to send
and receive messages between two or more devices using a set of rules called protocol.

48
LINUX
____________________________________________________________________________

Intranet => local network → don’t use protocol


Internet => use some protocol

A
OSI MODEL
( Open System Interconnection model )

R
D
N
JE
A

Physical layer :
It also defined the topologies , medium (what type of cabling we are
G

medium {coaxil ,fybr , optical cable etc.}


Physical layer also define mode ( simplex , half duplex , full duplex)
Topology is a set of rules.
For example we have different topologies : bus ,star, ring,hybrid
Bus network is the cheapest way in this if one connection is broken then all connections
disconnect .

Data link layer :


This layer defines the mac address and the size of mac address is 48
bit.this layer converts packet into fram.

49
LINUX
____________________________________________________________________________

To communicate devices we required 3 things


1. NIC (network interface card) => it is a component that helps us to connect with other
devices. Ex: wifi , lan card(ethernet)
2. Physical address / mac address of NIC card => it is the fixed address which is
assigned by the company who manufactured the nic card.it is a unique address in the
world.
3. Logical address (ip address) => ip {internet protocol / intranet protocol } it is a protocol
which is used to communicate devices.

A
Internet → public network
Intranet → private network
There are 2 versions declared of IP that are = ipv4 & ipv6

R
Ipv6 is the new version .
We study about ipv4.
Ipv4 has 32 bit length
Ipv6 has 128 bit length.
● 1 bit have 2 unique address (0,1) D
● 2 bit have 4 unique address (00 , 01 , 10 , 11)
● 32 bits have 2^32 = 4294967296 unique addresses
N
IP ADDRESS :
JE

Ip address has 32 bits. Ip address has a set of four numbers — an example


address might be 192.158.1.38. Each number in the set can range from 0 to 255. So, the full
IP addressing range goes from 0.0.0.0 to 255.255.255.255.
8 bit . 8 bit . 8 bit . 8 bit
Example : 10.10.0.1
A

127.0.0.0
0.0.0.0
8 bit . 8 bit. 8 bit. 8 bit
0-255 . 0-255 .0-255. 0-255
G

50
LINUX
____________________________________________________________________________

A
R
D
N
IP address have 2 address : 1) network address
JE

2) host address
One network address have more / multiple host address
Network address may be same of machines but host address are different of every machine
A
G

51
LINUX
____________________________________________________________________________

We can’t use ip of one class in another class , to solve this limitation we use a concept which is called
CIDR (Classless Internet Domain Routing).
In this we can use IP of any range whether it is of any class.

Subnet :
It is used to divide ip address into network address and host address.
Ex : 255 . 255 . 0 . 0

A
R
which have mini. Values that show hosts add.
Example : 1.) 10.10.1.0 / 255.255.0.0
D
The obtact or sets of subnets which have max. Values are denoted network add. And the sets
N
Here 10.10 is the network add. And 1.0 is the host add. Of IP
2.) 10 . 0.1.0 / 255.0.0.0
Here 10 is the network add. And 0.1.0 is the host add.
JE

3.) Do these two ip addresses have the same network address?


192.168.1.0 / 255.255.0.0
192.168.2.3 / 255.255.0.0
Ans : both ip has same network address

4.) Do these two ip addresses have the same network address?


A

172.168.1.0 / 255.255.0.0
172.169.2.3 / 255.255.0.0 (or 16 )
Ans : both ip has different network address
5.) Do these two ip addresses have the same network/host address?
G

172.168.1.0 / 16
172.169.1.0 /16
Ans : both ip has different network address but same host address

255.0.0.0 = 8
255.255.0.0 = 16
255.255.255.0 = 24

● The 1st & last address of any network is reserved .


● The 1st address of any network is called network address And last address is called
broadcast address.

52
LINUX
____________________________________________________________________________

0.0.0.0 / 0 => universal (included all ip networks)


0.0.0.0 /16 => means those ip whose subnet is 16 are included in this ip.
127.0.0.0 & 127.0.0.1 => this ip is basically reserved for loopback (self communicate)
127.0.0.0 => address of local host (own machine address)
We have an interface card by default which is called lo (loopback only).
The special address 127.0.0.1 always points to the local system (“localhost”), and the network
127.0.0.0/8 belongs to the local system, so that it can talk to itself using network protocols.

A
R
D
N
JE
A

COMMANDS :
G

● For windows = ipconfig => to check how many interfaces we have available on
our machine. (it run in windows power shell or terminal)
● For linux = ifconfig => to check how many interfaces we have available on our
machine.
ip a s => to check how many interfaces we have available on our machine.

IMCP ( inter message control protocol ) => to send a message / to receive a message
We use IMCP by using ping command
ping => used for sending a request to check the connection.
Ex: ping www.google.com

53
LINUX
____________________________________________________________________________

ping 127.0.0.1

Q.1 : Who will build the network (or allocate the address)?
Ans : DHCP (Dynamic Host Control Protocol )
It is an application which is running on some particular device that provides the service
of the network.
This will create a network and assign a useful address to whatever device is connected to it.
We can set up different DHCP for different networks. DHCP configure everywhere.
DHCP → router , switch , machine

A
DHCP working process is called the DORA process .

R
FIREWALL :
● systemctl status firewalld.service



D
224 systemctl stop firewalld.service
225 systemctl start firewalld.service
226 firewall-cmd --list-all
N
● 227 firewall-cmd --add-port=2254/tcp
● 228 firewall-cmd --list-all
● 229 netstat -tulpn
● 230 firewall-cmd --list-all
JE

● 231 firewall-cmd --get-services


● 232 firewall-cmd --add-service=nfs
● 233 firewall-cmd --list-all
● 234 firewall-cmd --remove-service=nfs
● 235 firewall-cmd --list-all
● 236 firewall-cmd --reload
A

● 237 firewall-cmd --list-all


● 238 firewall-cmd --permanent --add-service=nfs
● 239 firewall-cmd --list-all
● 240 firewall-cmd --reload
G

● 241 firewall-cmd --list-all


● 242 firewall-cmd --permanent --add-port=2254/tcp
● 243 firewall-cmd --reload
● 244 firewall-cmd --list-all
● 245 firewall-cmd --permanent --remove-port=2254/tcp
● 246 firewall-cmd --permanent --remove-service=nfs
● 247 firewall-cmd --list-all
● 248 firewall-cmd --reload
● 249 firewall-cmd --list-all
● 250 firewall-cmd --query-panic
● 251 firewall-cmd --panic-on

54
LINUX
____________________________________________________________________________

● 252 firewall-cmd --panic-off

SSH (SECURE SHELL) :


It is a remote access protocol that uses cryptography network
protocol for providing secure connection over an unsecured network .

● The default port of SSH is 22 (ssh>22/tcp)

A
Commands:
● ip a show => for show the ip address of machine
● ssh (username)@(ipaddress) => for take remote control through ssh of any machine to

R
other machine
Ex: ssh [email protected]

D
N
JE
A
G

55

You might also like