Mist Linux - 27102018 PDF
Mist Linux - 27102018 PDF
Mist Linux - 27102018 PDF
OPERATING SYSTEM:-
In this type of operating system only one user can log into
system and can perform only one task at a time.
E.g. MS-DOS
This type of O/S supports only one user to log into the system
but a user can perform multiple tasks at a time, browsing internet
while playing songs etc.
This type of O/S provides multiple users to log into the system
and also each user can perform various tasks at a time. In a broader
term multiple users can logged in to system and share the resources of
the system at the same time.
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
2|Page
History of Linux:-
UNIX was developed in 1969 at AT&T Bell Labs by Ken Thompson and
Dennis Ritchie.
Linux has been widely adopted for servers and embedded systems.
Advantages of Linux:-
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
3|Page
Architecture
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
4|Page
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
5|Page
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
6|Page
All files on a Linux system are stored on file systems which are
organized into a single inverted tree of directories, known as
file system hierarchy. This tree is inverted because the root of
the tree is said to be at the top of the hierarchy, and the
branch of directories and sub directories stretch below the root.
Every single file and directory starts from the root directory.
/root
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
7|Page
Commands used by all the users of the system are located here.
But, the linux commands located under this directory are used
typically by system administrator, for system maintenance
purpose.
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
8|Page
Content of the files that are expected to grow can be found under
this directory.
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
9|Page
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
10 | P a g e
[ root @ localhost ~ ] (# or $)
Basic Commands:
Man command:-
Syntax:-
Example:-
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
11 | P a g e
$ man cat
Date command:-
Date command is used to display the current date and time of the
system. It can also be used by the super user to set the system clock.
Syntax:-
$ date
Calendar command:-
Syntax:-
$ cal
$ ncal
$ cal 7 1984
$ cal 1984
Calculator command:-
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
12 | P a g e
bc command is used as calculator in Linux.
Syntax:-
$ bc (press enter)
50 (Result)
Create a file $cat bcfile then give the expressions in the file
like below
10*5
10+5
10-5
10/5
$ bc < bcfile
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
13 | P a g e
The pwd command displays the full path name of the current
location, which helps determine appropriate syntax for reaching files
using relative path names.
Syntax:-
$ pwd
Change Directory:-
Syntax:-
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
14 | P a g e
$ ls
$ ls –l
$ ls –r
$ ls –R
$ ls –ltr
$ ls –i
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
15 | P a g e
$ ls –lS
$ ls –l /home
$ ls –ld
$ ls -n
cat
touch
Cat command:
Syntax:-
$cat <filename>
Example:-
$cat /etc/passwd
To create a file
Syntax:
Example:-
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
16 | P a g e
$cat > mist.txt
Syntax:
Example:-
Syntax:-
$cat -n <filename>
Example:-
$cat -n mist.txt
Touch command:-
The touch command is the easiest way to create new, empty files.
It is also used to change the time stamps (i.e., dates and times of
the most recent access and modification) on existing files and
directories.
Syntax:-
$touch <filename>
Example:-
$touch file1
Syntax:-
$touch <first file> <second file> <third file>
Example:-
$touch mist redhat linux
Syntax:-
$touch <filename {range}>
Example:-
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
17 | P a g e
$touch linuxfile {1..10}
$touch linux{a..z}
Syntax:-
$ touch <filename>
Example:-
$ touch /root/anaconda-cfg.ks
Syntax:-
$ touch –d ‘< specify date & time >’ < file name >
Example:-
$ touch –d ’15 July 1984 10:00’ mist
Syntax:-
$ touch –t YYMMDDHHMM.SS <filename>
Example:-
$ touch –t 201403150920.01 redhat
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
18 | P a g e
File Editors:-
VI/VIM:-
The vi editor has three modes, command mode, insert mode and command
line mode.
2. Insert mode: Text is inserted. The ESC key ends insert mode and
returns you to command mode. One can enter insert mode with the
"i" (insert), "a" (insert after), and “A” insert at end of line,
"o" (open new line after current line) or "O" (Open line above
current line) commands.
3. Command line mode: One enters this mode by typing ":" which puts
the command line entry at the foot of the screen.
Cursor Movement
k - Move cursor up
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
19 | P a g e
(Words can contain punctuation)
Editing
u - Undo
ctrl + r - redo
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
20 | P a g e
ndd - delete (cut) n lines [e.g. 2dd - delete 2 lines]
Exiting
:wq! - Save & Quit the file forceful:x - Save & Exit the
file
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
21 | P a g e
Open the file:-
Copy file
Move file
Rename file
Delete/remove file
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
22 | P a g e
rm command is used to delete/remove the files
or not]
Example: $ rm file1
Example: $ rm –f file1
Create directory
Copy directory
Move directory
Rename directory
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
23 | P a g e
Syntax: $ mv <olddirname> <newdirname>
rename)
Delete directory
User Administration:-
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
24 | P a g e
1. System Users:-
While we are installing the os, the system users will be created
by default. These users are logical users except ‘root’ user, because
root user is the super user in Linux systems. The UIDs of System Users
are starts from 0 to 999. Root user UID is set to 0 by default.
2. Normal users:-
The users which are created by the root user are known as Normal
users. These users are physical users. The UIDs of Normal Users are
starts from 1000 to 60000.
When we are adding a user to the system it will create some key
points as follows:
Red Hat Enterprise Linux uses a user private group (UPG) scheme,
which makes UNIX groups easier to manage.
When we are creating a user the group also created with the same
name, this group is the primary group for that particular user.
/etc/passwd
/etc/shadow
/etc/passwd:-
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
25 | P a g e
All users created under /etc/passwd file, one line per user. The
seven colon-separated fields of /etc/passwd file as follows.
Username1:passwd2:UID3:GID4:comments5:directory6:shell7
Field Description
/etc/shadow
Smithj1:Ep6mckrOLChF.2:100633:04:999995:76:::7
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
26 | P a g e
Field Description
Inactive
Expiry
Create a user:
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
27 | P a g e
Check whether user added or not
# cat /etc/passwd
Options Description
Examples:
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
28 | P a g e
Assign the user password:-
Modify User
Options Description
Examples:
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
29 | P a g e
# usermod –u 1995 mistuser
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
30 | P a g e
Group Administration:-
/etc/group
/etc/gshadow
/etc/group:-
All groups created under /etc/group file, one line per group. The
four colon-separated fields of /etc/group file as follows.
groupname1:passwd2:gid3:groupmembers4
Field Description
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
31 | P a g e
/etc/gshadow
Mist1:Ep6mckrOLChF.2:admin3:smith,ramesh4
Field Description
Create a group:
# cat /etc/group
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
32 | P a g e
Options Description
Examples:
# groupadd -h
# tail /etc/gshadow
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
33 | P a g e
Modify the group account's
Modify group
Options Description
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
34 | P a g e
# gpasswd -M user1,user2,user3 mistgrp
ls command will show the file type as an encoded symbol found as the
first character of the file permission part. In this case it is "-",
which means "regular file". It is important to point out that Linux
file types are not to be mistaken with file extensions. Let us have a
look at a short summary of all the seven different types of Linux file
types and ls command identifiers:
1.- : regular file
2.d : directory
3.c : character device file
4.b : block device file
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
35 | P a g e
5.s : local socket file
6.p : named pipe
7.l : symbolic link
Regular file
The regular file is a most common file type found on the Linux
system. It governs all different files such us text files, images,
binary files, shared libraries, etc. You can create a regular file
with the touch command:
# touch mist.com
# ls -ld mist.com
-rw-rw-r-- 1 root root 0 Jan 10 12:52 mist.com
The first character of the ls command, in this case "-", denotes the
identification code for the regular file. To remove a regular file you
can use the rm command:
# rm mist.com
Directory
When trying to remove directory with the rmdir command, which contains
additional files you will get an error message:
rmdir: failed to remove `FileTypes/': Directory not empty
Character device
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
36 | P a g e
Character and block device files allow users and programs to
communicate with hardware peripheral devices. For example:
# ls -ld /dev/vmmon
crw------- 1 root root 10, 165 Jan 4 10:13 /dev/vmmon
Block Device
Sockets can be created by socket system call and removed by the unlink
or rm commands.
Named Pipes
Symbolic Links
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
37 | P a g e
file. Furthermore, hard links cannot cross file systems and
partitions. To create symbolic soft link we can use ln -s command:
# echo file1 > file1
# ln -s file1 file2
# cat file2
file1
# ls -ld file2
lrwxrwxrwx 1 lubos lubos 5 Jan 10 14:42 file2 -> file1
Conclusion
As a system administrator you will mostly work with regular
files, directories block and character devices. As a software
developer you will also work with local sockets and named pipes.
Permissions:-
Advanced permissions
Permission Groups
Each file and directory has three user based permission groups:
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
38 | P a g e
owner(u) - The Owner permissions apply only the owner of the file
or directory, they will not impact the actions of other users.
group(g) - The Group permissions apply only to the group that has
been assigned to the file or directory, they will not effect the
actions of other users.
others(o)- The others permissions apply to all users on the
system, this is the permission group that you want to watch the
most.
Permission Types
Ex:-cp,mv,vi,rm
Basic file permissions are using two mode's assign the file/
directory perimissions
. Symbolic mode
. Absloute mode
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
39 | P a g e
Symbolic mode: We can assign the permission's to file/directory
with using the alphabets(Ex: r,w,x)
read r 4
write w 2
excute x 1
read,write rw- 6
read,exute r-x 5
wrrite,excute -wx 3
read,write,excute rwx 7
null --- 0
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
40 | P a g e
Full file perimissions : 666
Note: If the file having 777 permissions the file become a script
file
Umask:
Temporary :
Permanent :
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
41 | P a g e
Example: # vi /root/.bashrc
<eof>
umask 0033
Examples:
# ls -l for file
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
42 | P a g e
To change the owner and groups membership for files/directories
is mandatory in Linux. Every file is associated with an owner and a
group. You can use chown and chgrp commands to change the owner or the
group of a particular file/directory.
# ls -l for file
of the file/directory
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
43 | P a g e
Example: # chown mist1:bharat /dir1
Advanced permission's:-
SUID
SGID
STICKY BIT
SUID(Set UserID):
# useradd antony
# su – antony
$ useradd <username>
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
44 | P a g e
# which useradd
/usr/sbin/useradd
# ls -ld /usr/sbin/useradd
# su – antony
$ useradd jhon
SGID(Set GroupID)
# mkdir /mistdir
# ls -ld /mistdir
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
45 | P a g e
# ls -ld /mistdir
# ls -ld /mistdir
# touch a b c
Sticky Bit:
# useradd abc1
# useradd abc2
# mkdir /mistltd
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
46 | P a g e
# chmod 777 /mistltd
# cd /mistltd
# touch f1 f2 f3
# su – abc1
$ cd /mistltd
$ ls
$ logout
# ls -ld /mistltd
# su – abc2
$ cd /mistltd
$ logout
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
47 | P a g e
# su – abc1
$ cd /mistltd
$ logout
For Users
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
48 | P a g e
Syntax: # setfcal -m u:<username>:<permissions>
<file>/<directory>
For Groups
For User:
For Group:
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
49 | P a g e
Sudo (super user do command) using with sudoers file we can make
normal user will act as root user temporarily.
Restricted privileges
Logs of the actions taken by users
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
50 | P a g e
Tar(Tape Archive):
Options
-u : Update archive
-J : xz the archive
-v : (verbose) verbosely list files processed
-A : Append tar files to existing archives.
Example:
To crate backup file
# tar -cvf /tmp/mistfile.tar /etc/passwd
# cd /tmp
# ls
# tar -tvf mistfile.tar
To Restore the file & directories
# ls
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
51 | P a g e
# cat /etc/passwd
# cd /opt
# ls
# du -sh marc.tar.gz
# ls
cpio
Options
- o : create archive file
- v : verbose
- i : extract archive file
- d : crate directories
Example
# mkdir /testdir
# cd /testdir
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
52 | P a g e
# touch abc{1..5}
# ls
# cd /opt
# cpio -idv <backup.cpio
Compress tools
gzip:
# ls
# du -sh mistfile.gz
Bzip2 :
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
53 | P a g e
compressing files, to reduce memory consumption.It can compress
multiple files at a time.
#ls
XZ:
Syntax:# xz <file-name>
EX:xz /etc/passwd
# cd /etc
# ls
# du -sh passwd.xz
uncompress tools:
for gzip:
(or)
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
54 | P a g e
# gunzip <file-name.gz>
# ls
# du -sh mistfile
for bzip2:
(or)
# bunzip2 <file-name.bz2>
# ls
# du -sh linux
for XZ:
syntax: # xz -d <file-name.xz>
(or)
# unxz <file-name.xz>
Ex:# xz -d /etc/passwd.xz
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
55 | P a g e
Many new Linux sys admin (or Windows admin) create only two partitions
/ (root) and swap for entire hard drive. This is really a bad idea.
You need to consider the following points while partitioning disk.
Types of Disks
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
56 | P a g e
Different type of disks will be having different initials in
Linux
Partitions:
When a hard drive is installed in a computer, it must be
partitioned before you can format and use it. Partitioning a drive
is when you divide the total storage of a drive into different
pieces. These pieces are called partitions. Once a partition is
created, it can then be formatted so that it can be used on a
computer.
Partitioning :
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
57 | P a g e
Disk partitioning or disk slicing is the creation of one or more
regions on a hard disk or other secondary storage so that an
operating system can manage information in each region separately.
Partition Types:
Partitions get their names from the disk name itself and
add a number starting at 1 (/dev/sda1, /dev/sda2,..etc. or
/dev/vda1, /dev/vda2,.. etc).
MBR partition table (MBR stands for Master Boot Record). This
organization allows for 4 primary partitions only. If you
want more than that, you need to create
an extended partition (using one of the 4 primary slots), and then
create logical partitions inside.
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
58 | P a g e
fdisk:
Commands:
#fdisk
/dev/vdb
Command action
a -toggle a
bootable flag b -
compatibility flag d -
delete a partition
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
59 | P a g e
g - create a new empty GPT
l - list known
partition types m-
tion table
disklabel t- change a
partition's system id
Steps:
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
60 | P a g e
#partprobe
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
61 | P a g e
In Redhat-7 default file system was xfs. In ext4,ext3 and ext2 are
default file systems in Redhat 6,5 and 4 respectively.
name> Example:
Mounting:
#mkdir /tempmnt
#mount /dev/vdb1 /tempmnt
Permanent mounting:
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
62 | P a g e
/etc/fstab
name> Example:
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
63 | P a g e
Mounting:
#mkdir /tempmnt
#mount /dev/vdb1 /tempmnt
Permanent mounting:
/etc/fstab
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
64 | P a g e
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
65 | P a g e
In a modern world every Server needs more space day by day for that
we need to expand depending on our needs. A Physical Disk will be
grouped to create a volume Group. Inside volume group we need to
slice the space to create Logical volumes. While using logical
volumes we can extend across multiple disks, logical volumes and we
can reduce logical volumes in size with some commands without
reformatting and re-partitioning the current disk. Volumes can
stripes data across multiple disks this can increase the I/O stats.
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
66 | P a g e
1. Create some partitions with available disk space (in lab /dev/
vdb)
naming as ‘myvg1’)
Partitioning:
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
67 | P a g e
2. #fdisk /dev/vdb
7. In last sector give 4MB extra than size of partition that you
wanted to give. (eg. If you wish to give 1GB(1024MB) size
then give as 1028MB and that 4MB is for lvm metadata.)
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
68 | P a g e
Now we have ‘/dev/vdb1’, create another one or two
partitions(.i.e. /dev/vdb2,/dev/vdb3..) by following above
steps.
myvg1 /dev/vdb3
Creating LVM’s:
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
69 | P a g e
#mkfs.xfs /dev/myvg1/mylv1
#mkdir /part1
#vim fstab
:wq(save&quit).
#mount –a
Extending LVM:
3. #lvdisplay will show the space added. (but space will not be
added to filesystem, we can check that with command ‘#df -
hT’).
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
70 | P a g e
filesystem.
5. #xfs_growfs /dev/myvg1/mylv1
6. Now #df -hT will show the newly extended space. (NOTE: We can
not reduce the size of xfs filesystem partitions or logical
volumes)
2. #lvdisplay
3. #mkfs.ext4 /dev/myvg1/mylv2
4. #mkdir /part2
5. #vim /etc/fstab
:wq
6. #mount –a
3. #lvdisplay (will show but #df –hT will not show added space.)
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
71 | P a g e
and ext4 filesystems. #resize2fs /dev/
myvg1/mylv2
To reduce the size of the LVM typically we should follow below six
steps:
5. #resize2fs /dev/myvg1/mylv2
Removing LVM’s:
3. #mount –a
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
72 | P a g e
4. #lvremove /dev/myvg1/
#vgremove myvg1
Removing PV’s:
SWAP:
The swap space is the hard disk space which is used to supplement
the system RAM by holding idle memory pages. When the kernel runs
out of memory, it can move idle/inactive processes into swap
creating room for active processes in the working memory. This is
memory management that involves swapping sections of memory to and
from virtual memory.
1. #fdisk /dev/sdb
2. Press ‘n’ for new partition
3. Choose ‘p’ for primary partion
4. Choose partition number
5. Press enter key at first sector
6. Give size at last sector
7. Now press ‘t’ to change partition’s system id
Here enter ‘82’ as code bcoz swap identifier code is 82(type ‘l’
to list the types).
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
73 | P a g e
Now we a have partition (/dev/sdb1)
i. #mkswap /dev/vdb1
ii. #swapon /dev/vdb1
iii. #blkid /dev/vdb1 (here copy the generated ‘uuid’)
iv. #vim /etc/fstab
uuid=<paste copied uuid here> swap swap defaults 0 0
:wq
v. #mount –a
bs=1GiB count=1
if=input file
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
74 | P a g e
Follow below steps to Convert this file into Swap space.
Now 1GB /swap_file was converted to Swap space to verify use #free
command.
fallocate - preallocate or
Here A /swapfile called 1GB file created and we can use that file as
swap space by following above procedure we used for /swap_file which
was created by using dd command.
scheduling jobs
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
75 | P a g e
We can automate the process like backup,schedule
updates,synchronization of files like more.cron is a deamon to run
schedule tasks.
syntax:-# crontab -e
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
76 | P a g e
ex:scheduling job at 5:30 everday;
:wq
# crontab -l
# crontab -r
# crontab -u <username> -e
# crontab -u <username> -l
# crontab -u <username> -r
options
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
77 | P a g e
Booting Procedure
booting procedure?
In Linux systems the booting is done in stages.
BIOS :
BIOS stands for Basic Input and Output System. Whenever we power
on the system , the system runs self diagnostic checks and detects
all the connected input and out peripherals. This process is called
POST (Power On Self Test). If any errors found it displays on the
screen. Then BIOS locates the booting disk in the system and
locates and loads the Primary boot loader nothing but MBR (Master
Boot Record) into the memory. So, in simple terms the BIOS loads the
MBR into memory and executes the MBR.
MBR :
MBR stands for Master Boot Record. It is located in the 1st
sector of the bootable disk (it may be /dev/hda or /dev/sda).
The size of the MBR is 512 bytes and it contains three components.
(i) Primary boot loader information and its size is 446 bytes.
(ii) Partition table information and its size is 64 bytes.
(iii) MBR validation check and its size is 2 bytes. Its main
purpose is whether the MBR is valid or not.
The primary boot loader contains the secondary boot loader
nothing but GRUB or LILO (in old systems).
Then primary boot loader locates and loads the secondary boot
loader into memory.
So, in simple terms the MBR loads and executes the GRUB boot
loader.
GRUB or LILO :
GRUB stands for Grand Unified Boot loader. LILO stands for Linux
Loader and is used in old Linux systems. If we have multiple kernel
images installed in our system, we can choose which one to be
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
78 | P a g e
executed. GRUB displays a splash screen, waits for few seconds. If we
do not enter anything, it loads the default kernel image as specified
in the grub configuration file. GRUB has the knowledge of the
file system (the old LILO didn't understand the system). GRUB
configuration file is /boot/grub/grub.conf (/etc/grub.conf is a
link to this). This file contains kernel and initrd images. So,
in simple terms GRUB just loads and executes kernel and initrd images.
Kernel :
Kernel initialises itself and loads the kernel modules and mounts
the root file system as specified in the "root=" in grub.conf and then
kernel executes the /sbin/init program. Since init was the 1st
program to be executed by Linux kernel, it has the process ID (PID)
of 1. We can see this id by # ps -ef | grep init command.
initrd stands for initial RAM Disk. initrd is used by kernel as
temporary file system until kernel is booted and the real root the
file system is mounted. It also contains necessary drivers compiled
inside which helps it to access the hard drive partitions and other
hardware.
init level :
In this init program reads the /etc/inittab file and put the
system into specified run level. init identifies the default run
level from /etc/inittab file and we can change the this default
run level whenever we needed. We can find the default run level
by # grep "initdefault" /etc/inittab command on our system.
Normally the
default run level in Linux is 3 in CLI (Command Line
Interface) mode and 5 in GUI (Graphical User Interface) mode.
Run Level Programs :
The following run levels are available in Linux systems.
0 -----> halt or shutdown the system
1 -----> Single user mode
2 -----> Multi user without NFS
3 -----> Full multi user mode but no GUI and only CLI mode
4 -----> Unused
5 -----> Full multi user mode with GUI (X11 system)
6 -----> reboot the system
Whenever we start the Linux system is booting we can see various
services getting started. Those services are located in different
run levels programs executed from the run level directory as defined
by our default run level. Depending on our default init level
setting, the system will execute the programs from one of the
following directories.
Run level 0 -----> /etc/rc.d/rc0.d
Run level 1 -----> /etc/rc.d/rc1.d
Run level 2 -----> /etc/rc.d/rc2.d
Run level 3 -----> /etc/rc.d/rc3.d
Run level 4 -----> /etc/rc.d/rc4.d
Run level 5 -----> /etc/rc.d/rc5.d
Run level 6 -----> /etc/rc.d/rc6.d
The above directories are also having symbolic links available
for those directories under /etc/rc0.d, /etc/rc1.d, ....etc., So,
the /etc/rc0.d is linked to /etc/rc.d/rc0.d
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
79 | P a g e
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
80 | P a g e
First open the /etc/inittab file by # vim /etc/inittab
command and go to last line change the run level number as we required
and then reboot the system by # init 6 command. After rebooting
the system check the current run level by # who -r command.
Controllers
IBM Power
HMC Hardware Management Console
series
HP ILO Integrated Light Out
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
81 | P a g e
Package Management:-
RPM:
Rpm is a powerful Package Manager for Red Hat Linux. It can be
used to build, install, query, verify, update, and remove/delete
individual software packages. A Package consists of an archive of
files, and package information, including name, version, and
description. But using with rpm it will install only Packages but not
all Dependencies. And no need to create any repository file.
Options:
v – verbose
h – hash able
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
82 | P a g e
qi – querying information
Note: Full Package name required and will not get any confirmation
for that use (vh) options
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
83 | P a g e
Syntax : rpm -ivh <Package-name> --nodeps
To remove Package
YUM
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
84 | P a g e
Yum configuration file /etc/yum.repos.d
To install package
Syntax:yum update
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
85 | P a g e
To know the information of the package
Syntax:yum repolist
#cd /etc/yum.repos.d
#ls
Ex: #yum-config-manager–-add-
repo=”http://content.example.com/rhel7.0/x86_64/dvd”
# vim content.example.com.repo
<eof>
gpgcheck=0
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
86 | P a g e
:wq
# yum update
# yum repolist
# vim mist.repo
[repoid]
name=mist repo
baseurl=http://content.example.com/rhel7.0/x86_64/dvd
enabled=1
gpgcheck=0
:wq
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
87 | P a g e
Managing services and Daemones
Services:
Daemons:
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
88 | P a g e
Syntax:# systemctl <command> <service-name.service>
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
89 | P a g e
Ex:#systemctl is-enabled httpd.service
Restart: If restart any service the service should be off and on. It
means it will kill old process id(pid) and generates new process id to
that service.
Process Management
# ps
Syntax:# ps -u <username>
Example:# ps -u root
Syntax: # ps -g <groupname>
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
90 | P a g e
Example:# ps -g mistgrp
# ps -aux | less
# ps -ef
# ps -elf
# kill -l
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
91 | P a g e
Zombie process?
top command
top is a command to see the processes states and statuses
information continuously until we quit by pressing " q ". By
default top command will refresh the data for every 3 seconds.
When we need to see the running processes on our Linux in real
time, the top command will be very useful. Besides the running
processes the top command also displays other information like free
memory both physical and swap.
The first line shows the current time, "up 1 day" shows how
long the system has been up for, "3 user" how many users login,
"load average : 0.01, 0.00, 0.23" the load average of the system
1, 5 and 15 minutes.
The second line shows the no of processes and their current
states.
The third line shows CPU utilization details like % of the
users processes, % of the system processes, % of available CPU and
% of CPU waiting time for I/O (input and output).
The fourth and fifth lines shows the total physical memory
in the system, used physical memory, free physical memory, buffered
physical memory, the total swap memory in the system, used swap
memory, free swap memory and cached swap memory, ... etc.,
From sixth line onwards the fields are as follows.
PID Process ID
USER Owner of the process ie., which user executed that process
PR Dynamic Priority
NI Nice value, also known as base value
VIRT Virtual size of the task includes the size of processes
executable binary
RES The size of RAM currently consumed by the task and not
included the swap portion
SHR Shared memory area by two or more tasks
S Task Status
% CPU The % of CPU time dedicated to run the task and it is
dynamically changed
% MEM The % of memory currently consumed by the task
TIME+ The total CPU time the task has been used since it started.
+ sign means it is displayed with hundredth of a
second granularity. By default, TIME/TIME+ does not account the
CPU time used by the task's dead children
COMMAND Showing program name or process name.
* While running the top command, just press the following keys
woks and the output will be stored in real time.
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
92 | P a g e
1 -----> 2nd CPU information Shift + > -----
>Page up
h ----->Help Shift + < -----> Page
down
Enter -----> Refresh immediately n ----->
Number of tasks
k -----> Kill the process u -----
>user processes
M -----> Sort by memory usage P ----->
Sort by CPU usage
T -----> Sort by cumulative time z -----
>Color display
r -----> To reschedule the priority by renice d -----
>Change the delay time (refresh time)
b -----> Highlight the running process W -----
>Write the information in /root/.toprc file
q -----> quit the top command
The status of the processes :
r -----> Running process s ----->
Sleeping process
z -----> Zombie process T ----->
Stopped process
D -----> Uninterrupted sleeping process R < -----
>High priority
N > ----> Low priority o ----->
Orphan process
+ -----> Foreground process ? ----->
Background process
# renice -n 10 5453 (to change the
specified running process priority on line)
# nice -n -15 firefox (to start the
firefox process with priority level -15)
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
93 | P a g e
# sosreport
This command will normally complete within a few minutes.
Depending on local configuration and the options specified in some
cases the command may take longer to finish. Once completed, sosreport
will generate a compressed a file under /tmp folder. Different
versions use different compression schemes (gz, bz2, or xz). The file
should be provided to Redhat support representative (normally as an
attachment to an open case).
Note: sosreport requires root permissions to run.
Different Options used in sosreport command :
The sosreport command has a modular structure and allows the user
to enable and disable modules and specify module options via the
command line. To list available modules (plug-ins) use the following
command:
# sosreport -l
To turn off a module include it in a comma-separated list of
modules passed to the -n/–skip-plugins option. For instance to
disable both the kvmand amd modules:
# sosreport -n kvm,amd
Individual modules may provide additional options that may be
specified via the -k option. For example on Red Hat Enterprise Linux
5 installations the sos rpm module collects "rpm -Va" output by
default. As this may be time-consuming the behaviour may be disabled
via:
# sosreport -k rpm.rpmva=off
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
94 | P a g e
* Ping is not used any port number. It is used ICMP
(Internet Control Message Protocol) only.
Security Levels
SELinux
Iptables
Firewalls
Tcp Wrappers
SELinux:
Managing SELinux
What is SELinux?
It is a one type of security that enhances the security that
allows users and administrators more control over which users and
applications can access which resources, such as files, Standard Linux
access controls etc.,
It is mainly used to protect internal data (not from external
data) from system services. In real time SELinux is disabled and
instead of this IP tables are used. It protects all the services,
files and directories by default if SELinux is enabled.
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
95 | P a g e
In how many ways we can implement the SELinux? Explain them.
We can implement the SELinux mainly in 2 modes.
(i) Enabled
(ii) Disabled (default mode)
Enabled :
Enabled means enabling the SELinux policy and this mode of
SELinux is divided into two parts.
(a) Enforcing
(b) Permissive
Disabled :
Disabled means disabling the SELinux policy.
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
96 | P a g e
# vim /etc/sysconfig/selinux -----> It is a link file to
the above file.
# vim /var/log/audit/audit.log -----> SELinux log messages
will be stored in this file.
command to see the SELinux mode?
# getenforce (to check the SELinux mode)
command to set the SELinux mode temporarily?
# setenforce 0 or 1 (to set the SELinux mode. Where ' 0
' -----> permissive and ' 1 ' -----> Enforcing)
Note :
(i) To change the SELinux mode from Permissive to Enforcing or
Enforcing to Permissive modes the system restart is not required.
(ii) To change Enforcing mode to Disabled mode or Disabled mode
to Enforcing mode the system restart is required.
(iii) The above commands are changed the SELinux mode temporarily
only.
To make the selinux changes permanently then open
/etc/selinux/config and go to ,
SELINUX=Enforcing or Permissive or Disabled
(save and exit this file)
command to see the SELinux policy details?
# sestatus (to see the SELinux policy details)
Other useful commands :
# ls -Z <file name> (to see the SELinux context of
the file)
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
97 | P a g e
NIC card:
A Network Interface Card or controller is hardware component
that connects a computer to a computer network. Each NIC card will
be having MAC (Media Access Controller) address to avoid conflicts
between same NIC adapters. In Linux these NIC adapter is
represented by the word "eth" . For example if two NIC cards are
there in a system then it will be denoted as
"eho","eth1", .....etc.,
media:
Media is nothing but cable to connect two or systems. Example :
RJ 45, CAT 5 and CAT 6, ....etc.,
topology:
Topology is a design in which the computers in network will be
connected to each other. Example for topologies are Bus, Ring, Star,
Mesh, Tree topologies.
Protocol:
A Network Protocol defines rules and conventions for
communication between the network devices. Protocols are generally
use packet switching techniques to send and receive messages in the
form of packets.
Example for protocols are TCP/IP (Transmission Control
Protocol and Internet Protocol), UPD (User Datagram Protocol)
and HTTP (Hyper Text Transfer Protocol), ....etc.,
Differences between TCP/IP and UDP protocols?
TCP/IP UDP
Transmission Control Protocol User Datagram Protocol
It is connection oriented It is connection less
Reliable Non-Reliable
TCP Acknowledgement will be sent / received No Acknowledgement
Slow communication Fast communication
Protocol No. for TCP is 6 Protocol No. for UDP is 17
HTTP, FTP, SMTP, ....etc., uses TCP DNS, DHCP, ....etc., uses UDP
IP address:
Every Computer will be assigned an IP address to identify each
one to communicate in the network. The IP address sub components are
Classes of an IP address, Subnet masks and Gateway.
Classes of IP address :
The IP addresses are further divided into classes. The classes
are A, B, C, D, E and the ranges are given below.
Classless
Default Subnet Inter
Class Start End
mask Domain
Routing
Class A 0.0.0.0 127.255.255.255 255.0.0.0 /8
Class B 128.0.0.0 191.255.255.255 255.255.0.0 /16
Class C 192.0.0.0 223.255.255.255 255.255.255.0 /24
Class D 224.0.0.0 239.255.255.255
Class E 240.0.0.0 255.255.255.255
Loopback address?
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
98 | P a g e
A special IP number (127.0.0.1) is designated for the software
loopback interface of a machine. 127.0.0.0 and 127.255.255.255 is
also reserved for loopback and is used for internal testing on local
machines.
Multicasting:
Multicasting allows a single message to be sent to a group of
recipients. Emailing and Teleconferencing are examples of
multicasting. It uses the network infrastructure and standards to send
messages.
Subnet mask:
A subnet mask allows the users to identify which part of an IP
address is reserved for the network and which part is available for
host use.
Gateway:
A Gateway is the network point that provides entrance into
another network. On the internet a node or stopping point can be
either gateway node or a host (end point) node. Both the computers of
internet users and the computer that serve the pages to users are
host nodes. The computer that control traffic within your company's
network or at our local internet service provider (ISP) are the
gateway nodes.
Omportant configuration files in network configuration:
# cat /etc/sysconfig/network (This file keeps the information
about the hostname assigned to the system and
if we want to change the hostname permanently, we need to change the
hostname in this file)
# cat /etc/sysconfig/network-scripts/ (This directory keeps
the configuration of network devices connected
to the system. Examples are ifcfg-eht0, ifcfg-
eth1, ifcfg-eth2, .....etc.,)
# cat /etc/hosts (This file is responsible for resolving
hostname into IP address locally. ie., local DNS if DNS
server
is not available)
# cat /etc/resolve.conf (This file keeps the address of the
DNS server to which the clients will be accessing to
resolve IP address to hostname and
hostname to IP address)
Differences between MAC and IP addresses:
MAC Address IP Address
It is a temporary address. So,
It is a permanent address. So we cannot
we can change this address any
change this address.
no. of times.
It stands for Media Access Control Address. Internet Protocol address.
It is a physical address. It is a logical address.
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
99 | P a g e
It is two types.
IPV4 :(It is divided into 4
parts )
--- . --- . --- . --- (each 8
bits. So, 8 X 4 = 32 bits
It is divided into 6 parts.
IPV6 : ( It is divided into 16
--- : --- : --- : --- : --- : --- (each 8
parts )
bits. So, 8 X 6 = 48 bits
--- . --- . --- . --- . --- .
--- . --- . --- . --- . --- .
--- . --- . --- . --- . --- .
--- (each 8 bits. So, 8 X 16 =
128 bits.
# ifconfig (to see
ifconfig (to see the MAC address)
the IP address)
Types of NIC cards available:
(a) eth0 (1st NIC card)
(b) eth1 (2nd NIC card)
(c) br0 (Bridge -----> used for communication from physical
to virtual)
(d) lo (loopback device name and IP address is 127.0.0.1)
# ifconfig (to see all the NIC devices connected to the
system)
Types of cable connections available:
(i) Cross cable (to connect two systems directly)
(ii) Straight cable (to connect more systems with the help of
switch)
# ethtool <device name> (to check the network cable is
connected or not)
# miitool <device name> (It is also used to check the
network cable but it will not supports RHEL - 7 and
only supports RHEL - 6 and it also works on physical system only not
on virtual system)
ways we can configure the network
There are two ways to configure the network.
(a) Static Network.
(b) Dynamic Network.
Static Network :
In this way we assign the IP address and hostname manually. Once
we configure the IP address, it will not change.
Dynamic Network :
In this way we assign the IP address and hostname dynamically.
This means the IP address will change at every boot.
Assign the static IP address to the NIC card?
In RHEL - 6 :
# setup
(Move the cursor to Network configuration and press Enter key)
(Move the cursor to Device configuration and press Enter key)
(Select the NIC adapter ie., eth0 and press Enter key)
(Assign the above IP address and other details as per our
requirements and move the cursor to "OK" and press
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
100 | P a g e
Enter
key)
(Move the cursor to "Save" to save the changes in device
configuration and press Enter key)
(Once again move the cursor to "Save & Quit" button and press
Enter key)
(Finally move the cursor to "Quit" button and press Enter key
to quit the utility)
(Then restart the network service and check for the IP address by
# service network restart command)
(If the change is not reflected with the above service, then
restart the network manager by
# service
NetworkManager restart command)
# ifconfig (to see the IP address of the NIC card)
# ping < IP address > (to check whether the IP is
pinging or not)
In RHEL - 7 :
# nmcli connection show (to see all the network
connections)
# nmcli device show (to see the network details if
already configured manually or dynamically)
# nmcli connection add con-name "System eth0" ifname eth0
type ethernet (to add the network connection)
# nmcli connection modify "System eth0" ipv4.addresses ' <
IP address >/< netmask >< gateway > ' ipv4.dns < dns
server IP address > ipv4.dns-search < domain name> ipv4.method
<static or manually> (to assign IP address, gateway, dns,
domain name and configure the network as static or manually)
# nmcli connection up "System eth0" (to up the
connection)
# systemctl restart network (to restart the
network service)
# systemctl enable network (to enable the
network service)
# ifconfig (to see the IP address of
the NIC card)
# ping < IP address > (to check whether the
IP is pinging or not)
Differences between RHEL - 6 and RHEL - 7 network configuration files
RHEL - 6 RHEL - 7
/etc/sysconfig/network-scripts
/etc/sysconfig/network-scripts is the
is the directory which contains
directory which contains the NIC
the NIC configuration
configuration information.
information.
/etc/sysconfig/network-scripts/
/etc/sysconfig/network-scripts/ifcfg-
ifcfg-<device name> is the
<device name> is the file which
file which contains the NIC
contains the NIC configuration details.
configuration details.
/etc/resolve.conf is the file which /etc/resolve.conf is the
contains DNS server IP and domain name file which contains DNS server
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
101 | P a g e
location. IP and domain name location.
/etc/sysconfig/network is the /etc/hostname is the
hostname configuration file. hostname configuration file.
/etc/hosts is the file
/etc/hosts is the file which
which contains the local DNS
contains the local DNS server IP address.
server IP address.
RHEL - 7 :
# hostname <fully qualified domain name> (to set
the hostname temporarily)
# hostnamectl set-hostname <fully qualified domain name>
(to set the hostname permanently)
# systemctl restart network (to update
the hostname in the network)
# systemctl enable network (to enable the
connection at next reboot)
troubleshoot if the NIC is notworking
(a) First check the NIC card is present or not by # ifconfig
command.
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
102 | P a g e
(b) If present thencheck the status of the NIC card is enabled
or disabledby click on System menu on the status bar, then select
Network Connections menu.
(c) Click on IPV4 settings tab, select the device eth0 or any
other and select Enable button, then Apply and OK.
(d)Open /etc/sysconfig/network-scripts/ifcfg-eth0 file check
Userctl=yes or no. If it is yes make it as no, then check
Onboot= yes or no. If it is no make it as yes and save that file.
(e) If not present thencheck the status of the NIC card is
enabled or disabled by click on System menu on the status
bar, then select Network Connections menu.
(f) Click on IPV4 settings tab, select the device eth0 or any
other and select Enable button, then Apply and OK.
(g) Using # setup (in RHEL - 6) or # nmcli (in RHEL - 7)
commands assign the IP address to the system and restart the
network service by # service network restart (in RHEL - 6) or #
systemctl restart network (in RHEL - 7) commands and
enable the service at next reboot by # chkconfig network on (in
RHEL - 6) or # systemctl enable network (in RHEL - 7)
commands.
(h) Then up the connection by # ifconfig eth0 up (in RHEL -
6) or # nmcli connection up <connection name> commands.
(i) Even though it is not working may be the fault in NIC card.
If so, contact the hardware vendor by taking the permissions from
higher authorities.
/etc/resolve.conf
It contains the details of nameserver, i.e., details of your
DNS server which helps us connect to Internet.
/etc/hosts file
To map any hostname to its relevant IP address.
command to check all the open ports of your machine
#nmap localhost
command to check all the open ports of remote machine
# nmap <IP address or hostname of the remote system>
command to check all the listening ports and services of your machine
# netstat -ntulp
make a service run automatically after boot
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
103 | P a g e
# chkconfig <service name> on
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
104 | P a g e
# ethtool <NIC device name> (to check the network
cable is connected or not)
# miitool <NIC device name> (It is also used to
check the network cable but it works on
physical system not on virtual system and supports in RHEL - 6
only)
# ip addr show (to show all NIC devices
present on the system)
# hostname (to see the hostname with fully
qualified domain name)
# hostname -i (to see the IP address of the system)
# hostname -d (to check the domain name of the
system)
# hostname -s (to check the hostname without domain
name)
# netstat -r (to check the default gateway and
routing table)
# route (to check the default gateway with
routing table)
# ip route (to display the NIC device with
default gateway)
# dig or # host or #nslookup (all are used to
resolve the name to IP and IP to name)
# nslookup <IP address> (to resolve IP to name)
# nslookup <hostname> (to resolve name to IP)
# host <IP address> (to resolve IP to name)
# host <fully qualified domain name> (to resolve name to
IP address)
# dig -x <IP address> (to resolve IP address to name)
# dig <fully qualified domain name> (to resolve name to
IP address)
# nmcli (Network Manager Command Line Interface used to
configure the network setup in RHEL - 7)
# setup (to setup the static
network in RHEL - 2, 3, 4, 5 and 6)
# nmtui (to setup the static
network in GUI mode for RHEL - 7)
# nmcli device show (It displays all the NIC devices
network information of the system )
# nmcli device show eth0 (to see all the
network devices information of the eth0)
# nmcli connection or nmcli connection show (to see all the
network connection names)
# nmcli connection add con-name <connection name> ifname <NIC
device name> type ethernet
(to create a new connection
name for eth0)
# nmcli connection show --activate (it shows which
connection is active currently)
# nmcli connection add con-name <connection name> ifname
<NIC device name> type ethernet
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
105 | P a g e
(to add a connection name
to NIC device)
# nmcli connection modify <connection name> ipv4.addresses '
<IP address>/<netmask><default gateway> '
ipv4.dns <dns server IP address> ipv4.dsn-search
<domain name> ipv4.method <static/manual>
(to modify the connection as static and assign
the IP, gateway, dns IP, domain name)
# nmcli connection delete <connection name> (to delete the
specified connection)
# nmcli connection modify <connection name> ipv4.method
<static/manual> (to modify dynamic connection
to static connection)
# nmcli connection up <connection name> (to activate or
up the specified connection)
# nmcli connection down <connection name> (to disable or down
the specified connection)
# nmcli connection show <connection name> (to see the
information about the specified NIC device)
# ping -I <NIC device name><IP address> (to check the
connection from NIC device to IP address)
# hostname <fully qualified domain name> (to set the hostname
temporarily)
# hostnamectl set-hostname <fully qualified domain name>
(to set the hostname permanently in RHEL - 7)
NOTE: Whenever we change any parameters in
/etc/sysconfig/network-scripts/ifcfg-<NIC device name> file, then we
have to reload that file and again we have to up the connection
(nothing but activate the connection by # nmcli connection reload
command.
# nmcli connection reload (to reload the configuration of
the connection if any changes on it and it reloads all
configuration
files)
# nmcli connection reload /etc/sysconfig/network-scripts/ifcfg-
<NIC device name> (to reload a single file)
# hostnamectl status (it displays full details of
the hostname and works in RHEL - 7 only)
# nmcli networking off (to disable all the
connections at a time)
# nmcli device status (to display all NIC device
connections statuses)
# nmcli connection modify <connection name> + ipv4.dns
<secondary dns server IP> (to add a secondary
dns server IP to the existing
connection)
# netstat -ntulp (to check how many
open ports are there in local system)
# ss -ntulp ( "
" )
# nmap (to check how many open
ports are there in remote system)
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
106 | P a g e
# tracepath (it displays the routing
information)
# miitool <NIC device name> (to check the network
cable is connected or not)
# ethtool <NIC device name> ( "
" )
# ifconfig (to check the NIC card is
enable or not)
# ifup <NIC device name> (to enable or up the
NIC card)
#ifdown <NIC device name> (to disable or down the NIC
card)
# route -n (to check the
gateway)
# cat /etc/resolve.conf (to check the dns
server information)
# cat /etc/sysconfig/network-scripts/ifcfg-<NIC device name>
(to see the NIC device information)
# hostname or cat /etc/sysconfig/network (to check the
hostname in RHEL - 6)
# hostnamectl status or cat /etc/hostname (to check the
hostname in RHEL - 7)
# ping <IP address> (to check the connection
communication)
# chkconfig --list (to list all the services
which are running at boo time in RHEL - 6 & 7)
# systemctl list-unit-files (to list all the
processes which are running at boot time in RHEL - 7)
# chkconfig --level <service name> (it will set the
service at run level 3 when the system is booting)
# service --status-all (to see the list of all the
processes which are currently running)
# ls /etc/init.d (is the location of all the
services and deamons in RHEL - 6)
# ls /usr/lib/systemd/system (is the location of all the
services and deamons in RHEL - 7)
# /etc/rc.local (is the last script to be run
when the system is booting)
(If we enter as sshd stop at the last line of the
script file then sshd will be stopped even though that
sshd is
enabled)
# service sshd status (to check the sshd status)
# service --service -all (to see the process ID of
all the services)
# netstat -ntulp (to see all the services
with port no., status, process ID and all open
ports in local system, routing table and NIC device
information)
-n -----> port no. (numeric no) -t -----
>tcp protocol
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
107 | P a g e
-u -----> upd protocol -l
-----> port
is listening or not
-p -----> display the process ID
# netstat -r (to see all routing table
information)
# netstat -i (to see all the NIC cards
information)
# nmap (to see the network mapping
ie., open ports list on remote system)
Note : By default this command will not available. So, first
install the nmap package by # you install nmap -y
# nmap <remote system IP address> (to see all the services
which are running in the specified remote system)
# nmap <remote IP 1><remote IP 2><remote IP 3> (to see the
running services on specified remote systems)
# nmap 172.25.0.11 - 50 (to see the running service
on 172.25.0.11 to 172.25.0.50 systems)
# nmap -p 80 <remote IP> (to see the http port is running
or not on specified remote system)
# nmap -p 80 - 90 <remote IP> (to see port no's 80 to
90 are running or not on remote systems)
# nmap -sp 172.25.0.0/24 (to see all the systems which
are in upstate ie., 172.25.0.1, 172.25.0.2,
(where s -- scan & p -- ping)
172.25.0.3, ......upto 172.25.0.254 systems)
Open a file, write all the systems IP addresses, save & exit the
file. Example has given below,
# vim coss
172.25.2.50
172.25.3.50
172.25.4.50 ....etc., (save and exit this file)
# nmap -iL coss (to scan all the IP addresses by
reading the coss file)(where -i ----> input, -L ----> list)
# nmap --iflist (to see all the routing table
information in the network)
# nmap 172.25.0.10 - 20 --exclude 172.25.0.15 (to scan
all the systems from 172.25.0.10 to 172.25.0.20
systems and excluding 172.25.0.15
system)
# nmcli connection show --active (to control the
network connections)
# ip link (to check the network
connection)
# ping -I eth1 <IP address> (to check the 2nd NIC
card connection)
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
108 | P a g e
SSH :
5. To use SSH you need to deploy SSH Server and SSH Client program respec-
tively.
8. OpenSSH encrypt data before sending it over insecure network like inter-
net.
11. OpenSSH replace Telnet and rlogin with SSH, rcp with scp, ftp with sftp.
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
109 | P a g e
LAB WORK:
ON SERVER:
Enabling firewalls
# ping 172.25.1.11
# ssh 172.25.1.11
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
110 | P a g e
example one person has to manage more than 10 systems at a time. In this
situation admin
has to transfer some files from one system to another 9 systems or vice versa,
for every
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
111 | P a g e
login on remote system it will prompt for password. Even for transferring
files for every
Above situation will be very annoying for system admin to type password
for every step.
Therefore SSH provides a best way to escape password prompting every now and
then.
By generating SSH keys, a public key and a private key, an admin can
copy the public key
into other system and done, it will work as authorized access from the admin’s
system. Now
whenever we are logging from admin’s system to other system in which we have
stored the
public key of admin’s system, it will not prompt us for password and we can
login to that
system as many time as we want without being prompt for the password.
Public key cryptography uses a public key to encrypt data and a private
key to decrypt it.
LAB WORK:
Generating SSH key pair
# ssh-keygen
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
112 | P a g e
After generating keys by using #ssh-keygen these keys will store under
user’s home directory in a hidden directory “ .ssh”.
#cd /root
# ls -a
.ssh
# cd /root/.ssh/
The “ id_rsa” is a private key and “id _rsa.pub” is the public key which
will be used later to make
In client machine:
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
113 | P a g e
On Server machine
On server :
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
114 | P a g e
Lab Work:
To restrict any user or group we need add them into the ssh configuration
file.(/etc/ssh/sshd_config).
#vim /etc/ssh/sshd_config
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
115 | P a g e
Restricting client:
With firewall:
#fiirewall-cmd --permanent --add-rich-rule='rule family="ipv4"
source address="172.25.1.11" service name="ssh" reject'
# firewall-cmd --reload
TCP WRAPPERS:
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
116 | P a g e
On Client machine:
scp stands for secure cp (copy), which means that you can copy files across
an ssh
connection that will be encrypted, and therefore secured. As scp will be using
ssh protocol
location to another.
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
117 | P a g e
On server: copying a file
To copy/transfer a directory
# mkdir data
# cd data
# touch a b c d
machine to another machine, and for keeping the two machines "in sync." It's
designed to
speed up file transfer by copying the differences between two files rather
than copying an entire file
every time.
For example, Assume that we are suppose to take the backup of a system and
copy the same to
another system. For first time we will copy entire directory, but every day if
we copy entire directory
it will kill lots of time. In such situation if rsync is used it will only
copy the updated files/directories
rather than copying all files/directories inside main directory, which saves
lots of time and speedup
the transfer
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
118 | P a g e
Transferring files:
Transferring Directories:
#mkdir data
#cd data
# touch a b c d a{11..20}
-r to transfer directories.
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
119 | P a g e
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
120 | P a g e
INSTALLATION:
# firewall-cmd --reload
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
121 | P a g e
# vim /etc/vsftpd/vsftpd.conf
# getenforce
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
122 | P a g e
# setsebool -P ftp_home_dir on
# setsebool -P ftp_anon_write on
# setsebool -P ftpd_full_access on
# cd /var/ftp/pub/
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
123 | P a g e
On Client Machine:
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
124 | P a g e
ftp> cd pub
ftp> ls
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
125 | P a g e
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
126 | P a g e
To check “! ls”
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
127 | P a g e
NFS stands for Network File System, and is a way to share files
between machines as if they were on your local hard drive. Linux
can be both an NFS server and an NFS client, which means that it
can export filesystems to other systems, and mount filesystems
exported from other machines.
For example NFS server could be a Linux system and Unix could be
a client. But it can’t be a
window system because window is not NFS compatible. The NFS server
exports one or
more directories to the client systems, and the client systems mount
one or more of the
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
128 | P a g e
I/O operations are written back to the server, and all clients notice
the change as if it
Package : nfs-utils
Daemons : nfs-server (nfsd in RHEL 6,5,4)
Port number : 2049
Configuration File : /etc/exports
Step2: Create a dir or directory on partition and add some data in it.
Step3: Export the directory by editing /etc/exports file and using exportfs
command
#rpm –q nfs-utils
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
129 | P a g e
Step2: Create a directory or create a partition and mount it and make a mount
point and add data to it.
Step3: Export the directory by editing /etc/exports file and using exportfs
command. Edit the /etc/exports file
#vim /etc/exports
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
130 | P a g e
To give permission to only one node, just give the IP ADDR Of that node (ex:
172.25.1.11)
Command completes
Something crashes)
#exportfs -avr
‘a’ for exporting, ‘v’ for verbose, ‘r’ for re-exporting all
directories
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
131 | P a g e
On Client
Temporary mounting
Permanent mounting
Automounting
Temporary Mounting:
We can mount nfs temporarily, but a system reboot will make that
nfs mount unavailable.
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
132 | P a g e
Permanent Mounting:
Automounting
Autofs automatically mounts file systems for you when they are
requested. This has a
very handy feature: It's great for handling removable media. Just CD
to the right directory,
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
133 | P a g e
mounts it.
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
134 | P a g e
Now restart the autofs.
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
135 | P a g e
We configured /private as read-only(ro) and /public as read-
write(rw).
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
136 | P a g e
SAMBA
Daemons : smb
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
137 | P a g e
#mkdir /share
Now we have to change the SELinux context values of our created di-
rectory ‘/share’ from default to samba by using ‘semanage fcontext
command’ and to make this effective we need to run another command
called ‘restorecon’ (in previous versions it is ‘chcon’).
#ls -ldZ /share (to check context of our directory.)
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
138 | P a g e
Step3: Create a user or use any existing user who will be allowed to
log in as samba user, add that user to samba user.
# useradd feroz
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
139 | P a g e
#vim /etc/samba/smb.conf
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
140 | P a g e
It will prompt for user name and passwd, give samba user and passwd
and click on OK.
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
141 | P a g e
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
142 | P a g e
MariaDB
MariaDB Server is one of the most popular database servers in the world. It’s
made by the original developers of MySQL and guaranteed to stay open source.
Server Profile:
Packages: mariadb,mariadb-server,mariadb-libs
Keypoints:
Firewalls:
# firewall-cmd - -permanent - -add-service=mysql
# firewall-cmd - -reload
Enable and Start MySQL service:
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
143 | P a g e
# mysql_secure_installation
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
144 | P a g e
Creation of tables
> create table <tablename> followed by rows and columns along with the
sizes and field names
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
145 | P a g e
Creating users:
Giving privileges to the normal users that we created over the the data-
base mistdb;
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
146 | P a g e
Connecting to our database with normal user “red” who have all permis-
sions over our database.
# mysql -u red –p
User ‘red’ have all privileges over mistdb database so ‘red’ can update
new data to our table.
Now connect with another user ‘blue’ who have only ‘select’ privilege.
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
147 | P a g e
User ‘blue’ can not insert data in the tables except reading data.
On server2
3. Install mariadb package and run following command to connect to mari-
adb server over the network.
4. # mysql -u <username> -h <host ip or hostname> -p
5. #mysql -u feroz –h 172.25.1.10 -p
Enter password to connect to remote database server.
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .
148 | P a g e
==============================================================================
==============================================================================
====
MIST TECHNOLOGIES, #606, Annapurna Block, Aditya Enclave, Ameerpet, Hyderabad- 500038,
Phone: +91-40-66661975, Mobile : 9032001975
Email : info@mistltd.com, Email : training@mistltd.com, Url : www.mistltd.com .