OSA Manual
OSA Manual
Certificate
This is certified to be the bonafide work of the student in the Operating System and Administration –
20CS42P Laboratory during the academic year 202 – 202
Course Coordinator
Examiner Signature
1.
2.
List of Experiments
5 Process Synchronization
6 Memory Management
7 Shell Programming
9 Network Management
10 User Authentication
13 Storage Management
An Operating system (OS) is system software that manages computer hardware, software resources, and
provides common services for computer programs. In other words, an Operating System (OS) is software that
acts as an interface between computer hardware components and the user.
1. Types of OS installation
Attended installation:
An installation process usually needs a user who attends it to make choices, such as accepting or
declining an end-user license agreement (EULA), specifying preferences such as the installation
location, supplying passwords or assisting in product activation.
In graphical environments, installers that offer a wizard-based interface are common.
Attended installers may ask users to help mitigate the errors.
o For example, if the disk in which the computer program is being installed was full, the
installer may ask the user to specify another target path or clear enough space in the disk.
Silent installation:
An installation that does not display messages or windows during its progress.
"Silent installation" is NOT the same as "unattended installation". [All silent installations are
unattended but not all unattended installations are silent.]
In bigger organizations where thousands of users work, deploying the applications becomes a typical
task and for that reason silent installation is performed so that the application is installed in background
without affecting the work of user.
Unattended installation:
An installation that is performed without user interaction during its progress or with no user present
at all.
One of the reasons to use this approach is to automate the installation of a large number of systems.
An unattended installation either does not require the user to supply anything or has received all
necessary input prior to the start of installation. Such input may be in the form of command line
switches or an answer file, a file that contains all the necessary parameters.
o For example, if the installation medium was faulty, the installer should fail the installation, as
there is no user to fix the fault or replace the medium. Unattended installers may record errors
in a computer log for later review.
Headless installation:
Installation performed without using a computer monitor connected.
In attended forms of headless installation, another machine connects to the target machine (for
example, via a local area network) and takes over the display output.
Clean installation:
A clean installation is one that is done in the absence of any interfering elements such as old versions
of the computer program being installed or leftovers from a previous installation.
The clean installation of an operating system is an installation in which the target disk partition is
erased before installation.
Since the interfering elements are absent, a clean installation may succeed where an unclean
installation may fail or may take significantly longer.
AITM Polytechnic, Belagavi Dept Of Computer
Science
Operating Systems and Administration-20CS42P
Network installation:
Network installation (netinstall), is an installation of a program from a shared network resource that may be
done by installing a minimal system before proceeding to download further packages over the network.
This may simply be a copy of the original media but software publishers which offer site licenses for
institutional customers may provide a version intended for installation over a network.
2. Boot methods
Booting is the process of starting a computer as initiated via hardware such as a button or by a software command.
Types of Booting:
Warm Booting: The Warm Booting is that in which system starts from the starting or from initial
state means.
o In the Warm Booting the system will be started from its beginning state means, first, the user
will press the Power Button, then this will read all the instructions from the ROM and the
Operating System will be automatically gets loaded into the System (RAM).
Cold Booting: The Cold Booting is that in which System automatically starts when the system is in a
running state.
o For example, due to Light Fluctuation, the system will automatically restarts. In this, chances
of damaging of system are more. The system will now be start from its initial state, so some
files may be damaged because they are not properly stored into the system.
disks since when OS X came on the market. Also, HFS-formatted drives are not recognized by
Windows computers as HFS is a Macintosh format. With the help of WIN32 or NTFS file systems, Windows
hard drives are formatted.
NTFS: NTFS is the file system, which stands for NT file system and stores and retrieves files on
Windows NT operating system and other versions of Windows like Windows 2000, Windows XP,
Windows 7, and Windows 10. Sometimes, it is known as the New Technology File System. As
compared to the FAT and HFS file system, it provides better methods of file recovery and data
protection and offers a number of improvements in terms of extendibility, security, and performance.
UDF: A UDF is a file system, stands for Universal Disk Format and used first developed by OSTA
(Optical Storage Technology Association) for ensuring consistency among data written to several
optical media. It is used with CD-ROMs and DVD-ROMs and is supported on all operating systems.
Now, it is used in the process of CD-R's and CD-RW's, called packet writing.
Formatting:
Formatting is a process of preparing the storage device to store the data. Formatting storage device will
erase the earlier contents of the device.
Virtual Box:
Virtual Box is a cross-platform virtualization application. It installs on existing operating systems and also it
extends the capabilities of the existing computer so that it can run multiple operating systems (it means, inside
multiple virtual machines) at the same time.
Host operating system (host OS): the operating system of the physical computer on which Virtual Box
was installed.
Guest operating system (guest OS): the operating system that is running inside the virtual machine.
Virtual machine (VM). When running, a VM is the special environment that VirtualBox creates for guest
operating system.
Screen Shots (working Virtual Box in Linux Operating System – Host is Linux):
Example 1: xterm
o The xterm terminal application is a standard terminal emulator for the X Window System
o Installation:
sudo apt-get update
sudo apt-get install xterm
Example 2: mate-terminal
o MATE Terminal is a terminal emulation application to access a UNIX shell in the MATE environment.
With it, one can run any application that is designed to run on VT102, VT220, and xterm terminals.
o MATE Terminal also has the ability to use multiple terminals in a single window (tabs) and supports
management of different configurations (profiles).
o MATE Terminal is a fork of GNOME-Terminal.
o Installation:
sudo apt-get update -y
sudo apt-get install -y mate-terminal
ls (list)
Use ls without any arguments to display current directory contents.
ls with the -a option. files all begin with a "dot", which indicates they are "hidden" files.
o ls -a
ls with -F, this command is useful for distinguishing between directories, ordinary files, and executable
files.
o ls -F
ls with -l to obtain a "long" listing of files. An explanation of the information it provides appears below.
o ls -l
-rwxr-xr-x 1 jsmith staff 43 Mar 23 18:14 prog1
-rw-r--r-- 1 jsmith staff 10030 Mar 22 20:41 sample.f
1 2 3 4 5 6 7
1 = access modes/permissions 5 = size (in bytes)
2 = number of links 6 = date/time of last modification
3 = owner 7 = name of file
4 = group
ls with R, Recursive listings which will display files and folders inside the folders recursively.
o ls -R
o ls -Rl
pwd (Present Working Directory)
rm (Remove File)
cp (Copy)
Pipes: The pipe command lets user sends the output of one command to another. Piping, as the term suggests, can
redirect the standard output, input, or error of one process to another for further processing. A traditional pipe is
“unnamed” and lasts only as long as the process.
A named pipe, however, can last as long as the system is up, beyond the life of the process. It can be deleted if no
longer used.
Named Pipe:
AITM Polytechnic, Belagavi Dept Of Computer Science - 12 -
Operating Systems and Administration-20CS42P
In computing, a named pipe (also known as a FIFO) is one of the methods for inter- process
communication.
It is an extension to the traditional pipe concept on Unix.
Usually a named pipe appears as a file and generally processes attach to it for inter- process
communication.
A FIFO file is a special kind of file on the local storage which allows two or more processes to
communicate with each other by reading/writing to/from this file.
A FIFO special file is entered into the file system by calling mkfifo() in C.
Once a FIFO special file is created in this way, any process can open it for reading or writing, in the same
way as an ordinary file. However, it has to be open at both ends simultaneously before it can proceed to do
any input or output operations on it.
Creating a FIFO file: In order to create a FIFO file, a function calls i.e. mkfifo is used.
Example: a.c and b.c communication
more
Use the more command to read a file:
o more filename
Press Space bar / Return Key to read the remaining parts of the file.
Press q to quit viewing contents
less
less is the opposite of more command
Use the more command to read a file:
o less filename
Searching can be done by typing /searchkey, will highlights the searched words
Example: less test.c
o /printf
cmp (Compare)
compare two files byte by byte
Syntax: cmp -b file1 file2
File Permissions
There are three users in linux namely owner (u), group(g), others(o).
o Note: For all users can be identified with letter a
All three uses will have three possible permissions namely read(r), write(w), execute(e)
Numbers assigned for permissions are read(4), write(2), execute(1)
Command used to change permission of file is chmod
Syntax: chmod filePermissionPattern filename
Permission Table:
o Octal Table:
Output:
-rw-rw-r-- 1 admincs admincs 805 Mar 28 13:42 b.c
drwx---------2 admincs admincs 4.0K Mar 28 09:12 OS
-rwxrw-r-- 1 admincs admincs 1.9M Mar 28 08:45 output.pdf
drwxrwxr-x 2 admincs admincs 4.0K Jan 23 2021 Scratch Projects
Explanation
First letter (-) indicates file (in this example b.c, output.pdf are files)
First letter (d) indicates item is directory
Next 9 characters indicates File Permissions for different uses
In this example, file output.pdf has permission r w x r w – r – – which indicates
o Owner has r w x Permissions, means file owner can read, write and execute the fileGroup users has r
w – Permissions, means Group users can only read and write the File contents
o Other users has r – – Permissions, means Other users can only read the file contents
Examples
add execution permission to group and other users
o chmod go+x output.pdf
remove write permissions to group users
o chmod g-w output.pdf
Keep only read permission to all users
o chmod a=r output.pdf
umask
While creating a file or directory, by default a set of permissions are applied. These default
permissions are viewed by umask command.
For safety reasons all Unix systems doesn't provide execution permission to newly created files.
o umask
Output: 0002
size.
Compressing files:
Syntax
Decompressing files Description Example(s)
Decompressed a file that is
gzip -d {.gz file} created using gzip command. gzip -d mydata.doc.gz
gunzip {.gz file} File is restored to their original gunzip mydata.doc.gz
form using this command.
gzip -l {.gz file} List files from a GZIP archive gzip -l mydata.doc.gz
unzip -l {.zip file} List files from a ZIP archive unzip -l mydata.zip
tar -ztvf {.tar.gz} tar List files from a TAR archive tar -ztvf pics.tar.gz tar
-jtvf {.tbz2} -jtvf data.tbz2
sort
sort command is used to sort a file, arranging the records in a particular order.
By default, the sort command sorts file assuming the contents are ASCII.
AITM Polytechnic, Belagavi Dept Of Computer Science - 16 -
Operating Systems and Administration-20CS42P
Using options in the sort command can also be used to sort numerically.
Syntax:
sort [OPTIONS] filename
Options used:
-o : us ed to save sorted content in specified file
o sort -o output.txt inputfile.txt
r : sort the file contents in descending order
o sort -r inputfile.txt
-n : if the file contains numbers, based on number values, file contents can be sorted.
o sort -n inputfile.txt
-k : sort the file contents based on kth field values
o sort -k 2 inputfile.txt // sorts file contents based on values in 2nd field.
-u : will remove duplicate entries in file while sorting.
uniq
uniq filter removes duplicate lines from a sorted file. It is often seen in a pipe coupled
with sort.
uniq -c filename
removes the duplicates lines as well as displays frequency of duplicate lines.
cut
A tool for extracting fields from files.
Important options are -d, which specifies delimiter to separate fields, -f which indicates field numbers
Example 1: cut -d” “ -f1-4,6,8 FileName
o here contains information separated by space. This command displays contents in fields 1,2,3,4
and 6 and 8
Example 2: cut -d: -f1-4,6,8 FileName
o Same as above but the fields in file are seperated by : (colon)
join
Join allows merging two files in a meaningful fashion, which essentially creates a simple
version of a relational database.
The join command operates on exactly two files, but pastes together only those lines with a common tagged
field (usually a numerical label), and writes the result to stdout.
The files to be joined should be sorted according to the tagged field for the matchups to work properly.
head and tail
grep
A multi-purpose file search tool that uses Regular Expressions. (Global Regular
Expression Pring).
o grep pattern [FileName...]
options used with grep are:
wc
wc gives a "word count" on a file or I/O stream:
Important Options Used:
o wc -l gives only the line count.
o wc -w gives only the word count.
o wc -c gives only the byte count.
Syntax: wc -lwc FileName
Example:
o wc -lwc temp2.txt
Output:
o 3 6 18 temp2.txt
o Says there 3 Lines, 6 Wrods and 18 Characters altogher in a file temp2.txt
tr
character translation filter.
Example 1: tr "A-Z" "*" <filename
o will translate all the UPPER CASE characters to * in a file
Example 2: tr "0-9" "A" <filename
o will translate all the DIGITS to ‘A’ in a file
The -c "complement" option inverts the character set to match.
Example 3: echo "acfdeb123" | tr -c b-d +
o +c+d+b++++
Example 4: echo "abcd2ef1" | tr '[:alpha:]' -
o--------2--1
same as echo "abcd2ef1" | tr 'a-zA-Z' -
o ----2-----1
fold
A filter that wraps lines of input to a specified width. This is especially useful with the -s option, which
breaks lines at word spaces.
Example 1: fold -w 3 FileName
o Will wrap each line for every three characters
Example 2: fold - -s -w 3
o Will wait for the user to enter text, after return key, the text will be wraped to every three
AITM Polytechnic, Belagavi Dept Of Computer Science - 18 -
nl
Operating Systems and Administration-20CS42P
characters.
Line numbering filter: nl filename lists filename to stdout, but inserts consecutive
numbers at the beginning of each non-blank line.
If filename omitted, operates on stdin.
Process
A process is any active (running) instance of a program. In other words, process is a
program in execution.
A new process can be created by the fork() system call.
The new process consists of a copy of the address space of the original process. fork() creates new
process from existing process.
Existing process is called the parent process and the process is created newly is called
child process.
Foreground Processes
Every process by default runs in Foreground (which means the output is printed on the
screen.) The best example for the foreground process is the ls command which prints the output on the
screen by listing the files and directories.
When a program is running in the foreground, user cannot start another process without completing the
previous process. [ It is because of this reason foreground process is considered a time-consuming process.]
Background Processes
When a process starts running and it is not visible on the screen it is called a background process.
User can simultaneously run ‘n’ number of commands in the background process.
To enable the background process, provide ampersand symbol (&) at the end of the command.
Example : ls &
ps
The default output of ps is a simple list of the processes running in current terminal.
Example: ps
PID TTY TIME CMD
23989 pts/0 00:00:00 bash
24148 pts/0 00:00:00 ps
Every running process (-e) and a full listing (-f) could be obtained with these options.
Demonstrate fork() system call
AITM Polytechnic, Belagavi Dept Of Computer Science
- 20 -
Operating Systems and Administration-20CS42P
bg: background
bg used to place foreground jobs in background. [used to send a process running in the foreground to
the background in the current shell.]
Syntax: bg [ job_spec]
Place the jobs identified by each job_spec in the background, as if they has been started with ‘&’.
Job_spec may be
o %n : Refer to job number n.
o %% or %+ : Refer to the current job.
%- : Refer to the previous job.
Example: sleep 500 is a command which is used to create a dummy job which runs for 500 seconds.
o Use jobs command to list all jobs
o Create a process using sleep command, get job id as 1
o Put that process in background using id
$ jobs // Display current jobs running and displayed nothing
$ sleep 500 // Create one job, which sleeps for 500 seconds.
^z // Terminate the job by pressing Ctrl + z
o [1]+ Stopped sleep 500
$ jobs // Display current jobs running and displayed one job stopped
o [1]+ Stopped sleep 500
$ bg %1 // Refer the process by job number place it in background
o [1]+ sleep 500 &
$ jobs // Display current jobs running and displayed one job which is running.
nohup
nohup, short for No Hang Up is a command in Linux systems that keep processes running even
after exiting the shell or terminal.
nohup prevents the processes or jobs from receiving the SIGHUP (Signal Hang UP) signal.
This is a signal that is sent to a process upon closing or exiting the terminal.
Every command in Linux starts a process at the time of its execution, which automatically gets terminated
upon exiting the terminal.
Suppose, user executing programs over SSH and if the connection drops, the session will be terminated, all
the executed processes will stop, and user may face a huge accidental crisis.
o In such cases, running commands in the background can be very helpful to the user and
this is where nohup command comes into the picture. Syntax: nohup command [command-
argument ...]
nohup command can be used to run multiple commands in the background.
Syntax: nohup bash -c 'commands'
Example 1:
nohup bash -c 'cal && ls'
Here, the output will be by default stored in nohup.out. To redirect it, type:
nohup bash -c 'commands' > filename.txt
Stopping a process
kill
kill is used to send a signal to a process. The most commonly used signal is "terminate"
(SIGTERM) or "kill" (SIGKILL). The full list can be shown with kill –L
Signal number nine is SIGKILL. The default signal is 15, which is SIGTERM.
o Issue a command such as kill -9 20896.
pkill
command used to send signal to kill process by process name.
while issuing pkill, make sure that selected process name is the correct process to be stopped, verify
it by its full path by issuing pgrep –f processname.
Syntax: pkill -f ProcessName
nice
nice command in Linux helps in execution of a program/process with modified scheduling priority.
It launches a process with a user-defined scheduling priority.
The renice command allows user to change and modify the scheduling priority of an already running
process.
Linux Kernel schedules the process and allocates CPU time accordingly for each of them.
The kernel stores a great deal of information about processes including process priority which is simply
the scheduling priority attached to a process.
Processes with a higher priority will be executed before those with a lower priority, while processes with
the same priority are scheduled one after the next, repeatedly.
There are a total of 140 priorities and two distinct priority ranges implemented in Linux.
The first one is a nice value (niceness) which ranges from -20 (highest priority value) to 19 (lowest
priority value) and the default is 0.
The other is the real-time priority, which ranges from 1 to 99 by default, then 100 to 139
pid process-id, ppid parent process-id, ni niceness of process, comm command for that
process
Alternatively, user can use top or htop utilities to view Linux processes nice values
in htop command output, PRI – is the process’s actual priority, as seen by the Linux kernel.
rt value in PRI fields, means the process is running under real-time scheduling priority
Syntax:
niceness-value [command args] OR
Change the Scheduling Priority of a Process
Linux allows dynamic priority-based scheduling. Therefore, if a program is already
running, user can change its priority with the renice command in this form:
$ renice -n -12 -p 1055 //Mention process with id (-p)
$ renice -n -2 -u apache // Mention user process with
name (-u)
// -g for group process priority
Output Verification:
o New priority for process 1055 is 20 – 12 = 8
o New priority for process apache is 20 – 2 = 18
Observe new priority by issuing top or htop command
$ sudo nice -n 5 tar -czf backup.tac
top
The top command has been around a long time and is very useful for viewing details of running
processes and quickly identifying issues such as memory hogs.
Its default view is shown below.
Example 1: top
top - 11:56:28 up 1 day, 13:37, 1 user, load average: 0.09, 0.04, 0.03
Tasks: 292 total, 3 running, 225 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.1 us, 0.2 sy, 0.0 ni, 99.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 16387132 total, 10854648 free, 1859036 used, 3673448 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 14176540 avail Mem
cron
The cron is a software utility, offered by a Linux-like operating system that automates the scheduled task at
a predetermined time.
It is a daemon process, which runs as a background process and performs the specified operations at the
predefined time when a certain event or condition is triggered without the intervention of a user.
Dealing with a repeated task frequently is an intimidating task for the system administrator and thus he
can schedule such processes to run automatically in the background at regular intervals of time by
creating a list of those commands using cron.
It enables the users to execute the scheduled task on a regular basis unobtrusively like doing the
backup every day at midnight, scheduling updates on a weekly basis, synchronizing the files at some
regular interval.
Cron checks for the scheduled job recurrently and when the scheduled time fields match the current time
fields, the scheduled commands are executed.
It is started automatically from /etc/init.d on entering multi-user run levels.
Syntax: cron [-f] [-l] [-L loglevel]
at
at command is a command-line utility that is used to schedule a command to be executed at a
particular time in the future.
Jobs created with at command are executed only once.
The at command can be used to execute any program or mail at any time in the future.
It executes commands at a particular time and accepts times of the form HH:MM to run a job at a specific
time of day.
In the command, expression like noon, midnight, teatime, tomorrow, next week, next Monday, etc.
could be used with at command to schedule a job.
o atq
Schedule a job for the coming Monday at a time twenty minutes later than the current time:
05 – Process Synchronization
Classic command-line tools such as ps or top, which display process-level information by default, can be
instructed to display thread-level information.
Using the ps
The "SPID" column represents thread IDs, and "CMD" column shows thread names.
Example 1: top
To restrict the top output to a particular process and check all threads running inside the process:
Example 2: top -H -p 1572
Using htop
A more user-friendly way to view threads per process is via htop, an ncurses-based interactive process viewer.
This program allows user to monitor individual threads in tree views.
To enable thread views in htop, launch htop, and press F2 to enter htop setup menu.
sChoose "Display option" under "Setup" column, and toggle on "Tree view" and "Show custom thread names"
options. Presss F10 to exit the setup.
06 – Memory Management
1. free command
Syntax: free –m
Output:
2. /proc/meminfo
Check memory usage by reading the file at /proc/meminfo.
Know that the /proc file system does not contain real files.
o They are rather virtual files that contain dynamic information about the kernel and the system.
Portion of output is
$ cat /proc/meminfo MemTotal:
8167848 kB
MemFree: 1409696 kB
Buffers: 961452 kB
Cached: 2347236 kB
SwapCached: 0 kB
SwapTotal: 1998844 kB
SwapFree: 1998844 kB
3. vmstat
vmstat –s
Portion of output is
8167848 K total memory
7449376 K used memory
718472 K free memory
1154464 K buffer memory
2422876 K swap cache
1998844 K total swap
0 K used swap
1998844 K free swap
The top command is generally used to check memory and cpu usage per process.
4. top command
It also reports total memory usage and can be used to monitor the total RAM usage.
The header on output has the required information.
Check the KiB Mem and KiB Swap lines on the header. They indicate total, used and free amounts of the
AITM Polytechnic, Belagavi Dept Of Computer Science
- 30 -
Operating Systems and Administration-20CS42P
5. htop
Similar to the top command, the htop command also shows memory usage along with
various other details.
The header on top shows cpu usage along with RAM and swap usage with the corresponding figures.
6. RAM Information
To find out hardware information about the installed RAM, use the demidecode command.
Portion of output is
sudo dmidecode –t 17 #
dmidecode 2.11
SMBIOS 2.4 present.
Handle 0x0015, DMI type 17, 27 bytes
Memory Device
Array Handle: 0x0014
Error Information Handle: Not Provided Total
Width: 64 bits
Data Width: 64 bits Size: 2048 MB
Form Factor: DIMM
Set: None
Locator: J1MY
Bank Locator: CHAN A DIMM 0 Type: DDR2 Type Detail: Synchronous
Speed: 667 MHz Manufacturer: 0xFF00000000000000 Serial Number: 0xFFFFFFFF
07 – Shell Programming
Script 4: Check the permissions of a given file and display the status
echo -e "Enter the name of the file : \c" read
filename
echo File Permission
`ls -l $filename`
if [ -r $filename ]
then
echo "$filename is readable" echo
else "$filename is not readable"
fi
if [ -w $filename ]
then
echo "$filename is writable" echo
else "$filename is not writable"
fi
if [ -x $filename ]
then
echo "$filename is executable" echo
else "$filename is not executable"
fi
if [ -s $filename ]
then
echo "$filename has size>0"
else
fi
echo "$filename has size= 0"
string1="Linux"
string2="Hint"
echo "$string1$string2"
string3=$string1+$string2
string3+=" is a good tutorial blog site"
echo $string3
Output
Write a Shell Script to display a menu consisting of options to display disk space, the current users logged in,
total memory usage, etc.
$cat menu1
#!/bin/bash
#simple script menu
function diskspace
{
clear
df -k
}
function whoseon
{
clear
who
}
function memusage
{
clear
cat /proc/meminfo
}
function menu
{
clear
echo
echo -e "\t System admin menu\n"
echo -e "\t 1. Display disk space\n"
echo -e "\t 2. Display logged on users\n"
echo -e "\t 3. Display memory usage\n"
echo -e "\t 0. Exit program\n\n"
echo -en "\t Enter option : "
read -n 1 option
}
while [ 1 ]
do
menu
case $option in
0)
break ;;
1)
diskspace ;;
2)
whoseon ;;
3)
memusage ;;
*)
clear
echo "Sorry wrong selection";;
esac
echo -en "\n\t Hit any key to continue"
read -n 1 line
done
clear
OUTPUT
btps123@ubuntu:~$ ./14b.sh
Enter option : 1
09 – Network Management
ifconfig:
ifconfig(interface configuration) is used to configure the kernel-resident network interfaces.
It is used at the boot time to set up the interfaces as necessary.
It is used to assign the IP address and netmask to an interface or to enable or disable a given interface.
Example 1: ifconfig -a
-a : This option is used to display all the interfaces available, even if they are down.
Output: ifconfig -a
enp1s0 Link encap:Ethernet HWaddr 94:c6:91:f6:37:56
inet addr:172.16.20.107 Bcast:172.16.20.255 Mask:255.255.255.0
inet6 addr: fe80::ef4b:1b1d:5c61:d9c6/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Example 2: ifconfig –s
-s : Display a short list, instead of details.
iwconfig:
iwconfig command in Linux is like ifconfig command, in the sense it works with kernel- resident network
interface but it is dedicated to wireless networking interfaces only.
It is used to set the parameters of the network interface that are particular to the wireless operation like SSID,
frequency etc.
iwconfig may also be used to display the parameters, and the wireless statistics which are extracted from
/proc/net/wireless.
Usage Examples:
o nwid: This option sets the network ID, user may disable or enable the Network ID.
iwconfig [Interface] nwid on/off
o mode: Set the operating mode of the device, which depends on the network topology. The modes can
be Ad-Hoc, Managed, Master, Repeater, Secondary, and Monitor.
iwconfig [Interface] mode Managed
o commit: This option forces the card to apply all pending changes.
iwconfig [Interface] commit
ethtool:
ethtool utility is used to view and change the ethernet device parameters.
Before executing the command first identify the name of the nic using command ifconfig. (Here it is, say enp1s0 )
arpwatch:
arpwatch is an open source computer software program that helps user to monitor Ethernet traffic activity (like
Changing IP and MAC Addresses) on network and maintains a database of ethernet/ip address pairings.
Example 1: To watch a specific interface, type the following command with ‘-i’ and device name.
arpwatch -i enp1s0
o So, whenever a new MAC is plugged or a particular IP is changing his MAC address on the
network, user can notice syslog entries at ‘/var/log/syslog‘ or ‘/var/log/message‘ file.
bmon:
bmon is a simple yet powerful, text-based network monitoring and debugging tool for Unix-like systems, which
captures networking related statistics and displays them visually in a human friendly format.
It is a reliable and effective real-time bandwidth monitor and rate estimator.
Example 1: bmon -p enp1s0
To view more detailed graphical statistics/information of bandwidth usage, press d key Press [Shift + ?] to
view the quick reference. To exit the interface, press [Shift + ?] again.
ssh:
Secure Shell, sometimes referred to as Secure Socket Shell, is a protocol which allows user to connect securely to
a remote computer or a server by using a text-based interface.
When a secure SSH connection is established, a shell session will be started and user will be able to manipulate
the server by typing commands within the client on local computer.
Prerequisite:
o Install openssh-client and openssh-server through software manager
o assign valid ip address to two machines, for connection
o Assure, both the system have user account with password.
Settings:
Machine 1: Machine 2:
name: admincsm1 admincsm2
login: admincsl1 admincsl2
192.100.100.1 192.100.100.2
telnet:
The telnet command is used to create a remote connection with a system over a TCP/IP
network.
It allows us to administrate other systems by the terminal.
User can run a program to conduct administration.
It uses a TELNET protocol. However, this protocol has some security defects, but it is one of the most used
networking protocols due to its simplicity.
It is not a secure protocol because it transfers data in unencrypted form.
Often Linux user prefers ssh over telnet because ssh transfers data in encrypted form.
Prerequisite:
o Install telnet (client) and telnetd (server) through software manager
o assign valid ip address to two machines, for connection
o Assure, both the system have user account with password.
Settings:
Machine 1: Machine 2:
name: admincsm1 admincsm2
login: admincsl1 admincsl2
192.100.100.1 192.100.100.2
ftp:
ftp is the user interface to the Internet standard File Transfer Protocol.
The program allows a user to transfer files to and from a remote network site.
Prerequisites:
Install Ftp (FTP-Client) and vsftpd (FTP-Server) using Software Manager.
Change /etc/vsftpd.conf file to enable write permission (other settings can be done according to
requirement.
◦ nano /etc/vsftpd.conf
Search for # write_enable=YES (around 30th line in that file)
Uncommnent and Save and Exit
Restart the Service: systemctl restart vsftpd
curl:
curl is a command-line tool to transfer data to or from a server, using any of the supported protocols (HTTP, FTP,
IMAP, POP3, SCP, SFTP, SMTP, TFTP, TELNET, LDAP, or FILE).
curl is powered by Libcurl.
This tool is preferred for automation since it is designed to work without user interaction.
curl can transfer multiple files at once.
wget:
wget is the non-interactive network downloader which is used to download files from the
AITM Polytechnic, Belagavi Dept Of Computer Science - 39 -
Operating Systems and Administration-20CS42P
server even when the user has not logged on to the system and it can work in the background
without hindering the current process.
Examples:
wget --ftp-user=admincs --ftp-password=admincs ftp://
192.100.100.2/Desktop/test.c
rcp:
The rcp command is used to copy files between different computers without starting an
FTP session or logging into the remote system explicitly.
It uses ssh for data transfer, and uses the same authentication and provides the same security as ssh.
To simply use the rcp command, just provide the source and destination to rcp command with a colon used to
separate the host and the data.
Syntax Example:
o /* using rcp command to send a file from local host to remote host */
rcp /mydirectory/a.txt admin:remotedir/kt.txt
o /* the example above is to send a file not to receive a file from remote host */
scp:
scp allows user to securely copy files and directories between two local/remote
machines.
It uses ssh for data transfer, and uses the same authentication and provides the same security as ssh.
Working with scp:
Note: Assume, Source machine and Destination machine have same username, so identify different machine
user names with ipaddress.
Example 1: Copy file from local machine to remoter machine.
scp index.html admincs@192.100.100.2:/home/admincs/test.html
This will copy file index.html from current user to remote user admincs@192.100.100.2 and file will be copied
to remote user /home/admincs with the file name test.html
rsync:
rsync is a fast and extraordinarily versatile file copying tool.
It can copy locally, to/from another host over any remote shell, or to/from a remote rsync daemon.
It offers a large number of options that control every aspect of its behavior and permit very flexible specification
of the set of files to be copied.
It is famous for its delta-transfer algorithm, which reduces the amount of data sent over the network by sending
only the differences between the source files and the existing files in the destination.
rsync is widely used for backups and mirroring and as an improved copy command for everyday use.
sftp:
sftp works on a client-server model. It is a subsystem of SSH and supports all SSH authentication mechanisms.
To open an SFTP connection to a remote system, use the sftp command followed by the remote server username
and the IP address or domain name (then provide password for the user):
o sftp admincs@172.16.20.116
netstat:
netstat is a command line utility for Linux that prints network connections, routing tables, interface statistics,
masquerade connections, and multicast memberships.
netstat can be used to diagnose network issues and service problems.
Important Options used:
o -a: all listening and non-listening ports, -t tcp ports
o -u udp ports, -l listening ports
o -s Statistics of ports, -r Kernel Routing Information
ping:
ping (Packet Internet Groper) command is used to check the network connectivity between host and server/host.
This command takes as input the IP address or the URL and sends a data packet to the specified address with the
message “PING” and get a response from the server/host this time is recorded which is called latency.
Fast ping low latency means faster connection.
Ping uses ICMP(Internet Control Message Protocol) to send an ICMP echo message
to the specified host if that host is available then it sends ICMP reply message.
Ping is generally measured in millisecond.
Important options used:
o -c : Number of packets to be transfered
o -w : deadline, with in this seconds, continuesly send the packets ICMP Packets.
o -s : Packe size
Example 1: ping -c 5 -s 100 172.16.20.116
o Will send 5 ICMP Packets to test wheter machine 100.172.16.116 is alive or not, and each packet size
data is 100 bytes, total packet size is 108 (8 bytes of header).
Example 2: ping -w 5 172.16.20.115
o Will continuously send the ICMP packets within 5 seconds.
traceroute:
o traceroute command in Linux prints the route that a packet takes to reach the host.
o This command is useful when user want to know about the route and about all the hops that a packet takes.
iftop:
The iftop command listens to network traffic on a named network interface, or on the first interface, it can find
AITM Polytechnic, Belagavi Dept Of Computer Science - 41 -
Operating Systems and Administration-20CS42P
which looks like an external interface if none is specified, and displays a table of current bandwidth usage by pairs
of hosts.
The iftop is a perfect tool for remote Linux server over an ssh based session.
iftop must be run by the root or the user who has sufficient permissions to monitor all network traffic on the
network interface.
nload:
nload is a Linux command-line tool used to monitor network traffic and bandwidth usage in real time, using
insightful graphs and traffic statistics.
Output of nload is in paragraph, one for each device.
A device is anything which sends and/or receives internet packets on the same network, but usually, it
represents a network interface device.
It does not necessarily need to be a separate physical device, but can even be on the same machine!
nload –m // -m for multiple devices.
Output:
Device enp1s0 [172.16.20.107] (1/2):
Incoming: Outgoing:
Curr: 1.61 kBit/s Curr: 0.00 Bit/s
Avg: 1.82 kBit/s Avg: 456.00 Bit/s
Min: 0.00 Bit/s Min: 0.00 Bit/s
Max: 34.95 kBit/s Max: 15.07 kBit/s
Ttl: 76.13 MByte Ttl: 8.84 MByte
ss:
The ss command is a tool used to dump socket statistics and displays information in
similar fashion (although simpler and faster) to netstat.
The ss command can also display even more TCP and state information than most other tools.
The ss command can also display even more TCP and state information than most other tools. Because ss is the
new netstat, the ss command-line utility can display stats for the likes of PACKET, TCP, UDP, DCCP, RAW, and
Unix domain sockets.
Example 1: ss -t
tcpdump:
tcpdump is a packet sniffing and packet analyzing tool for a System Administrator to troubleshoot connectivity
issues in Linux.
It is used to capture, filter, and analyze network traffic such as TCP/IP packets going through system.
It is many times used as a security tool as well. It saves the captured information in a pcap file, these pcap files
AITM Polytechnic, Belagavi Dept Of Computer Science - 42 -
Operating Systems and Administration-20CS42P
can then be opened through Wireshark or through the command tool itself.
tcpdump -i enp1s0
13:50:29.798343 IP 172.16.20.116 > 172.16.20.107: ICMP echo request, id 29434, seq 2, length 64
13:50:30.822415 IP 172.16.20.116 > 172.16.20.107: ICMP echo request, id 29434, seq 3, length 64
13:50:31.846476 IP 172.16.20.116 > 172.16.20.107: ICMP echo request, id 29434, seq 4, length 64
4 packets captured
4 packets received by filter 0
packets dropped by kernel
dstat:
dstat is a tool that is used to retrieve information or statistics form components of the system such as network
connections, IO devices, or CPU, etc.
It is generally used by system administrators to retrieve a handful of information about the above-mentioned
components of the system. It itself performs like vmstat, netstat, iostat, etc.
By using this tool one can even see the throughput for block devices that make up a single filesystem or storage
system.
dstat allows user to view all of system resources instantly, for example, user can compare disk usage in
combination with interrupts from IDE controller, or compare the network bandwidth numbers directly with the
disk throughput (in the same interval).
10 – User Authentication
useradd
passwd
The passwd command changes passwords for user accounts.
A normal user may only change the password for their own account, while the superuser may change the
password for any account.
passwd also changes the account or associated password validity period.
Important options used along with passwd:
o -d, --delete Delete a user's password (make it empty). This is a quick way to disable a
password for an account. It will set the named account passwordless.
o -e, --expire Immediately expire an account's password. This in effect can force a user to
change his/her password at the user's next login.
userdel
userdel command in Linux system is used to delete a user account and related files.
This command basically modifies the system account files, deleting all the entries which refer to the username
LOGIN.
It is a low-level utility for removing the users.
Syntax: sudo userdel -f –r –Z neuser
Important Options used along with userdel:
o -f: This option forces the removal of the specified user account. It doesn’t matter that the user is
still logged in. It also forces the userdel to remove the user’s home directory and mail spool, even
if another user is using the same home directory or even if the mail spool is not owned by the
specified user.
o -r: Whenever we are deleting a user using this option then the files in the user’s home directory
will be removed along with the home directory itself and the user’s mail spool. All the files
located in other file systems will have to be searched for and deleted manually.
o -Z : This option remove any SELinux(Security-Enhanced Linux) user mapping for the user’s
AITM Polytechnic, Belagavi Dept Of Computer Science
- 44 -
Operating Systems and Administration-20CS42P
login.
usermod
Groups: Groups in Linux refer to the user groups. In Linux, there can be many users of a single system, (normal user
can take uid from 1000 to 60000, and one root user (uid 0) and 999 system users (uid 1 to 999)).
groupadd
groupadd command is used to create a new user group.
Syntax: groupadd newgroupname
Every new group created is registered in the file “/etc/group“. To verify that the group has been created, enter the
command
o sudo tail /etc/group
Adding user while creating newuser
o useradd -d /home/newusername –p passwordstring -g
existinggroupname newusername
Adding existing user to group // Explained once again in next topic
o usermod -g existinggroupname existinguser
groupmod
groupmod command is used to modify or change the existing group.
It can be handled by superuser or root user.
Basically, it modifies a group definition on the system by modifying the right entry in the database of the group.
Syntax: groupmod [option] groupname
o Change the group name to new name.
o groupmod -n groupnewname groupoldname
gpasswd
gpasswd command is used to administer the /etc/group and /etc/gshadow.
gpasswd command assigns a user to a group with some security criteria.
gpasswd command is called by a group administrator with a group name only which prompts for the new
password of the group.
System administrators can use the -A option to define group administrator(s) and -M
option to define members.
Syntax: gpasswd [option] group
Important Options: Here only -A and -M options can be combined.
o -a, –add : This option is used to add a user to the named group.
o -d, –delete : It is used to remove a user from the named group.
AITM Polytechnic, Belagavi Dept Of Computer Science
- 45 -
Operating Systems and Administration-20CS42P
o -r, –remove-password : It is used to remove the password from the named group.
o -A, –administrators : Set the list of administrators for the group.
o -M, –members : set the list of members of the group.
Example:
add the user to group:
o gpasswd -a existinguser existinggroup
Deleting the created user from group geeks.
o gpasswd -d existinguser existinggroup
groupdel
groupdel command is used to delete a existing group.
It will delete all entry that refers to the group, modifies the system account files, and it is handled by superuser or
root user.
Syntax: groupdel –f existinggroup
Option used: -f –force: It used to delete a group even if it is the primary group of a user
LDAP server and client configuration:
Test LDAP connection with ldapwhoami, which should return the username as:
ldapwhoami -H ldap:// -x
Output
o anonymous
o anonymous is the result expected, since running ldapwhoami without logging in to the LDAP
server. This means the server is running and answering queries.
AITM Polytechnic, Belagavi Dept Of Computer Science
- 46 -
Operating Systems and Administration-20CS42P
top
The top command has been around a long time and is very useful for viewing details of
running processes and quickly identifying issues such as memory hogs. Its default view is shown below.
top - 11:56:28 up 1 day, 13:37, 1 user, load average: 0.09, 0.04, 0.03
Tasks: 292 total, 3 running, 225 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.1 us, 0.2 sy, 0.0 ni, 99.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
To make it easier to monitor required processes, user can call top and pass the PID(s) using the -p
option.
top -p20881 -p20882 -p20895 -p20896
Tasks: 4 total, 0 running, 4 sleeping, 0 stopped, 0 zombie
%Cpu(s): 2.8 us, 1.3 sy, 0.0 ni, 95.9 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 16387132 total, 10856008 free, 1857648 used, 3673476 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 14177928 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
df
The df command (short for disk free), is used to display information related to file systems about
total space and available space.
Syntax : df [OPTION]... [FILE]...
If no file name is given, it displays the space available on all currently mounted file systems.
Example 1: df
Portion of output:
Filesystem 1K-blocks Used Available Use% Mounted on udev
3996816 0 3996816 0% /dev
tmpfs 804624 10020 794604 2% /run
/dev/sda9 68117056 18036160 46597712 28% /
iostat
The iostat command in Linux is used for monitoring system input/output statistics for
devices and partitions.
It monitors system input/output by observing the time the devices are active in relation to their average
transfer rates.
The iostat produce reports may be used to change the system configuration to raised balance the
input/output between the physical disks.
Note: iostat is being included in sysstat package. If user doesn’t have it, user need to install first. (apt-
get install sysstat)
Syntax: iostat
Options used:
o -x: This command shows more details statistics information. iostat command gives I/O devices report
utilization as a result. So it’s possible to extend the statistic result for a diagnose in depth with the -x
option.
o -c: This command show only the CPU statistic. It is possible to show the statistic information and
report of our cpu with -c option.
o -d: This command displays only the device report. It is possible to only show the status of the device
utilization with the help of -d option. It will be going to list information for each connected device.
AITM Polytechnic, Belagavi Dept Of Computer Science
Operating Systems and Administration-20CS42P
20CS42P
o -k: This command captures the statistics in kilobytes or megabytes. By default, iostat measure the I/O
system with the bytes unit.
o -c 2 2: To show CPU only report with 2 seconds interval and 2 times reports.
free
free command is used to view memory consumption
free -m
total used free shared buffers cached
Mem: 7976 6459 1517 0 865 2248
-/+ buffers/cache: 3344 4631
Swap: 1951 0 1951
The m option displays all data in MBs.
The total os 7976 MB is the total amount of RAM installed on the system, that is 8GB.
cat /proc/cpuinfo
The file /proc/cpuinfo displays what type of processor the user system is running
including the number of CPUs present.
Portion of the Output: #
cat /proc/cpuinfo
processor 0
vendor_id : GenuineIntel
cpu family 6
model 45
model name : Intel(R) Xeon(R) CPU E5-2660 0 @ 2.20GHz
cat /proc/meminfo
On Linux, user can use the command cat /proc/meminfo to determine how much memory the computer
has.
This command displays the information stored in the meminfo file located in the /proc directory.
The total amount of memory will be displayed as MemTotal
Know that the /proc file system does not contain real files.
o They are rather virtual files that contain dynamic information about the kernel and the system.
Portion of output is
$ cat /proc/meminfo MemTotal:
8167848 kB
MemFree: 1409696 kB
Buffers: 961452 kB
Cached: 2347236 kB
Rebooting
halt
This command in Linux is used to instruct the hardware to stop all the CPU
functions.
Basically, it reboots or stops the system.
halt [OPTION]
Options used:
o -f, –force It does not invoke shutdown
o -w, –wtmp-only It will not call shutdown or the reboot system call but writes the shutdown
record to /var/log/wtmp file.
o -p, –poweroff To behave as poweroff
init
init is parent of all Linux processes with PID or process ID of 1.
It is the first process to start when a computer boots up and runs until the system shuts down.
init stands for initialization.
The role of init is to create processes from script stored in the file /etc/inittab which is a configuration
file which is to be used by initialization system.
AITM Polytechnic, Belagavi Dept Of Computer Science
Operating Systems and Administration-20CS42P
20CS42P
yum
Yum and RPM are both package managers for Linux systems.
Yum stands for Yellowdog Updater Modified. They are packaging managers for RPM- based Linux
systems.
They are a high-level front end management package managers for Linux distributions that are RPM-based.
It can sense and resolve dependencies.
Yum can only install the packages available in its repository.
Yum can also scan and upgrade the packages to the latest versions. It also entirely relies on online
repositories.
rpm
RPM stands for Redhat Packaging Manager.
It can be considered one of the oldest packaging managers that do basic functions like uninstalling,
updating, archiving the packages received by the Linux systems.
It cannot sense and resolve dependencies on its own.
It can install multiple packages with the condition that we give the correct file name with the .rpm
extension.
RPM does not depend on online repositories for any of its services and it cannot scan or upgrade itself or
its packages to the latest versions.
DNS is an Internet service that maps IP addresses and fully qualified domain names
Page | 52 (FQDN) to one another.
o In this way, DNS alleviates the need to remember IP addresses.
Computers that run DNS are called name servers.
Ubuntu ships with BIND (Berkley Internet Naming Daemon), the most common program used for
maintaining a name server on Linux.
o BIND is the most common program used for maintaining a name server on Linux.
Prerequisites: Install the following packages.
Installation
sudo apt-get update
sudo apt-get install bind9
sudo apt-get update
sudo apt-get install dnsutils
sudo apt-get update
Configuration
There are many ways to configure BIND9. Some of the most common configurations are a
caching nameserver, primary server, and secondary server.
When configured as a caching nameserver BIND9 will find the answer to name queries and remember the
answer when the domain is queried again.
As a primary server, BIND9 reads the data for a zone from a file on its host and is authoritative for
that zone.
As a secondary server, BIND9 gets the zone data from another nameserver that is authoritative for
the zone.
Caching Nameserver
The default configuration acts as a caching server. Simply uncomment and edit
/etc/bind/named.conf.options to set the IP addresses of ISP’s DNS servers:
nano /etc/bind/named.conf.options
Before After
// forwarders { forwarders {
// 1.2.3.4; 192.168.1.10;
// 5.6.7.8; };
// };
Assume:
Name Server: 192.168.1.10
Primary Server
In this section BIND9 will be configured as the Primary server for the domain example.com. Simply replace
Page | 53
example.com with FQDN (Fully Qualified Domain Name).
Forward Zone File
To add a DNS zone to BIND9, turning BIND9 into a Primary server, first edit
/etc/bind/named.conf.local:
nano /etc/bind/named.conf.local
zone "example.com" {
type master;
file "/etc/bind/db.example.com";
};
nano /etc/bind/named.conf.local
zone "example.com" {
type master;
file "/etc/bind/db.example.com";
allow-transfer { 192.168.1.11; };
};
zone "1.168.192.in-addr.arpa" {
type master;
file "/etc/bind/db.192";
allow-transfer { 192.168.1.11; };
};
ftp
ftp is the user interface to the Internet standard File Transfer Protocol. The program allows a
user to transfer files to and from a remote network site.
Examples below are to upload and download files using ftp service.
Prerequisites:
Install Ftp (FTP-Client) and vsftpd (FTP-Server) using Software Manager.
Change /etc/vsftpd.conf file to enable write permission (other settings can be done according to
requirement.
◦ nano /etc/vsftpd.conf
Search for # write_enable=YES (around 30th line in that file)
Uncommnent and Save and Exit
Restart the Service: systemctl restart vsftpd
Install and configure Apache web server and create virtual hosts:
The Apache web server is the most popular way of serving web content on the internet.
It accounts for more than half of all active websites on the internet and is extremely powerful and
flexible.
Apache breaks its functionality and components into individual units that can be customized and
configured independently. The basic unit that describes an individual site or domain is called a virtual host.
These designations allow the administrator to use one server to host multiple domains or sites off of a
single interface or IP by using a matching mechanism. This is relevant to anyone looking to host more than
Prerequisites:
Page | 55 For all commands use sudo bash
Install apache Server: apt-get install apache2
o Make a directory structure that will hold the site data that we will be serving to visitors.
o Document root (the top-level directory that Apache looks at to find content to serve) will be set to
individual directories under the /var/www directory.
o Create a directory here for virtual host.
o Within this directory, create a public_html folder that will hold our actual files. This gives some flexibility
in hosting.
o mkdir -p /var/www/example.com/public_html
Step 2: Granting Permissions
Directory structure for host files owned by our root user. If user want regular user to be able to modify
files in web directories, can change the ownership by doing this:
chown -R $USER:$USER /var/www/example.com/public_html
By doing this, regular user now owns the public_html subdirectories where we will be storing our
content.
Also modify permissions a little bit to ensure that read access is permitted to the general web directory
and all of the files and folders it contains so that pages can be served correctly:
chmod -R 755 /var/www
<html>
<head>
<title>Welcome to Apache Server Experiment</title>
</head>
<body>
<h1>Success! The virtual host is working Fine!</h1>
</body>
</html>
/etc/apache2/sites-available/example.com.conf
Before After
<VirtualHost *:80> <VirtualHost *:80>
ServerAdmin webmaster@localhost ServerAdmin admin@example.com
Page | 57 DocumentRoot /var/www/html ServerName example.com ServerAlias
ErrorLog ${APACHE_LOG_DIR}/error.log www.example.com DocumentRoot
CustomLog /var/www/example.com/public_html ErrorLog $
${APACHE_LOG_DIR}/access.log combined {APACHE_LOG_DIR}/error.log CustomLog
</VirtualHost> ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Add few contents to the above file. And also make few changes to the file such that it finally looks
like (Second Column):
Save and close the file.
13 – Storage Management
fdisk
cfdisk
o sudo sfdisk -l -uM
cfdisk is a linux partition editor with an interactive user interface based on ncurses.
It can be used to list out the existing partitions as well as create or modify them.
An example of how to use cfdisk to list the partitions.
parted
df is not a partitioning utility, but prints out details about only mounted file systems.
The list generated by df even includes file systems that are not real disk partitions.
o df -h
o df -h | grep ^/dev
Note:df shows only the mounted file systems or partitions and not all.
pydf
lsblk
Lists out all the storage blocks, which includes disk partitions and optical drives.
Details include the total size of the partition/block and the mount point if any.
Does not report the used/free disk space on the partitions.
o lsblk
If there is no MOUNTPOINT, then it means that the file system is not yet mounted. For cd/dvd this
means that there is no disk.
lsblk is capable of displaying more information about each device like the label and model. Check out the
man page for more information
Display UUID and Model of device
o The "-o" option can be used to specify the columns to display.
lsblk -o PATH,SIZE,RO,TYPE,MOUNTPOINT,UUID,MODEL
o The above output has all the necessary information about all the storage devices present on the
system or connected via usb.
o This is the best command to see all information about storage devices together in one place.
Prints the block device (partitions and storage media) attributes like uuid and file system type. Does not
report the space on the partitions.
blkid
o sudo blkid
hwinfo
The hwinfo is a general purpose hardware information tool and can be used to print out
the disk and partition list.
The output however does not print details about each partition like the above commands.
o hwinfo --block –short
inxi
inxi command display information about various hardware components present on the system.
To display information about the disk drives and storage devices use the "-D" option with inxi.
o inxi -D -xx
So to format our four logical volumes with the Ext4 filesystem, user can type:
1. sudo mkfs.ext4 /dev/LVMVolGroup/projects
2. sudo mkfs.ext4 /dev/LVMVolGroup/www
3. sudo mkfs.ext4 /dev/LVMVolGroup/db
4. sudo mkfs.ext4 /dev/LVMVolGroup/workspace
]
After formatting, user can create mount points:
sudomkdir /mnt/projects sudomkdir -p
/mnt/www sudomkdir -p /mnt/db
sudomkdir -p /mnt/workspace
Then mount the logical volumes to the appropriate location using commands:
The operating system should now mount the LVM logical volumes automatically at boot.