Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
10 views34 pages

Unit-4 Linux

The document provides an overview of the Linux operating system, highlighting its open-source nature, security advantages, and widespread use across various platforms, including servers and embedded systems. It discusses the features, advantages, and disadvantages of Linux, as well as its evolution and comparison with Unix. Additionally, it lists popular Linux distributions such as Ubuntu, Fedora, and Debian, emphasizing their unique characteristics and target users.

Uploaded by

rupaldas0000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views34 pages

Unit-4 Linux

The document provides an overview of the Linux operating system, highlighting its open-source nature, security advantages, and widespread use across various platforms, including servers and embedded systems. It discusses the features, advantages, and disadvantages of Linux, as well as its evolution and comparison with Unix. Additionally, it lists popular Linux distributions such as Ubuntu, Fedora, and Debian, emphasizing their unique characteristics and target users.

Uploaded by

rupaldas0000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

1.

Introduction to Linux Operating System


 Open-source software (OSS) is any computer software that's distributed with its source code
available for modification. That means it usually includes a license for programmers to change the
software in any way they choose: They can fix bugs, improve functions, or adapt the software to suit
their own needs.
 Linux is a Unix-like computer operating system assembled under the model of free and open source
software development and distribution.
 The defining component of Linux is the Linux kernel, an operating system kernel first released in
1991 by Linus Torvalds.
 Linux was originally developed as a free operating system for Intel x86-based personal computers.
It has since been ported to more computer hardware platforms than any other operating system. It is a
leading operating system on servers and other big iron systems such as mainframe computers and
supercomputers more than 90% of today's 500 fastest supercomputers run some variant of Linux,
including the 10 fastest.
 Linux also runs on embedded systems (devices where the operating system is typically built into
the firmware and highly tailored to the system) such as mobile phones, tablet computers, network
routers, televisions and video game consoles; the Android system in wide use on mobile devices is
built on the Linux kernel.
 Initially, Linux is created for personal computers gradually it is used in other machines like servers,
mainframe computers, supercomputers, etc. Nowadays, Linux is also used in embedded systems like
routers, automation controls, televisions, digital video recorders, video game consoles, smart watches,
etc.
 The biggest success of Linux is Android (operating system) it is based on the Linux kernel that is
running on smart phones and tablets. Due to android Linux has the largest installed base of all general-
purpose operating systems.

Advantages of Linux

 The main advantage of Linux, is it is an open-source operating system, 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 in any hardware even in your old
computer system.
 It performs all tasks properly even if it has limited space on the hard disk.

Disadvantages of Linux

 It is not much user-friendly. So, it may be confusing for beginners.


 It has small peripheral hardware drivers as compared to windows.

Linux Features :-
 Portable - Portability means software‘s can works on different types of hardware‘s in same
way. Linux kernel and application programs support their installation on any kind of hardware
platform.
 Open Source - Linux source code is freely available and it is community based development
project. Multiple Teams works in collaboration to enhance the capability of Linux operating system
and it is continuously evolving.
 Multi-User - Linux is a multiuser system means multiple users can access system resources
like memory/ ram/ application programs at same time.
 Multiprogramming - Linux is a multiprogramming system means multiple applications
can run at same time.
 Hierarchical File System - Linux provides a standard file structure in which system files/
user files are arranged.
 Shell - Linux provides a special interpreter program which can be used to execute commands
of the operating system. It can be used to do various types of operations, call application programs
etc.
 Security - Linux provides user security using authentication features like password
protection/ controlled access to specific files/ encryption of data. Linux is one of the most secure
operating systems than windows.

 Low cost: You don‘t need to spend time and money to obtain licenses since Linux and much
of its software come with the GNU General Public License. You can start to work immediately
without worrying that your software may stop working anytime because the free trial version
expires. Additionally, there are large repositories from which you can freely download high-quality
software for almost any task you can think of.
 Stability: Linux doesn‘t need to be rebooted periodically to maintain performance levels. It
doesn‘t freeze up or slow down over time due to memory leaks and such.
 Performance: Linux provides persistent high performance on workstations and on
networks. It can handle unusually large numbers of users simultaneously and can make old
computers sufficiently responsive to be useful again.
 Network friendliness: Linux was developed by a group of programmers over the Internet
and has therefore strong support for network functionality; client and server systems can be easily
set up on any computer running Linux. It can perform tasks such as network backups faster and
more reliably than alternative systems.
 Flexibility: Linux can be used for high-performance server applications, desktop
applications, and embedded systems. You can save disk space by only installing the components
needed for a particular use. You can restrict the use of specific computers by installing for example
only selected office applications instead of the whole suite.
 Compatibility: It runs all common UNIX software packages and can process all common
file formats.
 Choice: The large number of Linux distributions gives you a choice. Each distribution is
developed and supported by a different organization. You can pick the one you like best; the core
functionalities are the same; most software runs on most distributions.

 Fast and easy installation: Most Linux distributions come with user-friendly installation
and setup programs. Popular Linux distributions come with tools that make installation of additional
software very user friendly as well.
 Full use of hard disk: Linux continues work well even when the hard disk is almost full.
 Multi-tasking: Linux is designed to do many things at the same time; e.g., a large printing
job in the background won‘t slow down your other work.

Linux Distribution :-
Linux distribution is an operating system that is made up of a collection of software based on Linux kernel
or you can say distribution contains the Linux kernel and supporting libraries and software. And you can
get Linux based operating system by downloading one of the Linux distributions and these distributions
are available for different types of devices like embedded devices, personal computers, etc.

The Evolution of Linux


First Version was created in Bell Labs in 1969 and developed UNICS (Uniplexed information & Computing
Services ) , Version 6 was most popular . Many Companies Developed their Versions :-

 HP-UX
 IBM -AIX
 Sun Solarsis
 Linux

Some of the Bell Labs programmers who had worked on this project, Ken Thompson, Dennis Ritchie,In
1991, the Linux history started with the starting of a particular project by the Finland student Linus
Torvalds for creating a new free OS kernel. The final Linux Kernel was remarked by continuous
development throughout the history since then.

o Linux was proposed by the Finland student Linus Torvalds in 1991.


o HP-UX (Hewlett Packard) 8.0 version was published.
o Hewlett Packard 9.0 version was published in 1992.
o FreeBSD 1.0 version and NetBSD8 version was released in 1993.
o Red Hat Linux was proposed in 1994. Caldera was detected by Ransom love and Bryan Sparks and
NetBSD 1.0 version published.
o HP-UX 10.0 version and FreeBSD 2.0 version was released in 1995.
o K Desktop Environment was established by Matthias Ettrich in 1996.
o HP-UX 11.0 version was released in 1997.
o The IRIX 6.5 version, i.e., the fifth SGI UNIX generation, Free BSD 3.0 version, and Sun Solaris 7
OS was released in 1998.
o The Caldera System agreement with professional services division and SCO server software
division was released in 2000.
o Linus Torvalds published the Linux version 2.4 source code in 2001.
o Microsoft filed the Trademark collection against Lindows.com in 2001.
o Lindows name was modified to Linspire in 2004.
o The first publication of Ubuntu was published in 2004.
o The openSUSE project started a free distribution from the community of Novell In 2005.
o Oracle published its Red Hat distribution in 2006.
o Dell begun laptop distribution with Ubuntu which was pre-installed on it in 2007.
o Linux kernel version 3.0 was released in 2011.
o Linux-based android of Google insisted 75% of the market share of the Smartphone, based on the
number of phones exported in 2013.
o Ubuntu insisted on 20000000+ users in 2014.

Unix Vs Linux
Today Linux is in great demand. You can see the use of Linux everywhere. It's dominating on our servers,
desktop, smartphones and even used in some electrical devices like refrigerators.
Some people think Unix and Linux as synonyms, but that's not true. Many operating systems were
developed to be like Unix but none of them got the popularity as Linux. Linux is the clone of Unix. It has
several features similar to Unix, still have some key differences. Before Linux and Windows, computer
world was dominated by Unix. Unix is a copyrighted name and IBM AIX, HP-UX and Sun Solaris are only
Unix operating system remained till date.

Difference between Linux and Unix

Comparison Linux Unix


It is an operating system which
It is an open-source operating system which is
Definition can be only used by its
freely available to everyone.
copyrighters.
It has different distros like Ubuntu, Redhat, IBM AIX, HP-UX and Sun
Examples
Fedora, etc Solaris.
Nowadays, Linux is in great demand. Anyone It was developed mainly for
Users can use Linux whether a home user, developer or servers, workstations and
a student. mainframes.
Linux is used everywhere from servers, PC,
It is used in servers, workstations
Usage smartphones, tablets to mainframes and
and PCs.
supercomputers.
Linux is freely distributed,downloaded, and Unix copyright vendors decide
Cost distributed through magazines also. And priced different costs for their respective
distros of Linux are also cheaper than Windows. Unix Operating systems.
As it is open source, it is developed by sharing Unix was developed by AT&T
Development and collaboration of codes by world-wide Labs, various commercial vendors
developers. and non-profit organizations.
Linux kernel is developed by the community of Unix has three distributions IBM
developers from different parts of the world. AIX, HP-UX and Sun Solaris.
Manufacturer
Although the father of Linux, Linus Torvalds Apple also uses Unix to make OSX
oversees things. operating system.
Initially it was command based
Linux is command based but some distros
OS, but later Common Desktop
GUI provide GUI based Linux. Gnome and KDE are
Environment was created. Most
mostly used GUI.
Unix distributions use Gnome.
The default interface is BASH (Bourne Again It originally used Bourne shell.
Interface SHell). But some distros have developed their But is also compatible with other
own interfaces. GUIs.
File system It also supports file system but
Linux supports more file system than Unix.
support lesser than Linux.
Unix contain a completely
Linux is a Unix clone,behaves like Unix but
Coding different coding developed by
doesn't contain its code.
AT&T Labs.
Operating Unix is a complete package of
Linux is just the kernel.
system Operating system.
It provides higher security. Linux has about 60- Unix is also highly secured. It has
Security
100 viruses listed till date. about 85-120 viruses listed till date
As Linux is open-source,whenever a user post
In Unix, users have to wait for
Error detection any kind of threat, developers from all over the
some time for the problem to be
and solution world start working on it. And hence, it provides
resolved.
faster solution.

Linux Distribution
 A Linux distribution or a Linux Distro is an operating system made from a software
collection based upon the Linux Kernel or a package management system. Linux users get their
operating system by downloading one of the Linux distributions available for the various systems
ranging from embedded devices and personal computers (Ex: Linux Mint) to powerful supercomputers.
 Linux Distribution consists of Linux Kernel, Libraries, GNU Tools, and additional software
in a desktop environment. Most of the software is free and open-source.

 Due to huge availability of software, distributions have taken in a wide variety of forms i.e.
for use on desktops, servers, laptops, netbooks, mobile phones etc as well as minimal environments for
use in embedded systems. As there are commercially-backed distributions, like
Fedora , openSUSE and Ubuntu and entirely community-driven distributions,
such as Debian, Slackware, Gentoo and Arch Linux.

 Major distributions are pre-compiled and ready to use for a specific instruction set
and some distributions (such as Gentoo) are distributed mostly in source code form and compiled
locally during installation.

 List of Linux Distributions:

1. Ubuntu

Ubuntu is an open-source operating system sponsored by Canonical company and a trademark


registered by the same company. Ubuntu is based on Debian Linux distribution and is composed of several
open-source software and is available for free for businesses.

Ubuntu is also famous for its ease of use and its inclusion of a migration assistant for Windows users, and
support for the latest technologies. Ubuntu is available in various flavours targeted at specific niches,
Kubuntu, Xubuntu and Lubuntu etc.

2. Fedora

Fedora is upstream of commercial RHEL distribution. It is special because it uses the latest technology
and packages from the open-source world rather than RHEL. It also uses a Yum package manager like
RHEL.
3. Linux Mint

Linux Mint is based on Ubuntu or Debian is 32- and 64-bit Linux distribution for desktop computers. It
started with simply being Ubuntu with pre-installed and full out-of-the-box multimedia support and
proprietary software such as Adobe Flash. Newer versions of the Ubuntu-based Linux Mint have been
released every six months.

4. OpenSUSE

OpenSUSE started out a German translation of Slackware and is a community supported by SUSE
distribution and is the successor to SUSE Linux Professional and serves as the basis for SUSE Linux
Enterprise products.Newer versions are released every eight months and support many languages, and each
release is provided with security updates for a period of 18 months. It is a completely open-source system,
and it contains therefore not proprietary drivers or codecs to support most closed multimedia formats.
However, it is possible to install the packages to take advantage of these materials, as well as drivers for
ATI or Nvidia.

5. Debian

Debian is a free OS for computers. It is the most important available distros at present. It serves as the
base for Ubuntu, and many users consider it as the best one suited. With Debian, we have the possibility to
use all open-source components. Debian has a slow release cycle, having a period of 1 to 3 years.

6. Arch Linux

Arch Linux distribution was created by Judd Vinet. Arch Linux was designed for advanced users to be
the perfect operating system. It adheres to 5 principles: User centrality, pragmatism, modernity, simplicity,
versatility that means that project attempts to have minimal distribution-specific changes, minimum
breakage with updates etc. Arch Linux uses a rolling release model meaning no major releases of new
versions of the system, and regular updates are needed to obtain the latest arch software.
7. CentOS

CentOS is one of the Linux distribution which is available freely (no license) and has strong and big
community supported computing platform. Centos 5, 6, 7 and 8 versions will be maintained up to 10 years
based on RHEL.

Choosing a Linux distro

distribution name reason(s) for using

Red Hat Enterprise (RHEL) Used to want a good support contract.

CentOS Used without the support contract from Red Hat.

Fedora Want to have Red Hat on your laptop/desktop.

Linux Mint I want to have a personal graphical desktop to play music & games movies.

Debian Used for laptops, servers or any other device.

Ubuntu Ubuntu based on Debian

Kali Used to have a pointy-clicky or hacking interface.

Others Advanced users will prefer Arch, Gentoo, OpenSUSE, Scientific, …

Architecture of Linux system


The Linux operating system's architecture mainly contains some of the components: the Kernel, System Library,
Hardware layer, System, and Shell utility.
1. Kernel:- The kernel is one of the core section of an operating system. It is responsible for each of the
major actions of the Linux OS. This operating system contains distinct types of modules and cooperates
with underlying hardware directly. The kernel facilitates required abstraction for hiding details of low-level
hardware or application programs to the system.

2. System Libraries:- These libraries can be specified as some special functions. These are applied for
implementing the operating system's functionality and don't need code access rights of the modules of
kernel.

3. System Utility Programs:- It is responsible for doing specialized level and individual activities.

4. Hardware layer:- Linux operating system contains a hardware layer that consists of several peripheral
devices like CPU, HDD, and RAM.

5. Shell:- It is an interface among the kernel and user. It can afford the services of kernel. It can take
commands through the user and runs the functions of the kernel. The shell is available in distinct types of
OSes. These operating systems are categorized into two different types, which are the graphical
shells and command-line shells.

The graphical line shells facilitate the graphical user interface, while the command line shells facilitate
the command line interface. Thus, both of these shells implement operations. However, the graphical user
interface shells work slower as compared to the command-line interface shells.

There are a few types of these shells which are categorized as follows:

o Korn shell
o Bourne shell
o C shell
o POSIX shell
Components of Linux System
Linux Operating System has primarily three components :-
 Kernel − Kernel is the core part of Linux. It is responsible for all major activities of this operating system.
It consists of various modules and it interacts directly with the underlying hardware. Kernel provides the required
abstraction to hide low level hardware details to system or application programs.
 System Library − System libraries are special functions or programs using which application programs or
system utilities accesses Kernel's features. These libraries implement most of the functionalities of the operating
system and do not requires kernel module's code access rights.
 System Utility − System Utility programs are responsible to do specialized, individual level tasks.

Kernel Mode vs User Mode


Kernel component code executes in a special privileged mode called kernel mode with full access to all resources
of the computer. This code represents a single process, executes in single address space and do not require any
context switch and hence is very efficient and fast. Kernel runs each processes and provides system services to
processes, provides protected access to hardware to processes.
Support code which is not required to run in kernel mode is in System Library. User programs and other system
programs works in User Mode which has no access to system hardware and kernel code. User programs/ utilities
use System libraries to access Kernel functions to get system's low level tasks.

Install Linux
Linux is the foundation of thousands of open source operating systems designed to replace Windows and
Mac OS. It is free to download and install on any computer. Because it is open source, there are a variety of
different versions, or distributions, available developed by different groups.

Installing Any Linux Distribution


1.Download the Linux distribution of our choice. If you're new to Linux, consider trying a lightweight
and easy to use distribution, such as Ubuntu or Linux Mint. Linux distributions (known as "distros") are
typically available for free to download in ISO format. We can find the ISO for the distribution of your
choice at the distribution’s website. This format needs to be burned to a CD or USB stick before you can
use it to install Linux. This will create a Live CD or Live USB.
A Live CD or Live USB is a disk that you can boot into, and often contains a preview version of the
operating system that can be run directly from the CD or USB stick.

2.Boot into the Live CD or Live USB. Most computers are set to boot into the hard drive first, which
means you will need to change some settings to boot from your newly-burned CD or USB. Start by
rebooting the computer.
Once the computer reboots, press the key used to enter the boot menu. The key for your system will be
displayed on the same screen as the manufacturer’s logo. Typical keys include F12, F2, or Del.
For Windows 10 users, go to advanced boot in settings and click "Restart Now.
If your computer doesn't give you direct access to the boot menu from the manufacturer's splash screen, it's
most likely hidden in the BIOS menu. You can access the BIOS menu in the same way that you would
get to the boot menu. At the manufacturer splash screen, the key should be listed in one of the bottom
corners.
Once you're in the boot menu, select your live CD or USB. Once you’ve changed the settings, save and exit
the BIOS setup or boot menu. Your computer will continue with the boot process.

3.Try out the Linux distribution before installing. Most Live CDs and USBs can launch a "live
environment", giving you the ability to test it out before making the switch. You won’t be able to create
files, but you can navigate around the interface and decide if it’s right for you.

4.Start the installation process. If you’re trying out the distro, you can launch the installation from the
application on the desktop. If you decided not to try out the distribution, you can start the installation from
the boot menu.
 You will be asked to configure some basic options, such as language, keyboard layout, and timezone.

5.Create a username and password. You will need to create login information to install Linux. A
password will be required to log into your account and perform administrative tasks.

6.Set up the partition. Linux needs to be installed on a separate partition from any other operating systems
on your computer if you intend dual booting Linux with another OS. A partition is a portion of the hard
drive that is formatted specifically for that operating system. You can skip this step if you don't plan on
dual booting.
 Distros such as Ubuntu will set a recommended partition automatically. You can then adjust this manually
yourself. Most Linux installations require at least 20 GB, so be sure to set aside enough room for both the
Linux operating system and any other programs you may install and files you may create.
 If the installation process does not give you automatic partitions, make sure that the partition you create
is formatted as Ext4. If the copy of Linux you are installing is the only operating system on the computer,
you will most likely have to manually set your partition size.

7.Boot into Linux. Once the installation is finished, your computer will reboot. You will see a new screen
when your computer boots up called “GNU GRUB”. This is a boot loader that handles Linux installations.
Pick your new Linux distro from the list. This screen may not show up if you only have one operating
system on your computer. If this screen isn't being presented to you automatically, then you can get it
back by hitting shift right after the manufacturer splash screen.
 If you install multiple distros on your computer, they will all be listed here.

8.Check your hardware. Most hardware should work out of the box with your Linux distro, though you
may need to download some additional drivers to get everything working.
 Some hardware requires proprietary drivers to work correctly in Linux. This is most common with
graphics cards. There is typically an open source driver that will work, but to get the most out of your
graphics cards you will need to download the proprietary drivers from the manufacturer.
 In Ubuntu, you can download proprietary drivers through the System Settings menu. Select the Additional
Drivers option, and then select the graphics driver from the list. Other distros have specific methods for
obtaining extra drivers.
 You can find other drivers from this list as well, such as Wi-Fi drivers.

9.Start using Linux. Once your installation is complete and you’ve verified that your hardware is working,
you’re ready to start using Linux. Most distros come with several popular programs installed, and you can
download many more from their respective file repositories.

Essential Linux commands with examples

1. ls

$ ls :- This command shows a list of all the files and directories present in the current working
directory.

$ ls ~ :-This command shows the list of files that are present in the home directory.
$ ls -ltr :-This command will display the file having the name mentioned in the command and
will give details of that file.

2.df

$ df :- “df” is a “disk file system”.


This command shows a summary list of the total disk space available and the used disk space
on the file.
$ df -h :- ‘-h’ parameter is used to display the summary of the total disk space used and
available on your Linux file system in MB/GB.

3.mkdir

$ mkdir :- Used to create a new directory on Linux file system.


For Ex:- mkdir greatlearning will create a new directory named “greatlearning”.

4.rm

$ rm :- Used to remove a file from your Linux file system. For example- “rm data”, this will
remove file named data present in the current working directory.
$ rmdir :-- Used to remove a complete directory from the Linux file system.
For example- “rmdir allstuffs” will delete the allstuffs directory from the Linux file system.

5.pwd

$ pwd :- “pwd” stands for “Present Working Directory”. It will display the directory name on
which you are currently present or working and also shows the path of that directory.

6. cd

$ cd:-“cd” stands for change directory. By this command, a user can easily navigate to the
directory of his choice at any moment of time. cd command changes the present working
directory, to the directory name specified by the user in which he wants to navigate.
$ cd /

This is used to navigate to the root directory of a user’s Linux file system.

$ cd ~

This command is used to go to the home directory.

$ cd..

This command is used to navigate to one directory level up to the current working directory.

$ cd –

This command is used to navigate to the previous directory or simply go one directory back
to the directory which the user visited.

7.clear

$ clear

This command will clear all the data present on the Linux terminal window.

8. mv

$ mv

This command is used to change the name of a file/directory or to move a particular


file/directory from one place to another.

9. cp

$ cp
This is used to copy files/directory from one place to another. The user can easily create
multiple copies of a files/directories using this command.

10. cat

$ cat

Displays all the contents of a file on the output device.

11. du

$ du

“du” stands for “Disk Utility”. This command displays the details about how much space is
occupied by a file/directory in the disk.

$ du -sh

(“-s”= Summary and “-h”= Human Readable). It shows the details of the space occupied by a
file/directory on disk in bytes, megabytes, gigabytes, etc.

12. touch

$ touch

This command creates an empty file with the specified name in the current working
directory. An empty file with size 0 bytes gets created and will not be changed until the user
makes any changes to it.

13. who

$ who
It displays the number of users who are currently logged on Linux OS.

14. echo

$ echo

displays text written after the word “echo”.

Ex.- echo My House name is Sweet Dreams, this command output will be: “My House name
is Sweet Dreams”.

15. date

$ date

Displays the current date and time of your system. We easily know the current day and time
on the Linux terminal using this command.

16 .gzip

$ gzip filename

This command compresses content of files, gives extension of .gz and needs to be
uncompressed before use.

17. touch

$ touch filename

It creates new empty files and also used to change date and time of recent access and
modification.
18. locate

$ locate filename

Used to search find files by name and it also searches very fast, runs in the background to
trace the location of files. It also searches the file and stores them in a database.

19. echo

$ echo String

This command writes arguments to the standard output or display line of text. This command
is used in batch and scripts. This also plays an important role in building shell script.

20. grep

$ grep “String” filename

This command searches the text or file for lines containing a match to the given strings/words.

$ grep “String” filename1 filename2

This command searches the mentioned String in multiple files.

22. logout

$ logout

This command is used to exit a login shell or to get out of a current session.

23. exit

$ exit
This command is to exit a shell, like log out. It also reminds us that some jobs are running in
the background.

24. wc

$ wc [options] filename

This command is used to print the number of newlines, word, bytes in a file.

$ wc -l filename

This command is used to print the number of lines in a file.

$ wc -w filename

This command is used to print the number of words in a file.

$ wc -c filename

This command is used to display the count of bytes of a file.

25. sort

$ sort filename

This command sorts the file in alphabetical order and is used for printing lines of input text
files and concatenation of all files in sorted order.

$ sort -u filename

-u in sort command removes duplicate records in a file and only the first record is retained.
$ sort -n file

This command sorts a file numerically.

26. kill

$ kill

It stops a process and kills or terminates a process without logging out or restarting the system.

27. ps

$ ps

It will display current running process in the system and also used for view process running
on system. It provides information on current processes like CPU usage, user id, command
name and memory usage.

$ ps -ax

It shows all current running processes.

28. uptime

$ uptime

This command shows time from which system has been running. It will show current time of
system, No.of users that are currently active and system load average.

29. sleep

$ sleep number [suffix]


These command delays or pauses for a specified amount of time. It actually causes the system
with a given amount of time and also suspends the system for mentioned duration, then turns
on or resumes.

$ sleep (n)

Sleep for (n) seconds.

$ sleep (nm)

Sleep for (n) minutes.

$ sleep (nh)

Sleeps for (n) hours.

$ sleep (nd)

Sleeps for (n) days.

30. seq

$ seq n

Prints numbers starting from 1 to n and also prints the numbers from first to last with an
increment. All numbers can be real, not just integers.

$ seq n1 n2 . Prints number starting from n1 to n2.


Unix/Linux Command Reference

File Commands
1. Ls Directory listing
2. ls -al Formatted listing with hidden files
3. ls -lt Sorting the Formatted listing by time modification
4. cd dir Change directory to dir
5. Cd Change to home directory
6. Pwd Show current working directory
7. mkdir dir Creating a directory dir
8. cat >file Places the standard input into the file
9. more file Output the contents of the file
10. head file Output the first 10 lines of the file
11. tail file Output the last 10 lines of the file
12. tail -f file Output the contents of file as it grows,starting with the last 10
lines
13. touch file Create or update file
14. rm file Deleting the file
15. rm -r dir Deleting the directory
16. rm -f file Force to remove the file
17. rm -rf dir Force to remove the directory dir
18. cp file1 file2 Copy the contents of file1 to file2
19. cp -r dir1 dir2 Copy dir1 to dir2;create dir2 if not present
20. mv file1 file2 Rename or move file1 to file2,if file2 is an existing directory

21. ln -s file link Create symbolic link link to file

Process management
1. Ps To display the currently working processes
2. Top Display all running process
3. kill pid Kill the process with given pid
4. killall proc Kill all the process named proc
5. pkill pattern Will kill all processes matching the pattern
6. Bg List stopped or background jobs,resume a stopped job in the
background
7. Fg Brings the most recent job to foreground
8. fg n Brings job n to the foreground

File permission

1. chmod octal file Change the permission of file to octal,which can be found
separately for user,group,world by adding,
• 4-read(r)
• 2-write(w)
1-execute(x)
Searching
1. grep pattern file Search for pattern in file
2. grep -r pattern dir Search recursively for pattern in dir
3. command | grep pattern Search pattern in the output of a command

4. locate file Find all instances of file


5. find . -name filename Searches in the current directory (represented by a period) and
below it, for files and directories with names starting with
filename
6. pgrep pattern Searches for all the named processes , that matches with the
pattern and, by default, returns their ID

System Info
1. Date Show the current date and time
2. Cal Show this month's calender
3. uptime Show current uptime
4. W Display who is on line
5. whoami Who you are logged in as
Linux File System

 Unix uses a hierarchical file system structure, much like an upside-down tree, with root (/) at
the base of the file system and all other directories spreading from there.
 The general file system model, to which any implemented file system needs to be reduced,
consists of several well-defined entities: superblock, inode . These entities are file system
metadata (they contain information about data or other metadata).
 A superblock is a record of the characteristics of a filesystem, including its size, the block
size, the empty and the filled blocks and their respective counts, the size and location of the
inode tables, the disk block map and usage information, and the size of the block groups.

 The superblock stores the information needed for a mounted file system:

 inode and blocks locations


 file system block size
 maximum filename length
 maximum file size
 the location of the root inode

 An inode is a data structure on a filesystem on a Unix-like operating system that stores all the
information about a file except its name and its actual data. A data structure is a way of storing
data so that it can be used efficiently; different types of data structures are suited to different
types of applications, and some are highly specialized for specific types of tasks .

 An inode stores information like:

 file type;
 file size;
 access rights;
 access or modify time;
 location of data on the disk (pointers to disk blocks containing data).
 A Unix filesystem is a collection of files and directories that has the following properties −
 It has a root directory (/) that contains other files and directories.
 Each file or directory is uniquely identified by its name, the directory in which it resides, and a
unique identifier, typically called an inode.
 It is self-contained. There are no dependencies between one filesystem and another.
 The directories have specific purposes and generally hold the same types of information for
easily locating files.
 Following are the directories that exist on the major versions of Unix −

Sr. Directory & Description


No.

1 / -> This is the root directory which should contain only the directories needed at the
top level of the file structure

2 /bin -> This is where the executable files are located. These files are available to all
users

3 /dev -> These are device drivers

4 /etc -> Supervisor directory commands, configuration files, disk configuration files,
valid user lists, groups, ethernet, hosts, where to send critical messages

5 /lib -> Contains shared library files and sometimes other kernel-related files

6 /boot -> Contains files for booting the system

7 /home -> Contains the home directory for users and other accounts

8 /mnt -> Used to mount other temporary file systems, such as cdrom and floppy for
the CD-ROM drive and floppy diskette drive, respectively

9 /proc -> Contains all processes marked as a file by process number or other
information that is dynamic to the system

10 /tmp -> Holds temporary files used between system boots

11 /usr -> Used for miscellaneous purposes, and can be used by many users. Includes
administrative commands, shared files, library files, and others

12 /var -> Typically contains variable-length files such as log and print files and any
other type of file that may contain a variable amount of data
13 /sbin -> Contains binary (executable) files, usually for system administration. For
example, fdisk and ifconfig utilities

14 /kernel -> Contains kernel files

Navigating the File System


Now that you understand the basics of the file system, you can begin navigating to the files you need.
The following commands are used to navigate the system −

Sr. Command & Description


No.

1 cat filename -> Displays a filename

2 cd dirname -> Moves you to the identified directory

3 cp file1 file2 -> Copies one file/directory to the specified location

4 file filename -> Identifies the file type (binary, text, etc)

5 find filename dir -> Finds a file/directory

6 head filename -> Shows the beginning of a file

7 less filename -> Browses through a file from the end or the beginning

8 ls dirname -> Shows the contents of the directory specified

9 mkdir dirname -> Creates the specified directory

10 more filename -> Browses through a file from the beginning to the end

11 mv file1 file2 -> Moves the location of, or renames a file/directory

12 pwd -> Shows the current directory the user is in

13 rm filename -> Removes a file

14 rmdir dirname -> Removes a directory


15 tail filename -> Shows the end of a file

16 touch filename -> Creates a blank file or modifies an existing file or its attributes

17 whereis filename -> Shows the location of a file

18 which filename -> Shows the location of a file if it is in your PATH

Mounting the File System


A file system must be mounted in order to be usable by the system. To see what is currently mounted
(available for use) on your system, use the following command −
$ mount
/dev/vzfs on / type reiserfs (rw,usrquota,grpquota)
proc on /proc type proc (rw,nodiratime)
devpts on /dev/pts type devpts (rw)
$

 If you need to mount a file system, you can use the mount command with the following
 syntax − mount -t file_system_type
 For example, if you want to mount a CD-ROM to the directory /mnt/cdrom,
 you can type :- $ mount /dev/cdrom /mnt/cdrom
 This assumes that your CD-ROM device is called /dev/cdrom and that you want to mount it
to /mnt/cdrom.
 After mounting, you can use the cd command to navigate the newly available file system through
the mount point you just made.
Unmounting the File System
To unmount (remove) the file system from your system, use the umount command by identifying the
mount point or device.
For example, to unmount cdrom, use the following command −
$ umount /dev/cdrom
Kernel :-
In computer science, Kernel is a computer program that is a core or heart of an operating
system. Before discussing kernel in detail, let's first understand its basic, i.e., Operating system
in a computer.

Kernel in Operating System :-

o Kernel is the core part of an OS(Operating system); hence it has full control over everything in
the system. Each operation of hardware and software is managed and administrated by the
kernel.
o It acts as a bridge between applications and data processing done at the hardware level. It is
the central component of an OS.
o It is the part of the OS that always resides in computer memory and enables the communication
between software and hardware components.
o It is the computer program that first loaded on start-up the system (After the bootloader). Once
it is loaded, it manages the remaining start-ups. It also manages memory, peripheral, and I/O
requests from software. Moreover, it translates all I/O requests into data processing instructions
for the CPU. It manages other tasks also such as memory management, task management,
and disk management.
o A kernel is kept and usually loaded into separate memory space, known as protected Kernel
space. It is protected from being accessed by application programs or less important parts of
OS.
o Other application programs such as browser, word processor, audio & video player use separate
memory space known as user-space.
o Due to these two separate spaces, user data and kernel data don't interfere with each other and
do not cause any instability and slowness.
Functions of a Kernel
A kernel of an OS is responsible for performing various functions and has control over the
system. Some main responsibilities of Kernel are given below:

o Device Management :- To perform various actions, processes require access to peripheral


devices such as a mouse, keyboard, etc., that are connected to the computer. A kernel is
responsible for controlling these devices using device drivers. Here, a device driver is a
computer program that helps or enables the OS to communicate with any hardware device.
A kernel maintains a list of all the available devices, and this list may be already known,
configured by the user, or detected by OS at runtime.
o Memory Management :- The kernel has full control for accessing the computer's memory.
Each process requires some memory to work, and the kernel enables the processes to safely
access the memory. To allocate the memory, the first step is known as virtual
addressing, which is done by paging or segmentation. Virtual addressing is a process of
providing virtual address spaces to the processes. This prevents the application from crashing
into each other.
o Resource Management :- One of the important functionalities of Kernel is to share the
resources between various processes. It must share the resources in a way that each process
uniformly accesses the resource.
The kernel also provides a way for synchronization and inter-process communication (IPC). It
is responsible for context switching between processes.
o Accessing Computer Resources :- A kernel is responsible for accessing computer resources
such as RAM and I/O devices. RAM or Random-Access Memory is used to contain both data
and instructions. Each program needs to access the memory to execute and mostly wants more
memory than the available. For such a case, Kernel plays its role and decides which memory
each process will use and what to do if the required memory is not available.
The kernel also allocates the request from applications to use I/O devices such as keyboards,
microphones, printers, etc.

4
Process Management in Linux :-
Process:- An instance of a program is called a Process. In simple terms, any command that you give
to your Linux machine starts a new process. The process is a program in execution. The process is
created when a command is to be executed so, it can be called a running instance of a program in
execution. Tuning or controlling a process is called Process Management.
Any process can be run in two ways:
1. Foreground process: By default, All the processes are run in the foreground. When a process is run in
foreground, no other process can be run on the same terminal until the process is finished or killed. When
issuing this type of process, the system receives input from the keyboard(stdin) and gives output to the
screen(stdout). They run on the screen and need input from the user. For example Office Programs

2.Background process: Adding ‘&’ to a foreground command makes it a background process. A


background process runs on its own without input from the keyboard(stdin) and waits for input from
the keyboard. While the process runs in the background, other processes can be run in the foreground.
They run in the background and usually do not need user input. For example Antivirus.

Process status(ps):- displays all the process in execution

 $ PS
This command stands for 'Process Status'. It is similar to the "Task Manager" that pop-ups in a
Windows Machine when we use Cntrl+Alt+Del. This command is similar to 'top' command but the
information displayed is different.
To check all the processes running under a user, use the command -

 $ top
This utility tells the user about all the running processes on the Linux machine.
Press 'q' on the keyboard to move out of the process display.
The terminology follows:
Example
Field Description Example 1
2
PID The process ID of each task 1525 961
User The username of task owner Home Root
Priority Can be 20(highest) or -
PR 20 20
20(lowest)
NI The nice value of a task 0 0
VIRT Virtual memory used (kb) 1775 75972
RES Physical memory used (kb) 100 51
SHR Shared memory used (kb) 28 7952
Status
There are five types:
'D' = uninterruptible sleep
S 'R' = running S R
'S' = sleeping
'T' = traced or stopped
'Z' = zombie

1.First column: User Id

2. Second column: PID (process Id) – this is the 5-digit number assigned by OS for a process. No
PID can be the same.
3. Third column: PPID (parent process Id) – PID of the parent process
4. Fourth column: CPU utilization of process
5. Fifth column: STIME – Process start time
6. Sixth column: TTY – the Terminal type associated with the process
7. Seventh column: CMD – the command that started that process

 kill: Used to a process whose PID is known. To kill a process forcefully and unconditionally
use “kill -9 PID”
 You can also check the process status of a single process, use the syntax -
 ps PID


 This command terminates running processes on a Linux machine.
 To use these utilities you need to know the PID (process id) of the process you want to kill
 Syntax -
 kill PID
 bg: A job control command that resumes suspended jobs while keeping them running in the
background
 fg: It continues a stopped job by running it in the foreground

Types Of Processes :- There are five types of Process in Linux

1. Parent process: The process created by the user on the terminal. All processes have a parent process,
If it was created directly by user then the parent process will be the kernel process.

2. Child process: The process created by another process (by its parent process). All child processes
have a parent process.

The example is given above, the process having PID 28500(last row) is a child process of the process
having PID 26544

3. Orphan process: Sometimes when the parent gets executed before its own child process then the
child process becomes an orphan process. The orphan process have “Init” process (PID 0) as their
PPID (parent process ID)
4. Zombie process: The processes which are already dead but shows up in process status is called
Zombie process. Zombie processes have Zero CPU consumption.

5. Daemon process: These are system-related processes that run in the background. A Daemon process
can be recognized if it has “?” in its TTY field (6th column)

System calls :-
A system call is a procedure that provides the interface between a process and the operating
system. It is the way by which a computer program requests a service from the kernel of the
operating system.
Different operating systems execute different system calls.
In Linux making a system, call involves transferring control from unprivileged user mode to
privileged kernel mode; the details of this transfer vary from architecture to architecture. The
libraries take care of collecting the system-call arguments and, if necessary, arranging those
arguments in the special form necessary to make the system call.
System calls are divided into 5 categories mainly :
 Process Control
 File Management
 Device Management
 Information Maintenance
 Communication

You might also like