Linux Admin Guide for BSC IT Students
Linux Admin Guide for BSC IT Students
com
Acuity Educare
LINUX SYSTEM
ADMINISTRATOR
SEM : V
SEM V: UNIT 1
Linux Structure
The Linux operating system can be visualized in terms of layers:
• Hardware
o Hardware consists of all peripheral devices (RAM/ HDD/ CPU etc).
• Kernel
o controls the computer resources and schedules jobs
• Shell
o Acts as a command interpreter that acts as an interface between users and the
operating system.
o The shell communicates with the internal part of the operating system called the
kernel
• Working:
o After logging in, Linux starts another program called the shell
o The shell interprets commands the user types and manages their execution
o The most popular shells are: tcsh, csh, korn, and bash
• Utilities (Commands)
o Comprehensive set of utilities that are universally required by Unix administrators &
users. Utilities are often referred to as commands
Today Linux in general and Red Hat Linux is at the heart of the IT organization in many companies. Large
parts of the Internet operate on Linux, using popular applications such as theApache web server or the
Squid proxy server. Stock exchanges use Linux in their real-time calculation systems, and large Linux
servers are running essential business applications on top of Oracle and SAP. Linux has largely replaced
UNIX, and Red Hat is a leading force in Linux.
Page 1 of 26
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V: LINUX – U4
1. Redhat Enterprise Linux (Why Red Hat Linux and Fedora has been so successful? )
Red Hat produces the most popular distribution of Linux currently in use. It is a robust, reliable
operating system that can run on a variety of hardware, from personal computers to large
mainframes.
• One reason why Red Hat has been so successful since the beginning is the level of support thecompany
provides. Red Hat offers three types of support, and this gives companies theconfidence they need to
run vital business applications on Linux.
• The three types of Linux support provided by Red Hat are as follows
i. Hardware Support Red Hat has agreements with every major server hardware vendor to make
sure that whatever server a customer buys, the hardware vendor will assist them in fixing hardware
issues, when Red Hat is installed on it.
ii. Software Support Red Hat has agreements with every major enterprise software vendor tomake
sure that their software runs properly on top of the Red Hat Linux operating system and that the
enterprise software is also guaranteed to run on Red Hat Linux by the vendorof the operating
system.
iii. Hands-on Support This means that if a customer is experiencing problems accomplishing tasks
with Red Hat software, the Red Hat Global Support organization is there to help them by fixing bugs
and providing technical assistance.
2. Fedora Linux
• Fedora is a freely available Linux distribution that is completely comprised of open source software,
and Red Hat is providing the funds and people to manage this project. Both Red Hat and Fedora are free
of charge; with Red Hat you pay only for updates and support.
• Fedora is used as a development platform for the latest and greatest version of Linux, which is provided
free of charge for users who are interested. As such, Fedora can be used as a test platform for features
that will be included in Red Hat Enterprise Linux.
• Fedora makes an excellent choice to install on your personal computer, because it offers all thefunctions
of a modern operating system and some functions specially for home users.
3. Debian Linux
• It is used as a base for many other distributions. It provides security. Debian focuses mainly onthree
branches stable (latest release), unstable (branch that is in continuous evolution), and testing (next
release to be).
4. Ubuntu Linux
• Ubunto refers to distribution based on unstable branch of Debian distribution. It has best
looking desktop.
Page 2 of 26
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V: LINUX – U4
System Administrator
The “root” user account is the super user account in linux operating system.
root user has access to everything i.e all user accounts, their home directories, and the files; all
system configurations; and all files on the system.
A system administrator has access to “root” (Super user) account.
Page 3 of 26
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V: LINUX – U4
• There is a need to back up important files so that in the event of a failure of hardware, security, or
administration, the system can be up and running again with minimal disruption.
• Only system administrator can take system backup.
• If we have a high-capacity tape drive and several good sets of restore diskettes, we can makea full
system backup every few days.
• Once administrator decides what to back up, he need to decide how frequently backups are necessary
and whether there is a need to maintain a series of incremental backups (addingonly the files that
have changed since the last backup) or multiple full backups
Restoring Files:
• When Restoring files is also very important.
• Administrator needs to formulate a strategy for making sure system is not vulnerable tocatastrophic
disruption.
• There must be a plan for bringing the system back up in the event of a failure
• In case of system failure, backup files must be successfully restored.
5. Monitoring and tuning performance
• System tuning is an ongoing process aided by a variety of diagnostic and monitoring tools.
• Careful system monitoring and diagnostic practices give administrator an early heads-up when a
system component is showing early signs of failure, so that any potential downtime can be minimized.
Combined with the resources for determining which components are best supportedby Red Hat Linux,
performance monitoring can result in replacement components which allowto get best performance.
• Careful system monitoring plus wise use of the built-in configurability of Linux allows administrator to
squeeze the best possible performance from the existing equipment, from customizing video drivers to
applying special kernel patches to simply turning off unneeded services to free memory and processor
cycles.
6. Configuring a secure system
• There are major attacks done on machines connected to Internet, the majority of these attacks have not
targeted Linux systems, but Linux systems are not entirely immune, either to direct attack or to the
effects of attacks on machines running other operating systems.
• For example: Distributed Denial of Service (DDoS) attacks, attacks of the summer of 2001, Linux
machines themselves were invulnerable, but the huge amount of traffic generated by this “worm”
infection prevented many Linux machines from getting much Web-based work done for several weeks.
• The system administrator’s task is to make sure that no data on the machine or network are likely to
become corrupted, whether by hardware or power failure, by misconfiguration or user error or by
malicious or unintentional intrusion from elsewhere.
• Depending on how and to what a Linux machine is connected, the sensitivity of the data it contains and
the uses to which it is put, security can be as simple as turning off unneeded services, monitoring the
Red Hat Linux security mailing list to make sure that all security advisories are followed, and otherwise
engaging in good computing practices to make sure the system runs robustly.
• It is almost full-time job involving levels of security permissions within the system and systems to which
it is connected, elaborate firewalling to protect not just Linux machines but machines that, through
their use of non-Linux software, are far more vulnerable, and physical security.
Page 4 of 26
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V: LINUX – U4
• For any machine that is connected to any other machine, security means hardening against attack and
making certain that no one is using your machine as a platform for launching attacksagainst others. If
you are running Web, ftp, or mail servers, it means giving access to those whoare entitled to it while
locking out everyone else.
• It means making sure that passwords are not easily guessed and not made available to unauthorized
persons like former employees should not have access to the system, and no unauthorized person should
copy files from your machine or machines. As a system administrator keep right balance between
maximum utility and maximum safety.
Q. What is shell? List Different shells in Linux.
SHELL:
• Shell is an interface between operating system kernel and end user. It is the commandinterpreter that
executes other programs.
• It provides a computer user an interface so that the user can run different commands or utilities/tools
with some input data. When it finishes executing a program, it sends an output to the user on the screen.
• $ is called the command prompt or shell prompt.
Several shells are available on RHEL
Bash
• Bash stands for Bourne Again Shell and it is the default shell on many Linux distributions.
• The Bash shell is a combination of features from the Bourne Shell and the C Shell.
• It has a command-line editor that allows the use of the cursor keys in a more "user friendly"
manner than the Korn shell.
Sh
• Bourne shell is referred to as "the shell".
• It is used in single user mode for trouble shooting purpose in Linux Operating systems.
• This is default shell for UNIX operating system.
• There is no option to re-edit previous commands.
• Bourne shell is located under /bin/sh.
• Command to open this shell is $sh
Korn Shell
• This is based on the Bourne shell.
• One enhancement is its command-line editing facility. It is possible using vi to recall and edit
previous commands.
• History mechanism was introduced in this shell.
• korn shell is located under /bin/ksh, if it is installed.
• Command to open this shell is $ksh
• Command to check executed commands $history
C Shell
• The c shell syntax is taken from the C programming language.
• It is a useful tool for anyone familiar with C programming.
• This shell is located under /bin/csh, if it is installed.
• Command to open this shell is $csh
Page 5 of 26
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V: LINUX – U4
tcsh
• tcsh is like C Shell but it has number of enhancements.
• It is very popular with C programmers for R&D purpose.
• This shell is located under /bin/tcsh, if it is installed.
• Command to open this shell is $tcsh
zsh
• A shell that is compatible with Bash but offers even more features.
• This shell is located under /bin/zsh, if it is installed.
nologin
• This shell can be used if you don’t wantto allow the user any interaction with your system
locally.
• It displays a message that an account is not available. It is intended as a replacement shell for
accounts that have been disabled or have other user level access such as ftp, pop3, smtp etc.
Page 6 of 26
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V: LINUX – U4
As an administrator, sometimes we need to manage the commands that are in the history list.There are
two ways of doing this.
1. Manage the file .bash history which stores all of the commands. Every user has such a
file,which is stored in the home directory of the user. If, for example, you want to
delete this file for the user neha, just remove it with the following command
# rm /home/Ramu/.bash history
only root user can do this. Since the name of the file begins with a dot, it is a hidden
file,and normal users cannot see hidden files.
2. A second way of administering history files, which can be done by regular users, is by
usingthe history command with -c option. This will clear the history list for the user who
uses thiscommand.
Q . List and explain commands to perform Basic File System Management Tasks.
• Everything on your RHEL server is stored in a text or ASCII file. Therefore, working with files isa very
important task when administering Linux.
• cd /home — Takes you to the home directory, where user login directories are usuallystored
• cd .. — Takes you to the directory one level up.
• cd ~otheruser — Takes you to otheruser's home directory, if otheruser has granted you
permission.
2. pwd
• The pwd command stands for Print Working Directory. We can often see our current directoryfrom
the command line, but if we cannot see then use this command.
3. mkdir
• If we need to create a new directory, use mkdir. With Linux mkdir, it is possible to create a complete
directory structure in one command using the -p option, something that you cannot do on other
operating systems.
For example, the command #mkdir/some/directory will fail if /some does not exist beforehand.In that
case, we can force mkdir to create /some as well if it doesn’t already exist. Do this by using the #mkdir
-p /some/directory command
4. rmdir
The rmdir command is used to remove directories. This work only on directories that are
already empty. If the directory still has files and/or subdirectories in it, use #rm -rf instead (r-
recursive, f- forcefully).
Page 8 of 26
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V: LINUX – U4
cp original_file /dir1/dir2/new_file
2. Removing Files with rm
Cleaning up the file system is a task that also needs to be performed on a regular basis.
The rm command is used for this purpose. For example, use #rm /tmp/somefile to remove
somefile from the /tmp directory.
There are many options to rm. To view them all, enter man rm at the shell prompt.
• -i (interactive) — This is default option. Prompts you to confirm the deletion. This option canstop
you from deleting a file by mistake.
• -f (force) — Overrides interactive mode and removes the file(s) without prompting. This
might not be a good idea, unless you know exactly what you are doing.
• -v (verbose) — Shows the progress of the files as they are being removed.
• -r (recursive) — Deletes a directory and all files and subdirectories it contains. When this option is
combined with the -f option, the command becomes very powerful. For example, use # rm -rf
/somedir/* to clear out the entire contents of /somedir. This command doesn’t remove the directory
itself, however. If you want to remove the directory in addition to the contents of the directory, use
rm -rf /somedir.
o example, that you type
rm –rf / somedir (with a space between / and somedir)
o instead of
rm -rf /somedir.
o As a result, the rm command will first remove everything in /, and when it is finished
with that, it will remove somedir as well. Note that the second part of the command
is actually no longer required once the first part of the command has completed.
3. Copying Files with cp
• If you need to copy files from one location on the file system to another location, use the
cpcommand.
• To copy a file within the current directory, specify the new name as the third word on
thecommand line.
cp original_file new_file
• This command creates a new file, named new_file, with the same content as the original file.
• To copy a file to a different direcoty, specify a path as the third word on the command line:
cp original_file /dir1/dir2/
• This command creates a copy of original_file in dir2/. If the last part of the path is a filename
instead of a directory, the copy has that new name.
• This creates a new file named new_file with the contents of original_file in dir2/.
Page 9 of 26
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V: LINUX – U4
mv filename /dir1/otherfile
cp /dir1/dir2/filename .
• Alternatively, if you know where the file is and would like to place a copy of it in your
currentdirectory, enter the path as word two and "." as the third word.
• The above command places a copy of filename in your current working directory.
• To copy all files from your home directory to the directory /tmp use cp ~/* /tmp
• If subdirectories and their contents need to be included in the copy command, use the option -r.
• cp normally does not copy hidden files where the name starts with a dot. If you need to
copyhidden fi les as well, make sure to use a pattern that starts with a .(dot). For example,
use cp
~/.* /tmp to copy all files where the name starts with a dot from your home directory to
thedirectory /tmp.
4. Moving Files with mv
• Common useful options for mv include:
o -i (interactive) — Prompts you if the file you have selected overwrites an existing file in
thedestination directory.
o -f (force) — Overrides the interactive mode and moves without prompting. Be very
carefulabout using this option.
o -v (verbose) — Shows the progress of the files as they are being moved.
• To move a file from the current directory to another location, enter a path as the third
word onthe command line.
• This command would remove filename from the current working directory and place it
in /dir1/otherfile directory. If no directory with otherfile name exists in /dir1, the command
willsave the contents of the original file filename under its new name, otherfile, in the
directory
/dir1.
A path to the location of the file may be entered as the second word and "." as the thrid word.This
moves the file from the location specified in word two into our current working directory.
mv ../../filename /tmp/new_name
• The command above moves the file filename from a directory two levels up tothe
/tmp/ directory while renaming the file new_name.
• To rename the directory /somedir to /somethingelse, use command
# mv /somedir /somethingelse
5. Viewing the Contents of Text Files (Q. Explain any five commands to view the contents of text
files)
• head Command
The head command displays the beginning of a file. The format of the head command is:
head <filename>
By default, you can only read the first ten lines of a file. You can change the number of linesdisplayed by
Page 10 of 26
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V: LINUX – U4
The above command would display the first 20 lines of a file named <filename>.
• tail Command
The reverse of head is tail. Using tail, you can view the last ten lines of a file. This can be useful for
viewing the last ten lines of a log file for important system messages. You can also use tail to watchlog
files as they are updated. Using the -f option, tail automatically prints new messages from an open file to
the screen in real-time. For example, to actively watch /var/log/messages, enter the folowing at a shell
prompt (as the root user):
tail -f /var/log/messages
• more Command
The more command is a "pager" utility used to view text in the terminal window one page or screenat a
time. The [Space] bar moves forward one page.
• less Command
The format of the less command is:
less <filename>
The main difference between more and less is that less allows backward and single-line movement using
the same navigation as man pages: press the [Space] bar to go down one page, the [b] to goback one page,
the directional (or "arrow") keys to move one line at a time, and [q] to quit.
To search the output of a text file using less, press [/] and enter the keyword to search for within the file
• cat Command
The cat command can be used to view text, to create text files, and to join files. Its name is shortfor
concatenate, which means to combine files.
Entering the cat command followed by a file name displays the entire contents of the file on the
screen. Press [Ctrl]-[d] keystroke to exit.
Page 11 of 26
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V: LINUX – U4
Create a file using > sign. Every time user use this sign the file is overwritten. If you want to
append to existing file then use >>
• tac <filename>
Page 12 of 26
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V: LINUX – U4
Each line in the file that includes the pattern "pattern" is located and displayed
Each line in the file that includes the pattern "pattern" is located and displayed on the screen
6. Creating Empty Files
• Touch command help us to create empty files in file system.
• For example, use
$touch somefile
to create a zero-byte file with the name somefile in the current directory.
The main purpose of the touch command is to open a file so that the last access date and timeof the file
displayed by ls is modified to the current date and time. For example, touch * will setthe time stamp to
the present time on all files in the current directory
• The piping and redirection options are among the most powerful features of the Linuxcommand
line.
• Piping is used to send the result of a command to another command, and redirection sends theoutput
of a command to a file.
Piping
• The goal of piping is to execute a command and send the output of that command to the next
command so that it can do something with it.
• Exampe 1:
# ps aux
This command provides a list of all the processes that are currently running on your computer.
a = show processes for all users
u = display the process's user/owner
x = also show processes not attached to a terminal
• Example 2:
If we want to check whether a user with the name neha exists in the user database /etc/passwdthen use
cat with grep command.
# cat /etc/password | grep neha
Redirection
• Redirection sends the result of a command to a file. This file can be a text file or a device file.
• There are various types of Redirections.
1. Redirecting Output (STDOUT) to a file
2. Using Redirect ion of STDIN
3. Separating STDERR from STDOUT
Page 13 of 26
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V: LINUX – U4
Q. Explain redirection? How will you redirect output to a file? Explain with example.
OR
What is STDIN and STDOUT in Redirection? Explain with example.
Redirection signs:
Use the single redirector sign (>) if you want to overwrite the content of existing files.
For Example: Existing contents of windows file will be overwritten by contents of linux file.
• Use double redirector sign (>>) if you want to append to the existing files.
Contents of linux file will be appended at the end of windows file.
Page 14 of 26
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V: LINUX – U4
• One of the interesting features of redirection is that, not only it is possible to redirect to regularfiles,
but you can also redirect output to device files.
• In many cases,this works only if you’re at the root.
• important device files that can be used are:
1. /dev/null The null device. Use this device to redirect to nothing.
2. /dev/zero A device that can be used to generate zeros. This can be useful when creatinglarge
empty files.
3. /dev/ttyS0 The first serial port.
4. /dev/lp0 The first legacy LPT printer port.
5. /dev/hda The master IDE device on IDE inter face 0 (hard drive).
6. /dev/hdb The slave IDE device on IDE inter face 0 (not always in use).
7. /dev/hdc The master device on IDE inter face 1 (typically your optical drive).
8. /dev/sda The first SCSI, SAS, serial ATA, or USB disk device in your computer.
9. /dev/sdb The second SCSI or serial ATA device in your computer.
10. /dev/vda The name of your hard disk if you’re working on a vir tual machine in a KVM
virtual environment.
11. /dev/sda1 The first par tition on the first SCSI or serial ATA device in your computer.
12. /dev/tty1 The name of the first text-based console that is active on your computer. Thesettys
are available from tty1 up to tty12.
• For Example:
#cat /etc/passwd > /dev/tty12
• This will move output of passwd file to tty12. To view this, use the Ctrl+F12 key sequence forCLI or
Ctrl+Alt+F12 if you are working in a graphical environment.
5. Cloning Devices Using Output Redirection
• We can redirect contents of a storage device by using redirection.
• For example: We can clone sda disk to sdb by using
# cat /dev/sda > /dev/sdb
• Redirecting to devices, can be very dangerous. Imagine if you use the command cat
/etc/passwd > /dev/sda. It will dump the content of the passwd file to the beginning of the
/dev/sda device. Since you are working on the raw device, no file system information is used,so this
command would overwrite all impor tant administrative information stored at the beginning of the
device.
• A more efficient way to clone devices is to use the dd command. The advantage of using dd isthat it
handles I/O in a much more efficient way.
• To clone a device using dd, use
# dd if=/dev/sda of=/dev/sdb
Before you press Enter, make sure there is nothing you want to keep on the /dev/sdb device.
Page 15 of 26
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V: LINUX – U4
Q .What is a cron file write steps to run a task from cron or job scheduling.
o First there is the cron daemon, a process that starts automatically when your server boots.
o The second part is the cron configuration. This is a set of different configuration files thattell
cron what to do.
• After creating the cron configuration fi le, the cron daemon automatically picks up the changes,and it
will make sure that the job runs at the time indicated.
• The cron daemon checks its configuration every minute to see whether there are any new tasksthat
should be executed.
• cron jobs are started from the directories /etc/cron.hourly, /etc/cron.daily, /etc/cron.weekly, and
/etc/cron.monthly.
• Example: In a crontab specification, the time indicator 0 2 3 4 * indicates that a cron job willstart
on minute 0 of hour 2 (which is 2 a.m.) on the third day of the fourth month. Day of week is
not specified, which means the job would run on any day of the week.
• In a cron job defi nition, we can use ranges as well. For instance, the line */5 * * * 1-5 meansthat a
job has to run every five minutes, but only on Monday through Friday.
• We can also supply a list of comma-separated values, like 0 14,18 * * *, to run a job at 2 p.m.and at
6 p.m.
Page 16 of 26
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V: LINUX – U4
4. Use the vi command :wq! to close the crontab editor and save your changes.
5. Wait five minutes. Then, in a root terminal, type mail to start the command-line mail program to
check mail sent by acuity.
6. Go back to the terminal where you are logged in with the normal user account, and type
$crontab -r.
This deletes the current crontab file for user account acuity.
Q . What are links write steps to create link or explain the concept of hardlink and symbolic
link.
• In a Linux file system, we can access a single file from different locations using links.
• Because of this we need not copy files to different locations and make versions.
• A link looks like a regular file, but it’s more like a pointer that exists in one location to show wehow
to get to another location.
In Linux, there are two different types of links. A symbolic link and Hard link.
Soft Links have different inodes Hard Links have same inodes number as of
numbers than original files. original files.
Soft Link contains the path of original These links have actual file contents.
file and not the contents.
When the original file is removed, the link Even if the original file is removed, the link
becomes a 'dangling' link that pointsto will still show you the contents of the file.
nonexistent file.
You can make soft links to files and You cannot create a Hard Link for a
directories. directory.
Symbolic links can point to any file system Hard links are only valid within the same File
as they are simply the name ofanother System.
file.
The command used for a soft link is “ln the command used for the creation of hardlink
–s” is “ln”
Memory consumption is less Memory consumption is more.
Relative path and absolute path bothare Relative path is not allowed in a hard link.
allowed in soft links
Page 17 of 26
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V: LINUX – U4
Example:
Q. Write short notes on creating backup OR Write steps for Creating Backups OR Write
steps to Archive and extract files using tar.
1. Open a terminal, and use the following command to write an archive of the /etc directory to
/tmp/etc.tar:
# tar -zxvf /tmp/etc.tar /etc
Page 18 of 26
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V: LINUX – U4
• When we connect the device to a directory in the root file system, the process is known as
mounting the device.
• To mount a storage device, you first need to find out two things: what is the name of the
• device and the directory to mount it.
• The easiest way to setup a printer is by using the graphical system-config-printer utility.This
utility helps in setting up a local printer that is connected directly to your computer. It also gives you
access to remote print queues.
• CUPS (Common UNIX Print System) use the Internet Printing Protocol (IPP), a generic standard for
printer management. You can also manage your CUPS environment using a web-based interface that
is available at http://localhost:631
Page 19 of 26
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V: LINUX – U4
• Tasks that run at given moment on Red Hat Enterprise Linux Server are referred to asprocesses.
• Managing processes is an important work for a system administrator.
Page 20 of 26
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V: LINUX – U4
1. SIGTERM is used to ask a process to stop its activity, the process close all open files and stopusing
its resources.
2. SIGKILL, doesn’t allow the process any time at all to stop its activity; that is, the process is
simply cut off, hence there is risk of damaging open files.
• For example: # kill -9 123 or kill -SIGKILL 123
• The above command sends the SIGKILL signal to the process with PID 123.
3. SIGHUP signal tells a process that it should reinitialize and read its configuration files again.
killall Command:
• When using the kill command, you can use the PIDs of multiple processes to send specificsignals
to multiple processes simultaneously.
• Another way is to use killall command, which takes the name of a process as its argument.
• For example: # killall -SIGTERM hpptd
• The above command sends the SIGTERM signal to all active httpd processes.
Page 21 of 26
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V: LINUX – U4
o their names;
o the access, creation, or modification date;
o the user who created them;
o the permissions set on the file; etc.
• Example 1:If we want to find all files whose name begins with hosts, use
# find / -name "hosts*"
• Example 2:Find is useful to locate files that belong to a specific user. Command to locate allfiles
created by user maya.
# find / -user "maya"
Page 22 of 26
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V: LINUX – U4
Q . List different query options for installed packages OR What are the general RPM
command line options?
• Software installed on your computer may become damaged. In this situation you can extractfiles
from the packages and copy them to the original location of the fi le.
Page 23 of 26
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V: LINUX – U4
• Every RPM package consists of two parts: the metadata part that describes what is in the
package and a cpio archive that contains the actual files in the package.
• If a file has been damaged, you can start with the rpm -qf queryoption to find out from what
package the file originated.
• Next use rpm2cpio | cpio -idmv to extract the files from the package to a temporary location.
Example:
1. Use rm -f /usr/sbin/modem-manager.
2. Use rpm -qf /usr/sbin/modem-manager. This command shows that the file comes from the
ModemManager package.
3. Copy the ModemManager package file from the repository cp /repo/ModemM[Tab] /tmp
command.
4. Change the directory to the /tmp, and use rpm2cpio |cpio -idmv to extract the package.
The command in step 4 created a few subdirectories in /tmp. Activate the directory /tmp/usr/sbin,where
you can find the modem-manager file. We can now copy it to its original location in /usr/sbin
RPM YUM
RPM is the RedHat Package Manager. Meta Package Handler, which in Red Hat is
known as yum (Yellowdog Update Manager)
RPM cannot resolve dependencies on its own. YUM resolves dependencies with ease. It can
find dependencies and download required
files even if they're not in the system.
If we want to install an application(Ex: apache), Install an application with single command
rpm need to install all the packages required for Ex: yum install httpd
this application, these packages may vary from
1 rpm to several rpm’s depending on shared
rpm packages.
with the "rpm" command, you need to know with "yum", you just need to know the name
theexact location of the .rpm package of package, and if it's available through your
repositories list, it will be installed along with
its dependencies
RPM can’t handle updated software installation Does YUM install updates of the existing
automatically packages by using
yum install upgrade
RPM allows to install more than one version of YUM will inform us the previous version of the
any file at the same time. package that is already installed in your
system. It does not allow us to install its
multiple versions.
Page 24 of 26
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V: LINUX – U4
RPM Cannot connect to online repositories YUM can connect to on-line repositories to
get latest software before installing the
applications.
These are the package manager of Redhat Distro. This command also checks the repository metadata for
files that are in a package, and it tells you exactly which package you need to find a specific file.
Package manager tool is for installing, updating, removing, and managing software packages in Red
Hat Enterprise Linux System.
yum uses numerous third-party repositories to install packages automatically by resolving their
dependencies issues.
yum also install any dependencies which is related to that packages.
For the update of the system via yum you required internet connection.
So in CentOS, Redhat, Fedora we use yum package Installer & In Ubuntu, Debian system you use apt-
get package installer
Q . What is a repository write steps to create and manage a repository OR How to set up your
own repository?
• If you have a Red Hat server installed that doesn’t have access to the official Red Hat Network(RHN)
server repositories, you’ll need to set up your own repositories.
• This procedure is also useful if you want to copy all of your RPMs to a directory and use that
directory as a repository.
1. Create a directory that you can use as a repository in the root of your server’s file system.
# mkdir /repo
2. Insert the Red Hat installation DVD in the optical drive of your server. Assuming that you runthe
server in graphical mode, the DVD will be mounted automatically.
5. Create the metadata that allows you to use the /repo directory as a repository.
Page 25 of 26
YouTube - Abhay More | Telegram - abhay_more
607A, 6th floor, Ecstasy business park, city of joy, JSD road, mulund (W) | 8591065589/022-25600622
TRAINING -> CERTIFICATION -> PLACEMENT BSC IT : SEM – V: LINUX – U4
# createrepo /repo
6. Create a file with the name /etc/yum.repos.d/myrepo.repo using vi editor.
# vi /etc/yum.repos.d/myrepo.repo
[myrepo]
name=myrepo
baseurl=file:///re
pogpgcheck=0
7. Check outputs.
# yum repolist
# yum search nmap
• In myrepo.repoconfiguration file, The file:// part is the URI, which tells yum that it has to look ata
file, and after that,you need a complete path to the file or directory i.e/repo.
To check whether packages have been tampered usegpgcheck=1 else gpgcheck=0. If it is setto 1 then we
need to configure GPG check
When using the nice command, we can adjust the process niceness from -20, which is good forthe
most favorable scheduling, to 19 for the least favorable scheduling.
By default, all processes are started with a niceness of 0.
For example: you want to adjust the niceness of the find command, then get PID using followingcommand.
# ps aux | grep find
Assuming the PID is 1234, you can use
# renice -10 1234