Instructor Zia Uddin Siddiqui
Instructor Zia Uddin Siddiqui
Instructor Zia Uddin Siddiqui
• Linux is also a full 32- bit operating system, utilizing the special protected-
mode features of Intel 80386 and later processors and their work-alikes.
Major Features of Linux ….
• The X Window System
• The X Window System is the de facto industry-standard graphics system for
UNIX machines.
• With an Ethernet connection, you can have access to the Internet or to a local
area network from your Linux system.
• Using SLIP (Serial Line Internet Protocol) or PPP (Point to Point Protocol),
you can access the Internet over phone lines with a modem.
Major Features of Linux ….
• Virtual memory and shared libraries
• Linux can use a portion of your hard drive as virtual memory, expanding your
total amount of available RAM.
• Linux also implements shared libraries, allowing programs that use standard
subroutines to find the code for these subroutines in the libraries at runtime.
• This saves a large amount of space on your system; each application doesn't
store its own copy of these common routines.
Major Features of Linux ….
• The Linux kernel uses no code from AT&T or any other proprietary source.
• Much of the software available for Linux is free.
• In fact, a large number of utilities in Linux are developed by the GNU
project at the Free Software Foundation in Cambridge, Massachusetts.
• However, Linux enthusiasts, hackers, programmers, and recently even
commercial companies from all over the world have contributed to the
growing pool of Linux software.
• Linux supports (almost) all of the features of commercial versions of UNIX.
In fact, some of the features found in Linux may not be available on other
proprietary UNIX systems.
Major Features of Linux ….
• GNU software support.
• Linux supports a wide range of free software written by the GNU Project,
including utilities such as the GNU C and C++ compiler, gawk, groff, and so
on.
• Many of the essential system utilities used by Linux are GNU software.
Major Features of Linux ….
• Virtual memory support.
• Linux utilizes all of your system's memory, without memory limits or
segmentation through the use of a virtual memory manager.
Major Features of Linux ….
• Built-in support for networking, multitasking, and other features.
• You'll see this touted as "New Technology" in systems such as Windows NT.
In fact, UNIX (and now, Linux) has implemented this "new technology" for
more than 15 years.
• Linux is cheaper to get than most commercially available UNIX systems and
UNIX clones.
• If you have the patience and access to the Internet, the only price you pay for
Linux is your time. Linux is freely available on the Internet.
Major Distributions
• Seven distributions have emerged as most common. These are:
• Red Hat has gained fame particularly for its tools for installing and
upgrading the operating system and for its well-designed system for
installing, uninstalling, and tracking software application packages.
Installation Procedure
• The first thing to do before you start is to know what hardware is in
the computer you are going to install Linux on.
• You must know at least the manufacturer and model number of
devices such as your monitor, sound card, VGA card.
• This information can be obtained if MS Windows is already installed
on the computer.
• You can collect this information from the MS Windows control panel.
• Some of this information may not be relevant to all installations and
can be ignored.
• Once you know that hardware in your computer, the next step is to
determine how to install the Linux operating system.
• From amongst the various ways to install Linux, the easiest one is
installing from the bootable installation CD- ROMs.
• But a pre-requisite is that your computer must be able to boot from
CD-ROM. Boot sequence can be modified in a computer‘s BIOS.
• If the computer does not permit booting from CD-ROM, one
alternative is to run the autoboot.bat file from the dosutils directory on
the RedHat installation CD.
• Another alternative is to install from a Linux installation boot disk.
• The disk image for the boot disk is available on the images directory
on your RedHat installation CD as boot.img.
• Once you have located the boot image, you need a blank formatted
1.44 MB disk and a disk image utility such as rewrite.
Installation classes
Red Hat Linux provides five different classes, or types, of installations:
• Workstation: A workstation installation is most appropriate if you are
new to the world of Linux, and would like to give it a try. A
workstation installation will create a system for your home or desktop
use. A graphical, Windows-like environment will be installed.
• Server: A server installation is most appropriate if you would like your
system to function as a Linux- based server, and you do not want to
heavily customize your system configuration.
Installation classes….
• Laptop: A laptop installation has been designed to make installing Red
Hat Linux on laptops even easier. Much like a workstation installation,
it will make sure you have the appropriate packages needed, as well as
offer you an automated installation environment.
• Custom: A custom installation allows you the greatest flexibility
during your installation. You choose your boot loader, which packages
you want, and more. Custom installations are most appropriate for
those users more familiar with Red Hat Linux installations and for
those afraid of losing complete flexibility.
Upgrade
• If you already have a version of Red Hat Linux (4.2 or greater)
running on your system and you want to quickly update to the latest
packages and kernel version, then an upgrade is most appropriate for
you.
• These classes give you the option of simplifying the installation
process (with some potential for loss of configuration flexibility), or
retaining flexibility with a slightly more complex installation process.
Workstation Installations
• Most suitable for new users, the workstation installation will install your
choice of the GNOME or KDE desktop environments, or both, and the X
Window System (the graphical software on which the desktop environments
are based).
• Below are the minimum recommended disk space requirements for a
workstation installation where only one language (such as English) will be
installed.
• Workstation choosing GNOME or KDE : 1.5 GB
• Workstation choosing both GNOME and KDE, and games: 1.8 GB
• If you plan to choose all package groups (for example, GNOME is a group
of packages), as well as select additional individual packages, you may
want to allow yourself 2.1 GB or more of disk space.
What a Workstation Installation Will Do
• If you choose automatic partitioning, a workstation installation will
create the following partitions:
• The size of the swap partition is determined by the amount of RAM in
your system and the amount of space available on your hard drive. For
example, if you have 128 MB of RAM then the swap partition created
can be 128 MB – 256 MB (twice your RAM), depending on how
much disk space is available.
• A 50 MB partition mounted as /boot in which the Linux kernel and
related files reside.
• A root partition mounted as / in which all other files are stored (the
exact size of this partition is dependent on your available disk space).
Server Installations
• A server installation is most appropriate for you if you would like your
system to function as a Linux- based server, and you do not want to
heavily customize your system configuration.
• Below are the minimum recommended disk space requirements for a
server installation where only one language (such as English) will be
installed.
• Server (minimum, no graphical interface): 1.3 GB
• Server (choosing everything, no graphical interface): 1.4 GB
• Server (choosing everything, GNOME and KDE): 2.1 GB
Server Installations ….
• If you plan to choose all group packages, as well as select additional
individual packages, you may want to allow yourself 2.3 GB or more
of disk space.
• During the server installation, the X Window System is not configured
and no GUI will be loaded when the system boots, unless you choose
to install the appropriate packages during package selection.
What a Server Installation Will Do
• The size of the swap partition is determined by the amount of RAM in
your system and the amount of space available on your hard drive.
For example, if you have 128 MB of RAM then the swap partition
created can be 128 MB - 256 MB (twice your RAM), depending on
how much disk space is available.
• A 384 MB root partition mounted as /.
• A partition mounted as /usr (the exact size of this partition is
dependent on your available disk space).
• A partition mounted as /home (the exact size of this partition is
dependent on your available disk space).
What a Server Installation Will Do….
• 256 MB partition mounted as /var.
• A 50 MB partition mounted as /boot in which the Linux kernel and
related files are kept.
• This disk partitioning scheme results in a reasonably flexible file
system configuration for most server tasks.
Laptop Installations
• The laptop installation will install your choice of the GNOME or KDE
desktop environments (or both) and the X Window System.
• Below are the minimum recommended disk space requirements for a
laptop installation where only one language (such as English) will be
installed.
• Laptop choosing GNOME or KDE: 1.5 GB
• Laptop choosing both GNOME and KDE: 1.8 GB
Laptop Installations
• If you plan to choose all package groups (for example, GNOME is a
group of packages), as well as select additional individual packages,
you may want to allow yourself 1.7 GB or more of disk space. If you
provide this extra space, you will have room for additional data, if
needed.
What a Laptop Installation Will Do
• If you choose automatic partitioning, a laptop installation will create
the following partitions:
• The size of the swap partition is determined by the amount of RAM in
your system and the amount of space available on your hard drive. For
example, if you have 128 MB of RAM then the swap partition created
can be 128 MB - 256 MB (twice your RAM), depending on how much
disk space is available.
• A 50 MB partition mounted as /boot in which the Linux kernel and
related files reside.
• A root partition mounted as / in which all other files are stored (the
exact size of this partition is dependent on your available disk space).
Custom Installations
• The custom installation allows you the most flexibility during your
installation.
• The workstation and server installations automatically go through the
installation process for you and omit certain steps.
• During a custom installation, you have complete control over the
packages that will be installed on your system.
• The recommended disk space requirements for a custom installation
are as follows:
• Custom (minimum): 350 MB
• Custom (choosing everything): 3.7 GB
What a Custom Installation Will Do
• As you might guess from the name, a custom installation puts the
emphasis on flexibility. You have complete control over which
packages will be installed on your system.
• If you choose automatic partitioning, a custom installation will create
the following partitions:
• The size of the swap partition is determined by the amount of RAM in
your system and the amount of space available on your hard drive.
For example, if you have 128 MB of RAM then the swap partition
created can be 128 MB - 256 MB (twice your RAM), depending on
how much disk space is available.
What a Custom Installation Will Do….
• A 50 MB partition mounted as /boot in which the Linux kernel and
related files reside.
• A root partition mounted as / in which all other files are stored (the
exact size of this partition is dependent on your available disk space).
Recommendation
• We recommend using Custom installation and selecting only the
modules and packages that you need.
• You may delete the existing hard disk partitions in use by MS
Windows and create partitions for Linux from scratch.
• It is also possible to let MS Windows and Linux co-exist and choosing
between them when the computer boots.
• The Red Hat Linux text mode installation program uses a screen-based
interface that includes most of the on-screen "widgets" commonly
found on graphical user interfaces.
• The following screen shots illustrate what you will see.
Lab Session 02
• Or if the command is not on your path type the complete path and
name of the command such as:
• $ /usr/bin/command.
Linux Command
• Some of the frequently used Linux commands are:
• su
• pwd, cd , and ls
• more and less
• find and grep
• man
su
• Description: Runs a new shell under different user and group IDs. If no user is specified,
the new shell will run as the root user.
• Usually, when you want to temporarily become a different user, you will simply switch to
another virtual terminal, log in as the other user, log out when you're done, and return to
your "home" virtual terminal.
• However, there are times when this is impractical or inconvenient. Perhaps all your virtual
terminals are already busy, or perhaps you're in a situation (such as logged on via a
telephone and modem) in which you don't have virtual terminals available.
• In these cases, you can use the su command. "su" stands for "super user." If you type su
by itself, you will be prompted for the root password. If you successfully enter the root
password, you will see the root # prompt, and you will have all of root's privileges. You
can also become any other user by typing su <username>. If you are root when you type
su <username>, you are not asked for that user's password since in principle you could
change the user's password or examine all the user's files from the root login anyway. If
you are an "ordinary" user trying to change to another ordinary user, you will be asked to
enter the password of the user you are trying to become.
Syntax: su [-flmp] [-c command] [-s shell] [--login]
[--fast] [--preserve-environment] [--
command=command] [--shell=shell] [-] [user]
• (see the man pages for the description of the flags and options)
• $ su <username> (to become another user) or
• $ su (to become the root user).
Adding a new user
• #useradd user1
• #passwd user1
• <password>
pwd
• Description: Displays the name of the current directory.pwd stands
for present working directory. By typing this command you are
informed of which directory you are currently in.
• Syntax: pwd
cd
• Description: Changes the current directory to any accessible directory on
the system.
• Syntax: For instance to change from /home/user1 to a subdirectory of user1
word files use the following:
• $ cd wordfiles
• $ pwd
• /home/user1/wordfiles
• To change to /tmp use the following:
• $ cd /tmp
• $ pwd
• /tmp
ls
• Description: Displays the listing of files and directories. If no file or
directory is specified, then the current directory‘s contents are
displayed. By default the contents are sorted alphabetically.
• Syntax: To view the contents of user1 home directory use this:
• $ ls
• To list the contents of any directory on the system use:
• $ ls /usr
more
• Description: Displays one or more files screen by screen and allows
for searching and jumping to an arbitrary location in the file.
-f: causes long lines not to be folded and to be counted as a single line.
• Syntax: less [-aeEGiINrsS] file….. Description: Displays a text file one screen at
a time while allowing searching and backward scrolling.
•
(the details of the flags can be seen from man pages).
• This command is an improved version of the previous one. On addition to the
functions previously described the following are some of the other actions that can
be performed using less:
• Jumping directly to a line.
• Jumping directly to the beginning or end of file.
• Moving backward through the file.
• Searching backward through the file.
find
• Description: Looks for files below the specified paths that match all
the criteria indicated by the command- line options and takes any
action indicated by those options. If no paths are specified, the search
takes place below the current directory.
find
• Syntax: find [path…..] [options]
• (see the man pages for the flags and options).
• This command can be used to search for files by name, date of creation, size and even file type. To
search for files by name use the following syntax:
• $ find starting-directory parameters actions
• The starting-directory specifies where to begin searching.
• The parameters are where you specify the criteria by which to search. Here use
• –name filename to specify the file to search for.
• The actions section indicates what actions to take on found files. If –print is used then the full name and
path of file is displayed.
• To search for all files named myfile on your system, use this:
• $ find / -name myfile –print
• (Notice that the previous command attempted to search for the entire system. To do this effectively user
must be logged in as the root user).
grep
• /bin
• This directory holds many of the basic Linux programs. bin stands for
binaries, files that are executable and that hold text only computers
could understand.
/usr
This directory holds many other user-oriented directories.
Some of the most important are described in the following
sections. Other directories found in /usr include
• /usr/bin
This directory holds user-oriented Linux programs.
• /var/spool
This directory has several subdirectories. mail holds mail files,
spool holds files to be printed, and uucp holds files copied
between Linux machines.
• /dev
• Linux treats everything as a file! The /dev directory holds devices.
These are special files that serve as gateways to physical computer
components. For instance, if you copy to /dev/fd0, you're actually
sending data to the system's floppy disk. Your terminal is one of the
/dev/tty files. Partitions on the hard drive are of the form /dev/hd0.
Even the system's memory is a device!
• A famous device is /dev/null. This is sometimes called the bit bucket.
All information sent to /dev/null vanishes—it's thrown into the trash.
• /usr/sbin
• This directory holds system administration files. If you do an ls -l, you see
that you must be the owner, root, to run these commands.
• /sbin
• This directory holds system files that are usually run automatically by the
Linux system.
• /etc
• This directory and its subdirectories hold many of the Linux configuration
files. These files are usually text, and they can be edited to change the
system's configuration (if you know what you're doing!).
Creating Files
• Linux has many ways to create and delete files. In fact, some of the
ways are so easy to perform that you have to be careful not to
accidentally overwrite or erase files!
• Return to your home directory by typing cd. Make sure you're in your
/home/<user> directory by running pwd. A file can be created by
typing ls -l /bin > test. Remember, the > symbol means "redirect all
output to the following filename." Note that the file test didn't exist
before you typed this command. When you redirect to a file, Linux
automatically creates the file if it doesn't already exist.
• What if you want to type text into a file, rather than some command's
output? The quick way is to use the command cat.
The cat Command
• The cat command is one of the simplest, yet most useful, commands in
Linux. The cat command basically takes all its input and outputs it. By
default, cat takes its input from the keyboard and outputs it to the
screen. Type cat at the command line:
$ cat
• The cursor moves down to the next line, but nothing else seems to
happen. Now cat is waiting for some input:
Hello
Hello
What
• Everything you type is repeated on-screen as soon as you press Enter!
How do you get out of this? At the start of a line, type ^D (Ctrl-D). (In
other words, hold down the Ctrl key and press D.) If you're not at the
beginning of a line, you have to type ^D twice. ^D is the Linux "end of
file" character. When a program such as cat encounters a ^D, it
assumes that it has finished with the current file, and it goes on to the
next one. In this case, if you type ^D by itself on an empty line, there
is no next file to go on to, and cat exits. So how do you use cat to
create a file? Simple! You redirect the output from cat to the desired
filename:
$ cat > newfile
Hello world
Here's some text
• Type as much as you want. When you are finished, press ^D by itself
on a line; you will be back at the Linux prompt. Now you want to look
at the contents of newfile. You could use the more or less commands,
but instead, let's use cat. Yes, you can use cat to look at files simply by
providing it with a filename:
$ cat > newfile
Hello world
Here's some text
• You can also add to the end of the file by using >>. Whenever you use
>>, whether with cat or any other command, the output is always
appended to the specified file. (Note that the ^D character does not
appear on-screen)
$ cat >> newfile
Some more lines
^D
$ cat newfile
Hello world Here’s
some text Some more lines
• To discover what cat actually stands for, let's first create another file.
$ cat > anotherfile
Different text
^D
$
• Now, try this:
$ cat newfile anotherfile> thirdfile
$ cat thirdfile
Hello world
Here's some text
Some more lines
Different text
• cat stands for concatenate; cat takes all the specified inputs and
regurgitates them in a single lump. This by itself would not be very
interesting, but combine it with the forms of input and output
redirection available in Linux and you have a powerful and useful tool.
Moving and Copying Files
• You often need to move or copy files. The mv command moves files,
and the cp command copies files. The mv command is much more
efficient than the cp command. When you use mv, the file's contents
are not moved at all; rather, Linux makes a note that the file is to be
found elsewhere within the file system's structure of directories.
• When you use cp, you are actually making a second physical copy of
your file and placing it on your disk. This can be slower (although for
small files, you won't notice any difference), and it causes a bit more
wear and tear on your computer. Don't make copies of files when all
you really want to do is move them!
• The syntax for the two commands is similar:
mv <source> <destination>
cp <source> <destination>
$ cp thisfile /tmp
and if you want to copy thisfile to /tmp but give the new file a different
name, enter
$ cp thisfile /tmp/newfilename
• Also to avoid overwriting a file accidentally use the –i flag of the cp
command which forces the system to confirm any file it will overwrite
when copying. Then a prompt like the following appears:
$ cp –i thisfile newfile
cp: overwrite thisfile?
• An alias for the cp command can be created by using the following:
$ alias cp=’cp –i’
• Here an alias has been defined so that when the cp command is issued,
then actually cp –i
• Is issued. In this way the user is always prompted before overwriting a
file while copying. If the user logs in as the super user or root user this
alias is set by default in most Linux distributions. This is especially
important because making a small mistake as the root user can have
drastic consequences for the whole system.
Copying Multiple Files in One Command
• In DOS only one file or file expression can be copied at a time. To
copy three separate files then three commands must be issued. The
Linux cp command makes this a bit easier. The cp command can take
more than two arguments. If more than two arguments are passed to
the command then the last one is treated as the destination and all
preceding files are copied to this destination.
• For example to copy fileone ,filetwo and filethree in the current
directory to /tmp then the following commands can be issued:
$ cp fileone /tmp
$ cp filetwo /tmp
$ cp filethree /tmp
Similarly wildcards can be used to mix and copy a large number of files in one
command. For instance, this command