Linux Unit1 Notes

Download as pdf or txt
Download as pdf or txt
You are on page 1of 35

Linux System Administration

Unit 1

Introduction to Red Hat Enterprise Linux:

1. Linux
2. Open Source & Red Hat
3. Origins of Linux
4. Distribution
5. Duties of Linux System Administration
Linux
Some people (mis)understand Linux to be an entire software suite of developer tools, editors, graphical user
interfaces (GUIs), networking tools, and so forth.

More formally and correctly, such software collectively is called a distribution.

Linux itself is the core of the operating system: the kernel.

The kernel is the program acting as chief of operations.

It is responsible for starting and stopping other programs (such as text editors, web browsers, services, and so on),
handling requests for memory, accessing disks, and managing network connections.

You’ve most likely heard of the Linux distributions named Red Hat Enterprise Linux (RHEL), Fedora, Debian,
Mageia, Ubuntu, Mint, openSUSE, CentOS, Arch, Chrome OS, Slackware, and so on.
Linux
Linux distributions can be broadly categorized into two groups.

The first category includes the purely

1) commercial distros,
2) noncommercial distros.
● The commercial distros generally offer support for their distribution—at a cost. The commercial distros
also tend to have a longer release life cycle. Examples of commercial flavors of Linux-based distros are
RHEL and SUSE Linux Enterprise (SLE).
● The noncommercial distros, on the other hand, are free. These distros try to adhere to the original spirit
of the open source software movement. They are mostly community supported and maintained—the
community consists of the users and developers. The community support and enthusiasm can sometimes
supersede that provided by the commercial offerings.
Open Source Software
In the early 1980s, Richard Matthew Stallman began a movement within the software industry.

He preached (and still does) that software should be free. Note that by free, he doesn’t mean in terms of price, but
rather free in the same sense as freedom or libre.

Stallman’s concept of open source software was in line with the initial distributions of UNIX from Bell Labs.

Early UNIX systems did contain full source code. Yet by the late 1970s, source code was typically removed from UNIX
distributions and could be acquired only by paying large sums of money to AT&T (now SBC).

The Berkeley Software Distribution (BSD) maintained a free version, but its commercial counterpart, BSDi, had to deal
with many lawsuits from AT&T until it could be proved that nothing in the BSD kernel came from AT&T.
Open Source Software (Continued ..)
The idea of giving away source code is a simple one: A user of the software should never be forced to deal with a
developer who might or might not support that user’s intentions for the software.

The user should never have to wait for bug fixes to be published.

More important, code developed under the scrutiny of other programmers is typically of higher quality than code
written behind locked doors.

One of the great benefits of open source software comes from the users themselves: Should they need a new feature,
they can add it to the original program and then contribute it back to the source so that everyone else can benefit
from it.

This line of thinking sprung a desire to release a complete UNIX-like system (Linux) to the public, free of license
restrictions.

Of course, before you can build any operating system, you need to build tools. And this is how the GNU project and its
namesake license were born.
Origin of Linux
The late 1960s and early 1970s were the dawn of the modern computing era. It was the period of proprietary stacks,
where a vendor would build a “closed” computer system and create the operating software to run on it.

It was normal for computer programmers to address the hardware directly, using very complex assembly programming
languages

An important step forward was the development of the general-purpose programming language C by Dennis Richie at
Bell Telephone Laboratories in 1969.

This language was developed for use with the UN IX operating system

The UN IX operating system was the fi rst operating system where people from different companies tried to work
together to build instead of competing with each other, keeping their efforts secret.

This spirit brought UN IX to scientifi c, government, and highereducation institutions. There it also became the basis
for the rise of another phenomenon, the Internet Protocol (IP) and the Internet.

One of the huge contributors to the success of UN IX was the spirit of openness of the operating system. Everyone
could contribute to it, and the specifications were freely available to anyone.
Origin of Linux
Because of the huge success of UNIX, companies started claiming parts of this operating system in the 1970s.

They succeeded fairly well, and that was the beginning of the development of different flavors of UNIX, such as BSD,
Sun Solaris, and H P AIX.

Instead of working together, these UNIX flavors worked beside one another, with each sponsoring organization trying
to develop the best version for a specific solution

During the 1980s, many common Unix commands, tools, and applications were developed until, in 1991, the last gap
was filled in with the launch of the Linux kernel by a student at the University of Helsinki in Finland, Linus Torvalds.

The interesting fact about the Linux kernel is that it was never developed to be part of the GNU project. Rather, it was
an independent initiative.

Torvalds just needed a license to ensure that the Linux kernel would be free software forever, and he chose to use the
GNU General Public License (GPL) for this purpose.

The GPL is a copyleft license, which means that derived works can be distributed only under the same license terms.
Distributions
With the adoption of the Linux kernel, finally everything that was needed to create a complete operating system was in place.

There were many GNU utilities to choose from, and those tools, together with a kernel, made a complete operating system.

The only thing enthusiastic users still needed to do was to gather this software, compile it from source code, and install the working parts on
a computer

Among the first was MCC Interim Linux, a distribution made available for public download in February 1992.

Patrick Volkerding released a distribution called Slackware

In 1993, Marc Ewing and Bob Young founded Red Hat, the first Linux distributor operating as a business. Since then, Red Hat has acquired
other companies to integrate specific Linux-related technologies.

Today Linux in general and Red Hat Linux in particular is at the heart of the IT organization in many companies.

Large parts of the Internet operate on Linux

One reason why Red Hat has been so successful since the beginning is the level of support the company provides.
Distributions
The three types of Linux support provided by Red Hat are as follows:

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.

Software Support Red Hat has agreements with every major enterprise software vendor to make 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 vendor of the operating system.

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.
Fedora
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 tackle 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 eventually be included in Red Hat Enterprise
Linux.

If you want to know what will be included in future versions of Red Hat Linux, Fedora is the best place to look.

Also, Fedora makes an excellent choice to install on your personal computer, because it offers all the functions you
would expect from a modern operating system—even some functions that are of interest only to home users
Red Hat Enterprise Linux and Related Products
The core of the Red Hat offering is Red Hat Enterprise Linux.

This is the basis for two editions: a server edition and a workstation edition.

The RHEL Server edition is the highly successful Red Hat product that is used in companies around the globe.

1) Red Hat Enterprise Linux Server Edition


2) Red Hat Enterprise Linux Workstation Edition
Red Hat Enterprise Linux Server Edition
With the Red Hat Enterprise Linux Server edition, there is a major new release about every
three to four years.
In between the major updates, there are minor ones, represented by the number after the dot
in the version number.
Apart from these releases, Red Hat provides patches to fix bugs and to apply security updates.
Typically, these patches are applied by using the Red Hat Network, a certified collection of
repositories where Red Hat makes patches available after verifying them.
To download and install repositories from the Red Hat Network (RHN), a current
subscription is required.
Without a current subscription, you can still run RHEL, but no updates will be installed
through RHN.
As an alternative to connecting each server directly to RHN, Red Hat provides a solution
called Satellite.
Red Hat Enterprise Linux Workstation Edition
The other product that falls under Red Hat Enterprise Linux is the Workstation edition.
This solution is based on the same code as RHEL Server.
Also, the same license conditions apply for RHEL Workstation as for RHEL Server, and you
need a current subscription to access and install updates from RHN.
To date, Red Hat Linux Workstation hasn’t experienced the same level of success as Red Hat
Linux Enterprise Server
Duties of Linux System Administrator.
LINUX IS A MULTIUSER, multitasking operating system from the ground up, and in this regard the system
administrator has flexibility — and responsibility — far beyond those of other operating systems.

Now, Red Hat has employed innovations that extend these duties even for the experienced Linux user.

1) The Linux system administrator


2) Installing and configuring servers
3) Installing and configuring application software
4) Creating and maintaining user accounts
5) Backing up and restoring files
6) Monitoring and tuning performance
7) Configuring a secure system
8) Using tools to monitor security
The Linux System Administrator
The Linux system administrator is more likely to understand the necessity of active system
administration than are those who run whatever came on the computer, assuming that things
came from the factory properly configured.
The user or enterprise that decides on Linux has decided, too, to assume the control that
Linux offers, and the responsibilities that this entails.
By definition, the Linux system administrator is the person who has “root” access, which is to
say the one who is the system’s “super user” (or root user).
A standard Linux user is limited as to the things he or she can do with the underlying engine
of the system.
But the “root” user has unfettered access to everything — all user accounts, their home
directories, and the files therein; all system configurations; and all files on the system
The system administrator has full system privileges, so the first duty is to know what you’re
doing lest you break something
Installing and Configuring Servers
In the Linux world, the word “server” has a meaning that is broader than you might be used to.
For instance, the standard Red Hat Linux graphical user interface (GUI) requires a graphical layer called
XFree86.
This is a server. It runs even on a standalone machine with one user account. It must be configured
Likewise, printing in Linux takes place only after you have configured a print server. Again, this has
become so easy as to be nearly trivial
In certain areas the client-server nomenclature can be confusing, though. While you cannot have a
graphical desktop without a server, you can have World Wide Web access without a Web server, file
transfer protocol (FTP) access without running an FTP server, and Internet e-mail capabilities without
ever starting a mail server.
Installing and Configuring Application Software
This may seem redundant, but it’s crucial that the new Linux system administrator understand two characteristics that set
Linux apart from popular commercial operating systems:
The first is the idea of the root or super user, and the second is that Linux is a multiuser operating system.
Each user has (or shares) an account on the system, be it on a separate machine or on a single machine with multiple
accounts.
One reason that these concepts are crucial is found in the administration of application software — productivity
programs.
While it is possible for individual users to install some applications in their home directories — drive space set aside for
their own files and customizations — these applications are not available to other users without the intervention of the
system administrator.
Besides, if an application is to be used by more than one user, it probably needs to be installed higher up in the Linux
file hierarchy, which is a job that can be performed by the system administrator only.
Creating and Maintaining User Accounts
Not just anyone can show up and log on to a Linux machine. An account must be created for each user and — you
guessed it — no one but the system administrator may do this.
But there’s more, and it involves decisions that either you or your company must make.
You might want to let users select their own passwords, which would no doubt make them easier to remember, but
which probably would be easier for a malefactor to crack.
You might want to assign passwords, which is more secure in theory but which increases the likelihood that users will
write them down on a conveniently located scrap of paper — a risk if many people have access to the area where the
machine(s) is located
These issues and others are parts of the system administrator’s duties in managing user accounts.
Whether the administrator or his or her employer establishes the policies governing them, those policies should be
established — if in an enterprise, preferably in writing — for the protection of all concerned.
Backing Up and Restoring Files
Until equipment becomes absolutely infallible, and until people lose their desire to harm the property of others (and,
truth be known, until system administrators become perfect), 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 the system administrator may do this.
Again, knowing that file backup is your job is not enough. You need to formulate a strategy for making sure your system
is not vulnerable to catastrophic disruption
Once you’ve decided what to back up, you need to decide how frequently you want to perform backups and whether you
wish to maintain a series of incremental backups — adding only the files that have changed since the last backup — or
multiple full backups, and when these backups are to be performed
Monitoring and Tuning Performance
The default installation of Red Hat Linux goes a long way toward capitalizing on existing system resources. But there is
no “one size fits all” configuration, and Linux is infinitely configurable or close to it.
On a modern stand-alone system, Linux is going to be pretty quick, and if it isn’t, there’s something wrong — something
that is up to the system administrator to fix
System tuning is an ongoing process aided by a variety of diagnostic and monitoring tools. Some performance decisions
are made at installation time, while others are added or tweaked later.
Proper monitoring allows you to detect a misbehaving application that might be consuming more resources than it should
or failing to exit completely on close.
Through the use of system performance tools you can determine when hardware — such as memory, added storage, or
even something as elaborate as a hardware RAID — should be upgraded for more cost-effective use of a machine in the
enterprise or for complicated computational tasks such as three-dimensional rendering.
Configuring a Secure System
If there is a common thread in Linux system administration, something that is a constant presence in everything you do,
it is the security of the computer and data integrity.
What does this mean? Well, just about everything.
The system administrator’s task, first and foremost, is to make certain 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
inadvertent 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
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 attacks against others.
Using Tools to Monitor Security
Crackers — people who, for purposes of larceny or to amuse themselves, like to break into other people’s computers —
are a clever bunch.
If there is a vulnerability in a system, they will find it.
Fortunately, the Linux development community is quick to find potential exploits and to find ways of slamming shut the
door before crackers can enter.
Fortunately, too, Red Hat is diligent in making available new, patched versions of packages in which potential exploits
have been found.
So your first and best security tool is making sure that whenever a security advisory is issued, you download and install
the repaired package
And as good as the bug trackers are, sometimes their job is reactive.
Preventing the use of your machine for nefarious purposes and guarding against intrusion are, in the end, your
responsibility alone.
Again, Red Hat Linux equips you with tools to detect and deal with unauthorized access of many kinds.
Chp 2 - Command Line

Working with the Bash Shell

1) To communicate commands to the operating system kernel, an interface is needed that sits between the
kernel and the end user issuing these commands.
2) This interface is known as the shell.
3) Several shells are available on RHEL.
4) Bash (short for the Bourne Again Shell) is the one that is used in most situations. This is because it is
compatible with the Bourne shell, which is commonly found on UNIX servers.
5) You should, however, be aware that Bash is not the only shell that can be used.

tcsh A shell with a scripting language that works like the C programming language. It is very popular with C
programmers.

zsh A shell that is compatible with Bash but offers even more features.

sash This stands for stand-alone shell. This is a minimal-feature shell that runs in almost all environments.
Therefore, it is very well suited for system troubleshooting.
Getting the Best of Bash
Basically, from the Bash environment, an administrator is working with commands.

An example of such a command is ls, which can be used to display a list of files in a given directory.

To make working with these commands as easy as possible, Bash has some useful features to offer.

Some of the most used Bash features are automatic completion and the history mechanism.

Some shells offer the option to complete a command automatically.

Bash also has this feature, but it goes beyond the option of simply completing commands.

Bash can complete almost everything, not just commands.

It can also complete filenames and shell variables


Using Bash Key Sequences
Sometimes, you will enter a command from the Bash command line and nothing, or something totally unexpected, will
happen.

If that occurs, it is good to know that some key sequences are available to perform basic Bash management tasks.

1) Ctrl+C : Use this key sequence to quit a command that is not responding (or simply is taking too long to
complete). This key sequence works in most scenarios where the command is active and producing screen
output.

1) Ctrl+D This key sequence is used to send the end-of-file (EOF) signal to a command. Use this when the
command is waiting for more input. It will indicate this by displaying the secondary prompt >.

1) Ctrl+R This is the reverse search feature. When used, it will open the reverse-i-search prompt. This feature helps
you locate commands you have used previously. The feature is especially useful when working with longer
commands. Type the first characters of the command, and you will immediately see the last command you used
that started with the same characters.
Using Bash Key Sequences

● Ctrl+Z Some people use Ctrl+Z to stop a command. In fact, it does stop your command, but it does not
terminate it. A command that is interrupted with Ctrl+Z is just halted until it is started again with the fg
command as a foreground job or with the bg command as a background job.

● Ctrl+A The Ctrl+A keystroke brings the cursor to the beginning of the current command line.

● Ctrl+B The Ctrl+B keystroke moves the cursor to the end of the current command line.
Working with Bash History

● Another useful aspect of the Bash shell is the history feature.


● The history mechanism helps you remember the last commands you used.
● By default, the last 1,000 commands of any user are remembered.
● History allows you to use the up and down arrow keys to navigate through the list of commands that you used
previously.
● You can see an overview of these remembered commands when using the history command from the Bash
command line.
● This command shows a list of all of the recently used commands.
● From this list, a command can also be restarted
Working with Bash History
Using ! to Run Recent Commands

You can also repeat commands from history using !. Using !, you can repeat the most recent command you used that
started with the same string.

For example, if you recently used useradd linda to create a user with the name linda, just entering the characters !us
would repeat the same command for you.
Working with Bash History
As an administrator, you sometimes need to manage the commands that are in the history list. There are two ways of
doing this.

● First you can manage the file .bash_history , which stores all of the commands you have used before. 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 joyce, just remove it with the command rm /home/joyce/. Bash_history. Notice that you must be at
the root to do this. Since the name of the file begins with a dot, it is a hidden file, and normal users cannot see
hidden files.
● A second way of administering history files, which can be accomplished by regular users, is by using the history
command. The most important option offered by this Bash internal command is the option -c. This will clear the
history list for the user who uses this command. So, use history -c to make sure that your history is cleared. In
that case, however, you cannot use the up arrow key to access commands used previously
Performing Basic File System Management Tasks
Working with Directories Commands:

1) Cd : Use this command to change the current working directory. When using cd, make sure to use proper syntax.
First, names of commands and directories are case-sensitive; therefore, /bin is not the same as /BIN. Next, you
should be aware that Linux uses a forward slash instead of a backslash.

2) Pwd: The pwd command stands for Print Working Directory. You can often see your current directory from the
command line, but not always. If the latter is the case, pwd offers help.

3) Mkdir: If you 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, you 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. Be aware, however, that it is not the most useful
command available, because it will work only on directories that are already empty. If the directory still has files
and/or subdirectories in it, use rm -r instead
Working with Files
● Using ls to List Files: the ls command displays the list of files available in the directory but these files have their own details.
Wildcards can be used when working with the ls command. For example, ls * will show a list of all fi les in the current
directory, ls / etc/*a.* will show a list of all fi les in the directory /etc that have an a followed by a . (dot) somewhere in the fi
lename, and ls [abc]* will show a list of all fi les where the name starts with either a, b, or c in the current directory. Now
without the option –d, something strange will happen
● Removing Files with rm: Cleaning up the fi le 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. If you are
at the root and have all the proper permissions. for this file (or if you are the root), you will succeed without any problem.
Since removing files can be delicate (imagine removing the wrong files), the shell will ask your permission by default.
Therefore, it may be necessary to push the rm command a little. You can do this by using the -f (force) switch. For example,
use rm -f somefile if the command states that some file cannot be removed for some reason
● Copying files with cp: If you need to copy fi les from one location on the file system to another location, use the cp
command. This straightforward command is easy to use. For example, use cp ~/* / tmp to copy all files from your home
directory (which is referred to with the ~ sign) to the directory /tmp. If subdirectories and their contents need to be included in
the copy command, use the option -r. You should, however, be aware that cp normally does not copy hidden fi les where the
name starts with a dot.
Working with Files (Continued ..)
● Moving files with mv: An alternative method for copying fi les is to move them. In this case, the fi le is removed from its
source location and placed in the target location. For example, use mv ~/somefile /tmp/otherfile to move the filename
somefile to /tmp. If a subdirectory with the name otherfile exists in /tmp, somefile will be created in this subdirectory. If,
however, no directory with this name exists in /tmp, the command will save the contents of the original file somefile under its
new name, otherfile, in the directory /tmp.
● Viewing the contents of Text Files: When administering your RHEL server, you will very often find that you are modifying
configuration fi les, which are all ASCII text files.
○ Cat: This command displays the contents of a fi le by dumping it to the screen. This can be useful if the contents of the fi le do not fit on the
screen. You will see some text scrolling by, and as the fi nal result, you will see only the last lines of the fi le being displayed on the screen.
○ Tac: This command does the same thing as cat but inverts the result; that is, not only is the name of tac the opposite of cat, but the result is
the opposite as well. This command will dump the contents of a fi le to the screen, but with the last line first and the first line last.
○ Tail: This command shows only the last lines of a text fi le. If no options are used, this command will show the last 10 lines of a text file. The
command can also be modified to show any number of lines on the bottom of a fi le. For example, tail -n 2 /etc/passwd will show you the last
two lines of the confi guration fi le where usernames are stored. The option to keep tail open on a given log fi le is also very useful for
monitoring what happens on your system. For example, if you use tail -f /var/log/messages, the most generic log fi le on your system is
opened
○ Head: This command is the opposite of tail. It displays the first lines of a text file.
○ Less: The last command used to monitor the contents of text fi les is less. This command will open a plain-text fi le viewer. In the viewer,
you can browse the fi le using the Page Down key, Page Up key, or spacebar.
○ More: This command is similar to less but not as advanced
Working with Files (Continued ..)
● Creating empty files: It is often useful to create fi les on a fi le system. This is a useful test to check to see whether a file
system is writable. The touch command helps you do this. For example, use touch somefile to create a zero-byte file with the
name somefile in the current directory. It was never the purpose of touch to create empty fi les. The main purpose of the touch
command is to open a fi le so that the last access date and time of the fi le displayed by ls is modified to the current date and
time. For example, touch * will set the time stamp to the present time on all fi les in the current directory
Piping and Redirection
Piping
Piping is used to send the result of a command to another command

Redirection
It sends the output of a command to a file

You might also like