Unit-1 - Overview of Linux: What Is Linux, Linux S Root in Unix, Common Linux Features, Advantage of
Unit-1 - Overview of Linux: What Is Linux, Linux S Root in Unix, Common Linux Features, Advantage of
Unit-1 - Overview of Linux: What Is Linux, Linux S Root in Unix, Common Linux Features, Advantage of
Unit-1 - Overview of Linux: What is Linux, Linux‘s root in Unix, Common Linux Features, advantage of
Linux, Overview of UNIX and Linux architectures, Linux files system, hardware requirements for Linux,
Linux standard directories. Commands for files and directories cd, ls, cp, rm, mkdir, rmdir, pwd, file, more,
less, Creating and viewing files using cat, file comparisons.
History of Linux
In 1969, Ken Thompson and Dennis Ritchie developed a small, general-purpose operating system written
in Assembly Language called UNIX.
In 1973, Ken Thompson and Dennis Ritchie rewrote the UNIX operating system in C.
Many vendors, such as Sun, IBM, and Hewlett-Packard, purchased the source code of UNIX and
developed their own version of UNIX. The source code of these versions was not freely available, so
the developers had to wait for a long time for the release of bug fixes.
In 1984, Richard Stallman's Free Software Foundation (FSF) began the GNU (gnu's Not UNIX)
project to create a free version of the UNIX operating system. The FSF built a number of tools that
could be freely used, read, modified, and redistributed but the kernel was still not created.
In 1991, Linus Torvalds developed a kernel and called it Linux.
In 1992, the Linux kernel was combined with the incomplete GNU system to form a completely free
operating system. This operating system is called GNU/Linux because it is a combination of GNU
and Linux. The GNU/Linux operating system is commonly referred to as the Linux operating
system.
Distributors of Linux
There are several distributors of Linux. All the distributors use the Linux kernel.
Some of the distributors of Linux are:
Red Hat
Ubuntu
Caldera
Mandrake
Debian
SuSE,
Slackware
1 GG
S4 BCA A LINUX MI
Official mascot
Tux is a penguin character and the official brand character of the Linux kernel. Tux is the most commonly
used icon for Linux, although different Linux distributions depict Tux in various styles.
2 GG
S4 BCA A LINUX MI
6. Portability: Portability means software can works on different types of hardware in same way. Linux
kernel and application programs support their installation on any kind of hardware platform.
7. Hierarchical File System: Linux provides a standard file structure in which system files/ user files
are arranged.
8. Shell: Linux provides a special interpreter program which can be used to execute commands of the
operating system.
9. Security: Linux provides user security using authentication features like password protection/
controlled access to specific files/ encryption of data.
10. Free to use (Low Cost): Linux is freely available on the web to download and use. We do not need to
buy the license for it as Linux and many of its software come with GNU General Public License.
11. Software Updates: In Linux you encounter a larger number of software updates. These software
updates are much faster than updates in any other operating system. Updates in Linux can be done
easily without facing any major issue or concern.
12. Customization: You can customize any feature, add or delete any feature according to your need as
it is an open source operating system.
13. Various Distributions: There are many distributions available also called bistros of Linux. It provides
various choices or flavors to the users. You can select any distributor according to your needs.
14. Support for application development: Offers an excellent platform for many development languages,
such as C, C++, JAVA, Python, PHP, and Perl.
15. Graphical User Interface (GUI): Is a user interface that helps the users to interact with the computer
easily. The GUI of Linux is X Window system. The X Window system consists of two subsystems:
server and client. Linux has a number of GUIs called Desktop Environments, such as K Desktop
Environment (KDE) and GNU Object Model Environment (GNOME).
3 GG
S4 BCA A LINUX MI
1. Boot Block: This represents the beginning of the file system. It contains a program called 'bootstrap
loader ‘which is executed when we 'boot' our machine. Although only one boot block is needed to
start up the system, all file systems contain one (possibly empty) boot block.
2. Super Block: The super block describes the state of the file system - how large it is, how many files
it can accommodate, It contains information like:
3. Inode Table- The information related to all these files (not the contents) is stored in an Inode Table
on the disk. For each file, there is an inode entry in the table. These details are:
Owner of the file
Group to which the owner belongs
Type of file
File access permissions
Date and time of last access
4. Data Block- These contain the actual file contents. An allocated data block can belong to only one
file in the file system.
Linux Directory Structure/Linux Standard Directories
The Linux file system looks like a tree.
The file system begins with a directory known as root. The root directory is denoted as slash(/). All
files and directories are logically contained inside the root directory.
The root Directory is subdivided into subdirectories like Bin, Boot ,home ,usr, etc, dev etc
.
4 GG
S4 BCA A LINUX MI
1. /bin: Bin directory stores many utilities available in linux. These utilities are commands in the Linux
operating system Many Linux commands, such as cat, cp, ls, more, and tar, are locate in /bin
2. /home: Home directory is the parent to the home directories of users which contains the home
directories of all the users.
3. /dev: contains all device files. Linux treats each device as a special file. All such files are located in
/dev.
4. /lib: Lib directory contains data libraries for the compilers, such as C Language routine installed in
the Linux OS.
5. /usr: Stores the operating system files that are not required during the startup process
6. /boot: contains the Linux kernel and other files.
7. /etc : Contains the data related to the operating system, including the essential operating system
programs and configuration files
ARCHITECTURE OF LINUX
1. Kernel
2. Shell
3. Utilities and application programs
1. Kernel
Kernel is the core of the Linux operating system.
It provides services for all other components of the operating system.
Kernel controls the resources of a computer by allocating them to different Linux users and tasks
It interacts directly with the hardware.
5 GG
S4 BCA A LINUX MI
The kernel forms an interface between the user and the hardware.
Linux Kernel performs: I/O management, process management, device & file management and
memory management.
2. Shell
Shell is a user interface that helps a user to interact with the Linux operating system.
Shell provides services requested by Linux users, such as viewing a file and creating or removing a
directory or a file.
It hides the complex hardware details from the Linux users.
Shell is used as a Command Line Interpreter (CLI) to run commands and programs.
Acts as a mediator between kernel and the user
3. System Utilities
The utilities in Linux are collections of programs that provide day-to-day processing requirements,
such as searching a word in a file and viewing access permissions of files.
These programs are invoked through the shell of the Linux operating system.
6 GG
S4 BCA A LINUX MI
pwd
/home/student/D1
Here the user are currently in the Directory D1
2. CD
The cd Command. The cd command is used to change the current directory (i.e., the directory in
which the user is currently working)
CD [directory] to move inside a subdirectory
CD / This command is used to change directory to the root directory, the
root directory is the first directory in your file system hierarchy.
CD Dir1/Dir2/Dir3 This Command is used to Change the directory to Dir3 by giving the
relative path Name
CD This command is used to change directory to the home directory.
CD .. This command is used to move to the parent directory of current
directory or the directory one level up from the current directory.
3. MKDIR
MKDIR command in Linux allows the user to create directories (also referred to as folders in some
operating systems).
mkdir BCAS4 The mkdir command creates a directory called ‘BCAS4’.
mkdir –p ABC/XYZ/PQR The option –p allows you to create multiple generations
of directories. If the ABC and XYZ Directories not
exists it will be created and inside XYZ , PQR is
created.
4. RMDIR
rmdir command is used remove empty directories from the file system in Linux. The rmdir
command removes each and every directory specified in the command line only if these directories
are empty. So if the specified directory has some directories or files in it then this cannot be removed
by rmdir command.
rmdir BCAS4 The rmdir command removes a directory called ‘BCAS4’.
rmdir –p ABC/XYZ/PQR This will first remove the child directory and then
remove the parent directory.
7 GG
S4 BCA A LINUX MI
rm -r DIR1 To remove non-empty directories and all the files within them, use
the rm command with the-r (recursive) option
5. RM
To remove (or delete) a file in Linux from the command line, use either the rm (remove)
rm filename To Remove File1
rm filename1 filename2 filename3 To Remove Multiple Files
rm *.pdf To Remove all the PDF Files
6. CP
To copy the contents of one file to another one use the following method. If destination file
doesn’t exist it will be created. If it exists Linux will over write the contents of destination file.
cp F1 F2 To Copy the Contents of File F1 to F2
cp F1 F2 Dir1 To Copy the Files F1 and F2 to the Directory Dir1
cp ABC/XYZ/F1 DIR1/F2 Here F1 is copied from the directory ABC/XYZ to the
Directory DIR1. The New Name is F2 for the File.
7. MV
mv is for moving a file.mv stands for move. mv is used to move one or more files or directories from
one place to It has two distinct functions:
(i) It rename a file or folder.
(ii) It moves group of files to different directory.
mv F1 F2 To Rename the File F1 to F2
mv Dir1 Dir2 To Rename the Directory D1 to D2
mv F1 F2 Dir1 To move the Files F1 and F2 to the directory Dir1
8. FILE
File command is used to determine the type of a file.
File F1 To display the type of File F1
File * To Display all the files type in the current directory
File Dir1/* To Display all the files type in the Dir1 directory
8 GG
S4 BCA A LINUX MI
9. MORE
More command is used to view the text files in the command prompt, displaying one screen at a time
in case the file is large (For example log files). The more command also allows the user do scroll up
and down through the page.
More command pauses when the screen fills and waits for pressing a spacebar key before it moves to
another screen full of text. A message at the bottom of the screen tells us the percentage of file that
has been displayed so far. We can press Ctrl-C to quit more command before reaching the end of
file.
More F1
10. LESS
The less command works like more except that it moves both forward and backward in the file while
the command is running. We can use the B key on your keyboard to back up one screen or a
spacebar to move forward and display the next screen. Less command is faster than more command
because it does not load the entire file at once and allows navigation though file.
Less F1
11. LS
List all the directories, or list the contents of the current or specified directory.
Ls To display the contents of the current directory
Ls –a To display hidden files in the current directory
ls p* List all files starting with p followed by any other character
ls ?ain List all files starting with any character but ends with ‘ain’
ls /mydir/*x List all files in directory ‘mydir’ which end in ‘x’
ls [aeiou]* List the files with the first character can be either a,e,i,o,u and
the remaining can be any other letter.
ls [!aeiou]* List the files with the first character not being a,e,i,o,u and the
remaining can be any other letter
ls [a-m][c-z][4-9] ?? List all 5 character file names whose first character in range a-
m 2nd character in the range c-z, 3rd character in the range 4 to
9and 4th and 5th are any valid characters.
9 GG
S4 BCA A LINUX MI
Cat>F1 Creates a File F1 and allows us to add some contents to the file
F1. Use Ctrl+d to indicate the EOF
Cat F1 To Display the Contents of F1
Cat<F1 To Display the Contents of F1
Cat F1 F2 To Display the Contents of F1 and F2
Cat>>F1 To append the contents of File F1(old +New Contents)
Cat F1 > F2 To create a New File F2 with the content of F1
Cat F1 F2 > F3 To create a New File F3 with the content of F1 and F2
Cat F1 F2 >> F3 To append the contents of F3 with the contents of F1 and F2
FILE COMPARISONS
1. Diff Command
The Linux diff command analyses a file line by line and gives an output of a list of changes made between
two files. The command diff is short for difference, which in essence gives the differences between two
files.
Diff Command Output Symbols
The less than symbol indicates lines from the first line
The greater than symbol indicates lines from the second line
a - Denotes that text was added to the file
c - Denotes that changes were made in the file
d - Indicates that the line was deleted
10 GG
S4 BCA A LINUX MI
Case A: Change
The 2,3c2,3 line implies that lines 2 and 3 from the first file need to be changed in order to match lines 2
and 3 from the second text file.
Case B: Add
[student@localhost p1]$ cat F1 [student@localhost p1]$ cat F2
RED RED
BLUE GREEN
BLUE
1a2
> GREEN
11 GG
S4 BCA A LINUX MI
From the output above, 1a2 implies that after line 1 from the first file, another line needs to be added to
match line 2 from the second file.
Case C: Delete
RED RED
GREEN GREEN
BLUE
3d2
< BLUE
Here the output 3d2 means that delete the 3rd line from the first file to sync up with the second file at line
number 2.
2. Comm Command
Comm compare two sorted files line by line and produce three-column output. Column one contains lines
unique to FILE1, column two contains lines unique to FILE2, and column three contains lines common to
both files.
12 GG
S4 BCA A LINUX MI
3. CMP Command
cmp command in Linux is used to compare the two files byte by byte and finds out whether the two files are
identical or not. If difference is found between 2 files, it reports the location of the first mismatch between 2
files.
13 GG