Linux Unit1 Notes
Linux Unit1 Notes
Linux Unit1 Notes
Unit 1
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.
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.
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.
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.
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.
Now, Red Hat has employed innovations that extend these duties even for the experienced Linux user.
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.
Bash also has this feature, but it goes beyond the option of simply completing commands.
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
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