Unit-V Linux - History and Evolution
Unit-V Linux - History and Evolution
We know that Windows-like operating system, files are stored in different folders on
different data drives like C: D: E: whereas in the Linux/Unix operating system files are
stored in a tree-like structure starting with the root directory as shown in the below
diagram.
The base of the Linux/Unix file system hierarchy begins at the root and everything starts
with the root directory.
These are the common top-level directories associated with the root
directory:
• /bin – binary or executable programs.
• /etc – system configuration files.
• /home – home directory. It is the default current directory.
• /opt – optional or third-party software.
• /tmp – temporary space, typically cleared on reboot.
• /usr – User related programs.
• /var – log files.
pwd The pwd command stands for (print working directory). It displays the
current working location or directory of the user. It displays the whole
working path starting with /. It is a built-in command.
ls The ls command is used to show the list of a folder. It will list out all the
files in the directed folder.
mkdir With mkdir command you can create your own directory.
rmdir The rmdir command is used to remove a directory from your system.
1. Files Listing
To perform Files listings or to list files and directories ls command is used
$ls
All your files and directories in the current directory would be listed and each type of
file would be displayed with a different color. Like in the output directories are
displayed with dark blue color.
$ls -l
It returns the detailed listing of the files and directories in the current directory. The
command gives os the owner of the file and even which file could be managed by
which user or group and which user/group has the right to access or execute which
file.
2. Creating Files
touch command can be used to create a new file. It will create and open a new blank
file if the file with a filename does not exist. And in case the file already exists then
the file will not be affected.
$touch filename
4. Copying a File
cp command could be used to create the copy of a file. It will create the new file in
destination with the same name and content as that of the file ‘filename’.
$cp source/filename destination/
5. Moving a File
mv command could be used to move a file from source to destination. It will remove
the file filename from the source folder and would be creating a file with the same
name and content in the destination folder.
$mv source/filename destination/
6. Renaming a File
mv command could be used to rename a file. It will rename the filename to
new_filename or in other words, it will remove the filename file and would be creating
a new file with the new_filename with the same content and name as that of the
filename file.
$mv filename new_filename
7. Deleting a File
rm command will remove the filename file from the directory.
$rm filename
Relative path-name
Relative path is defined as the path related to the present working directly(pwd). It
starts at your current directory and never starts with a /.
To be more specific let’s take a look on the below figure in which if we are looking
for photos then absolute path for it will be provided as /home/jono/photos but assuming
that we are already present in jono directory then the relative path for the same
can be written as simple photos.
Architecture of Linux
Linux architecture has the following components:
1. Kernel: Kernel is the core of the Linux based operating system. It
virtualizes the common hardware resources of the computer to provide each
process with its virtual resources. This makes the process seem as if it is the
sole process running on the machine. The kernel is also responsible for
preventing and mitigating conflicts between different processes. Different
types of the kernel are:
• Monolithic Kernel
• Hybrid kernels
• Exo kernels
• Micro kernels
2. System Library: Isthe special types of functions that are used to implement
the functionality of the operating system.
3. Shell: It is an interface to the kernel which hides the complexity of the
kernel’s functions from the users. It takes commands from the user and
executes the kernel’s functions.
4. Hardware Layer: This layer consists all peripheral devices like RAM/
HDD/ CPU etc.
5. System Utility: It provides the functionalities of an operating system to the
user.
Advantages of Linux
• The main advantage of Linux, is it is an open-source operating system.
This means the source code is easily available for everyone and you are
allowed to contribute, modify and distribute the code to anyone without any
permissions.
• In terms of security, Linux is more secure than any other operating system.
It does not mean that Linux is 100 percent secure it has some malware for
it but is less vulnerable than any other operating system. So, it does not
require any anti-virus software.
• The software updates in Linux are easy and frequent.
• Various Linux distributions are available so that you can use them
according to your requirements or according to your taste.
• Linux is freely available to use on the internet.
• It has large community support.
• It provides high stability. It rarely slows down or freezes and there is no
need to reboot it after a short time.
• It maintains the privacy of the user.
• The performance of the Linux system is much higher than other operating
systems. It allows a large number of people to work at the same time and it
handles them efficiently.
• It is network friendly.
• The flexibility of Linux is high. There is no need to install a complete Linux
suit; you are allowed to install only required components.
• Linux is compatible with a large number of file formats.
• It is fast and easy to install from the web. It can also install on any hardware
even on your old computer system.
Disadvantages of Linux
• It is not very user-friendly. So, it may be confusing for beginners.
• It has small peripheral hardware drivers as compared to windows.
2. Relational Operators: Relational operators are those operators which define the
relation between two operands. They give either true or false depending upon the
relation. They are of 6 types:
• ‘==’ Operator: Double equal to operator compares the two operands. Its
returns true is they are equal otherwise returns false.
• ‘! =’ Operator: Not Equal to operator return true if the two operands are
not equal otherwise it returns false.
• ‘<’ Operator: Less than operator returns true if first operand is less than
second operand otherwise returns false.
• ‘<=’ Operator: Less than or equal to operator returns true if first operand
is less than or equal to second operand otherwise returns false
• ‘>’ Operator: Greater than operator return true if the first operand is greater
than the second operand otherwise return false.
• ‘>=’ Operator: Greater than or equal to operator returns true if first operand
is greater than or equal to second operand otherwise returns false.
3. Logical Operators: They are also known as Boolean operators. These are used to
perform logical operations. They are of 3 types:
• Logical AND (&&): This is a binary operator, which returns true if both
the operands are true otherwise returns false.
• Logical OR (||): This is a binary operator, which returns true is either of the
operand is true or both the operands are true and return false if none of them
is false.
• Not Equal to (!): This is a unary operator which returns true if the operand
is false and returns false if the operand is true.
The operator is used to specify how the modes of a file should be adjusted. The
following operators are accepted:
Operator Description
+ Adds the specified modes to the specified classes
- Removes the specified modes from the specified classes
= The modes specified are to be made the exact modes for the specified classes
Note: Putting blank space(s) around operator would make the command fail.
The modes indicate which permissions are to be granted or removed from the specified
classes. There are three basic modes which correspond to the basic permissions:
r Permission to read the file.
w Permission to write (or delete) the file.
x Permission to execute the file, or, in the case of a directory, search it.
Types of permissions which we will be changing using chmod command :
In linux terminal, to see all the permissions to different files, type ls -l command which
lists the files in the working directory in long format. The figure below shows an
example to use ls -l and its output :
Let us take a look at above figure. To make things easy to understand some columns
and rows are eliminated and extra spaces are added to the permissions column to make
it easier to read as shown below:
- rw- rw- r-- mik mik assgn1_client.c
- rw- rw- r-- mik mik assgn1_server.c
d rwx rwx r-x mik mik EXAM
Now, let us see how chmod command can be used to change the access mode of a file.
Example 1 :
Let’s change the assgn1_client.c permission so that the owner cannot write(w) in the
file but can only read it.
BEFORE: -rw-rw-r-- mik mik assgn1_client.c
COMMAND: chmod u=r assgn1_client.c
AFTER: -r--rw-r-- mik mik assgn1_client.c
Before :
After :
Example 2 :
Let’s restrict the permission such that the user cannot search the directory EXAM.
BEFORE: drwxrwxr-x mik mik EXAM
COMMAND: chmod u=rw EXAM
AFTER: drw-rwxr-x mik mik EXAM
After applying the chmod u=rw EXAM command, the user (owner) cannot change the
directory. If the user tries to change the directory, then it shows the message
“Permission denied” as shown in the figure below :
$ mkdir $HOME/jail
• Step 2: Create directories inside “$HOME/jail”:
$ ldd /bin/bash
• Step 5: Copy required libraries into $HOME/jail/lib64/ location using cp command:
cp -v libraries/displayed/by/above/command $HOME/jail/lib64
Similarly, copy the libraries of ls command into $HOME/jail/lib64 location.
• Step 6: Finally, chroot into your mini-jail: