SlideShare une entreprise Scribd logo
1  sur  53
Linux Commands
By
Dr. Meenu Chopra
What is command?
 A command is an instruction given to our computer by us to do whatever
we want.
 In Mac OS, and Linux it is called terminal, whereas, in windows it is
called command prompt. Commands are always case sensitive.
 Commands are executed by typing in at the command line followed by
pressing enter key.
 This command further passes to the shell which reads the command and
execute it. Shell is a method for the user to interact with the system.
 Default shell in Linux is called bash (Bourne-Again Shell).
There are two types of shell commands:
 Built-in shell commands: They are part of a shell. Each shell has some
built in commands.
 External/Linux commands: Each external command is a separate
executable program written in C or other programming languages.
Command Navigation
 Here is a list of commonly used keyboard shortcuts using the
default shell, bash :
Linux mkdir Command
 The mkdir stands for 'make directory‘
Syntax:
mkdir <dirname1>
 To make multiple directories
Syntax:
mkdir <dirname1> <dirname2> <dirname3> ...
Linux mkdir Command
Linux rmdir Command
Command : rmdir <director name>
This command is used to delete a directory. But will not be able to
delete a directory including a sub-directory. It means, a directory
has to be empty to be deleted.
Command : rmdir –p
This command will delete a directory including its sub-directories
all at once. In below picture, all sub-directories have been deleted
with 'rmdir -p' command.
Types of Files
 Regular files (-): It contain programs, executable
files and text files.
 Directory files (d): It is shown in blue color. It
contain list of files.
 Special files
• Block file (b)
• Character device file (c)
• Named pipe file (p)
• Symbolic link file (l)
• Socket file (s)
File Command
Linux touch Command
• touch command is a way to create empty files (there are some other
methods also).
• You can update the modification and access time of each file with the
help of touch command.
Syntax:
touch <filename>
touch myfile1 myfile2 // To create multiple files in one command
Linux touch Command
• To see the access and change time of your file, you need to
use stat command.
Now after using touch -r demo.txt Demo.txt command,
time of Demo.txt has been changed wit reference to time of demo.txt
Copy (cp) Command
Remove (rm) Command
Man Command
 The "man" is a short term for manual page. In Unix like
operating systems such as Linux, man is an interface to
view the system's reference manual.
 A user can request to display a man page by simply
typing man followed by a space and then argument. Here
its argument can be a command, utility or function. A
manual page associated with each of these arguments is
displayed.
 If you will provide a section number in the command,
then man will be directed to look into that section number
of the manual and that section page will be displayed.
And if not, then by default it will display the first page
and you have to go through the entire sections in a pre-
defined manner.
Man Command
 Command : man –ls
 This command will display all the information
about 'ls' command as shown in the screen shot.

Sections in the man Page:
 Executable programs and shell commands
 System calls
 Library calls
 Special files
 File formats and conventions
 Games
 Miscellaneous
 System administration commands
 Kernel routines
Syntax for a particular section:
man section_number keyword
For example : man 2 passwd
Command Man –a
 This command help us to show all the man page sections
of a particular topic.
 Sections will come in ascending order that is lowest
section number will come first.
To go to the next section press 'q' and then enter.
 In the next slide, we have given the command 'man -a
chmod'. We know that chmod has two sections (1) and
(2).
Man –a Chmod
Linux man -f (whatis)
This command works like 'whatis' command which we'll study in later
sections. It searches for the manual page name for a given command and
displays the result with a short description about the particular manual
page.
Linux man -k
This command works like 'whatis' command which we'll study in later
sections. It searches for the manual page name for a given command
and displays the result with a short description about the particular
manual page.
$ man –k chmod
Linux File Contents Command
Linux head command
 The 'head' command displays the starting content of a file. By
default, it displays starting 10 lines of any file.
For example : head jtp.txt
 If we'll write two file names then it will display first ten lines (in
this case file has five lines only) of each file separated by a heading.
For example : head doc1.txt doc2.txt
 The 'head -n' option displays specified number of lines.
For example : head -15 jtp.txt
 The 'head -c' command counts the number of bytes of a file.
For example : head -c 20 jtp.txt
Linux Tail command
 The 'tail' command displays the last lines of a file. Its
main purpose is to read the error message. By default, it
will also display the last ten lines of a file.
For example : tail jtp.txt
 The ‘tail -n' option displays specified number of lines.
For example : tail -n<number> <file name>
 The 'tail -c' option displays the specified number of bytes
from the last.
Syntax: tail -c<number> <file name>
Example: tail -c12 jtp.txt
Linux cat command
 Linux cat command (to create a file)
 The 'cat' command can be used to create a new file with
greater than sign (>).
Command : cat >filename
 Press 'enter' after every line and you will be directed to
the next line. To save your file, go to the next line,
press 'ctrl+d' and your file will be saved.
 The 'cat' command with double greater than
sign (>>) append (add something in the last of a file)
something in your already existing file.
Syntax: cat >> file name
Example: cat >> filename
Linux cat command
 The 'cat' command can be used to copy the content of a
file into another file.
Syntax: cat (older file name)>(newer file name)
Example: cat combo>combo2
 The 'cat' command can be used to concatenate the
contents of multiple files in a single new file.
Syntax:
cat <filename1> <filename2>.... > <newFilename>
Example:
cat file1 file2 file3 >combo
Linux cat command
 To Insert A New Line
 A new line will be inserted while concatenating multiple files by
using a hyphen (-).
syntax:
cat - <filename1> <filename2>. . . . > <new filename>
Example:
cat - file1 file2 file3 >combo
 The 'cat -n' option displays line numbers in front of each line in
a file.
 The 'cat -n' option displays line numbers in front of each line in a
file.
 Syntax: cat -n <fileName>
 Example: cat -n jtp.txt
Linux cat command
 The 'cat -b' option removes the empty lines.
Syntax: cat -b (file name)
Example: cat -b meenu.txt
 The 'cat -n' option displays line numbers in front of each line in
a file.
Syntax: cat -n <fileName>
Example: cat -n meenu.txt
 The 'cat-e' option displays a '$' sign at the end of every line.
Syntax: cat -e <fileName>
Example: cat -e prog.txt
Linux cat command
 The 'cat -b' option removes the empty lines.
Syntax: cat -b (file name)
Example: cat -b meenu.txt
 The 'cat << EOF ' option displays an end marker at the end of a
file. It is called here directive and file content will be saved at the
given end marker.
 The file can be saved with the help of 'ctrl + d ' keys also. It works
like the end marker.
 Note: Any word other than 'EOF' can be used for the end marker.
Syntax: cat << EOF
Example: cat > exm.txt << EOF
Linux tac command
 The 'tac' command is the reverse of the 'cat' command. It is also
known as 'cat' backward. It will display the file content in reverse
order. It prints the last line first, then second last and so on. Such way,
it prints the first line at last.
Syntax: tac <file name>
Example: tac count
 To Separate The Content
 The 'tac --separator' command will separate the content from the
mentioned string or keyword from the rest of the file content.
Syntax: tac <file name> --separator "<string>"
Example: tac count --separator "two"
tac count --separator "five"
tac count --separator "one"
Linux More command
 As 'cat' command displays the file content. Same way 'more'
command also displays the content of a file.
 Only difference is that, in case of larger files, 'cat' command output
will scroll off your screen while 'more' command displays output one
screen ful at a time.
Following keys are used in 'more' command to scroll the page:
 Enter key: To scroll down page line by line.
 Space bar: To go to next page.
 b key: To go to the backward page.
 / key: Lets you search the string.
Syntax: more <file name>
Example: more /var/log/udev
Linux More command
 Note: The 'more' command can't be used to display binary files.
Linux Filesystem Hierarchy Standard
(FHS) The Root Directory
 Ubuntu with the help of the command "ls /". Here, we have written (/) to represent root
directory.
 Enter the command man hier. It will display directory structure of your system.
Linux Binary Directory
 Binary files are the files which contain compiled source code (or
machine code). They are also called executable files because they can
be executed on the computer.
Binary directory contains following directories:
 /bin
 /sbin
 /lib
 /opt
 /bin
Linux Binary Directory
 The '/bin' directory contains user binaries, executable files, Linux
commands that are used in single user mode, and common commands
that are used by all the users, like cat, cp, cd, ls, etc.
 The '/bin' directory doesn't contain directories.
 Example: ls /bin
Linux Binary Directory
 The '/sbin' directory also contains executable files, but unlike '/bin' it
only contains system binaries which require root privilege to perform
certain tasks and are helpful for system maintenance purpose. e.g.
fsck, root, init, ifconfig, etc.
Example: ls /sbin
Linux Binary Directory
 The '/lib' directory contains shared libraries which are often used by the
'/bin' and '/sbin' directories. It also contains kernel module. These filenames
are identiable as ld* or lib*.so.*.
 Example: ls /lib
 /lib/modules: The '/lib/modules' stores kernel modules and has a directory
for each installed kernel. Modules are meant to use extra hardware support
without making a new kernel.
 /lib32 and /lib64: During compilation time of libraries you'll encounter
through the directories named '/lib32' and '/lib64' which will clarify register
size to be used. A 64-bit system may have compatibility for 32-bit binary.
Linux Configuration Directory
 The configuration directory contains configured files which
configures the parameters and initial settings for some computer
programs.
 Configuration directory have following sub-directories:
1. /boot
 The '/boot' directory contains boot loader files which are essential to
boot the system. In other words, they only contain files which are
needed for a basic Linux system to get up and going.
 You may find '/boot/grub' directory which contains
'/boot/grub/grub.cfg' (older system may have /boot/grub/grub.conf)
which defines boot menu that is displayed before the kernel starts.
 Example: ls /boot
Linux Configuration Directory
 Configuration directory have following sub-directories:
1. /boot
Linux Configuration Directory
 Configuration directory have following sub-directories:
2. /etc
 All the machine related configuration files are kept in '/etc'. Almost
everything related to the configuration of your system is placed here.
It also contain startup and shutdown shell script which is used to start
and stop a program. All the files are static and text based and no
binary files can be placed in this directory.
 The meaning of 'etc' is very controversial. Earlier it was referred to
as 'Etcetera' because it could contain all the files that did not belong
from anywhere else. But recently its most likely meaning is 'Editable
Text Configuration' or 'Extended Tool chest'.
 Configuration files will have an extension of .conf.
Linux Configuration Directory
 Configuration directory have following sub-directories:
2. /etc
 Some common directories of /etc are:
 /etc/init.d/: The term 'init' is short for initialization. This directory contains script to control the system
or to start and stop the daemons (background process). The 'init' is a daemon process that continues
running until the system is shut down.
 /etc/X11/: The X Window system configuration files are stored in this directory. The configuration file of
graphical display (xorg.conf) is also stored here.
 /etc/skel/: The term 'skel' is short for skeleton. Everything in the system has a skeleton which is called
hidden file and is stored in this directory. It is not an important part in the system and can be deleted but
still it serves a specific purpose. Its purpose is to serve the basic set of files, a basic framework which can
be used in the creation of a new user.
Linux Data Directory
 Data directory is used to store data of the system.
 Data directory contains following directories.
 /home
 /root
 /srv
 /media
 /mnt
 /tmp
Linux Data Directory
 The '/home' directory stores users personnel files. After the '/home' there is a
directory which is generally named at the user's name like we have '/home/meenu'.
Inside this directory we have our sub-directories like Desktop, Downloads,
Documents, pictures, etc.
 Example: ls /home
ls /home/meenu
 The '/root' directory is the home directory of the root user.
 Please note that '/root' directory is different from (/) root.
 The term 'srv' is short for service. The '/srv' directory contains server specific data
for services provided by the system like www, cvs, rysync, ftp, etc.
 The '/media' directory acts as a mount point for removable media devices such as
CD-Rom, floppy, USB devices, etc.
 This is newly introduced directory and hence a system can run without this directory
also.
Example: ls /media
Linux Data Directory
 The term 'mnt' stands for mount. The '/mnt' directory should be empty
and sysadmins can only mount temporary filesystems.
 The term 'tmp' stands for temporary. Data stored in '/tmp' is
temporary and may use either disk space or RAM. When system is
rebooted, files under this directory is automatically deleted. So it is
advisable that never use '/tmp' to store important data.
Linux Memory Directory Memory directory contains files of the whole system. All the device information,
process running indata or system related information are stored in this directory.
 Memory directory contains the following directories.
 /dev
 /proc
 /sys
 /dev
 The term 'dev' is short for device. As you know in Linux operating system
everything is a file. It appears to be an ordinary file but doesn't take up disk space.
Files which are used to represent and access devices are stored here including
terminal devices like usb. All the files stored in '/dev' are not related to real devices,
some are related to virtual devices also.
 /dev/tty and /dev/pts: The '/dev/tty' file represents the command line interface that
is a terminl or console attached to the system. Typing commands in a terminal is a
part of the graphical interface like Gnome or KDE, then terminal will be represented
as '/dev/pts/1' (here 1 is replacable by any another number).
 /dev/null: The '/dev/null' file is considered as black hole, it has unlimited storage but
nothing can be retrieved from it. You can discard your unwanted output from the
terminal but can't retrieve it back.
Linux Memory Directory
/proc
 The term 'proc' is short for process. Same as '/dev', '/proc' also doesn't take up disk
space. It contains process information. It is a pseudo file system that contains
information about running processes. It also works as virtual file system containing
text information about system resources.
 /proc conversation with the kernel: The '/proc' displays view of the kernel, what
the kernel manages and it is a means to directly communicate with the kernel.
 Also most of the files in '/proc' are of 0 bytes yet they contain a lot of data. Most
of the files are readable only, some require root privileges and some are
writable.
 /proc/interrupts: The '/proc/interrupts' displays the interrupt.
 Example: cat /proc/interrupts
/sys
 The term 'sys' is short for system. Basically it contains kernel information about
hardware. It was created for Linux 2.6 kernel. It is a kind of '/proc' and is used for
plug and play configuration.
Linux Memory Directory
 Look at the below snapshot, command "ls /proc" displays content of '/proc'. Many
files are named as numbers and some named files are also there.
 The '/proc' has some file properties like date, which keeps on updating as shown in
the below snapshot.

Contenu connexe

Tendances

Basic command ppt
Basic command pptBasic command ppt
Basic command ppt
Rohit Kumar
 
Unix(introduction)
Unix(introduction)Unix(introduction)
Unix(introduction)
meashi
 

Tendances (20)

Basic commands
Basic commandsBasic commands
Basic commands
 
Basic linux commands
Basic linux commandsBasic linux commands
Basic linux commands
 
Unix slideshare
Unix slideshareUnix slideshare
Unix slideshare
 
Basic 50 linus command
Basic 50 linus commandBasic 50 linus command
Basic 50 linus command
 
Linux commands and file structure
Linux commands and file structureLinux commands and file structure
Linux commands and file structure
 
Basic command ppt
Basic command pptBasic command ppt
Basic command ppt
 
Basic Linux day 2
Basic Linux day 2Basic Linux day 2
Basic Linux day 2
 
Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013
 
Know the UNIX Commands
Know the UNIX CommandsKnow the UNIX Commands
Know the UNIX Commands
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Quick Guide with Linux Command Line
Quick Guide with Linux Command LineQuick Guide with Linux Command Line
Quick Guide with Linux Command Line
 
BASIC COMMANDS OF LINUX
BASIC COMMANDS OF LINUXBASIC COMMANDS OF LINUX
BASIC COMMANDS OF LINUX
 
Terminal Commands (Linux - ubuntu) (part-1)
Terminal Commands  (Linux - ubuntu) (part-1)Terminal Commands  (Linux - ubuntu) (part-1)
Terminal Commands (Linux - ubuntu) (part-1)
 
Linux Basic Commands
Linux Basic CommandsLinux Basic Commands
Linux Basic Commands
 
Linux
Linux Linux
Linux
 
Linux command for beginners
Linux command for beginnersLinux command for beginners
Linux command for beginners
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Linux Administration
Linux AdministrationLinux Administration
Linux Administration
 
Unix(introduction)
Unix(introduction)Unix(introduction)
Unix(introduction)
 

Similaire à Linux commands

8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unix
southees
 
Linux introductory-course-day-1
Linux introductory-course-day-1Linux introductory-course-day-1
Linux introductory-course-day-1
Julio Pulido
 
Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to Unix
Sudharsan S
 

Similaire à Linux commands (20)

IntroCommandLine.ppt
IntroCommandLine.pptIntroCommandLine.ppt
IntroCommandLine.ppt
 
IntroCommandLine.ppt
IntroCommandLine.pptIntroCommandLine.ppt
IntroCommandLine.ppt
 
Linux file commands and shell scripts
Linux file commands and shell scriptsLinux file commands and shell scripts
Linux file commands and shell scripts
 
Linux Command.pptx
Linux Command.pptxLinux Command.pptx
Linux Command.pptx
 
Unix_QT.ppsx
Unix_QT.ppsxUnix_QT.ppsx
Unix_QT.ppsx
 
Unix_QT.ppsx
Unix_QT.ppsxUnix_QT.ppsx
Unix_QT.ppsx
 
Lab 4 -Linux Files, Directories and Basic Commands Part-2.pptx
Lab 4 -Linux Files, Directories and Basic Commands Part-2.pptxLab 4 -Linux Files, Directories and Basic Commands Part-2.pptx
Lab 4 -Linux Files, Directories and Basic Commands Part-2.pptx
 
Linux Administration
Linux AdministrationLinux Administration
Linux Administration
 
The structure of Linux - Introduction to Linux for bioinformatics
The structure of Linux - Introduction to Linux for bioinformaticsThe structure of Linux - Introduction to Linux for bioinformatics
The structure of Linux - Introduction to Linux for bioinformatics
 
Linux
LinuxLinux
Linux
 
60761 linux
60761 linux60761 linux
60761 linux
 
Linux Cheat Sheet.pdf
Linux Cheat Sheet.pdfLinux Cheat Sheet.pdf
Linux Cheat Sheet.pdf
 
40 basic linux command
40 basic linux command40 basic linux command
40 basic linux command
 
40 basic linux command
40 basic linux command40 basic linux command
40 basic linux command
 
linux-lecture4.ppt
linux-lecture4.pptlinux-lecture4.ppt
linux-lecture4.ppt
 
8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unix
 
Operating System Laboratory presentation .ppt
Operating System Laboratory presentation .pptOperating System Laboratory presentation .ppt
Operating System Laboratory presentation .ppt
 
Linux introductory-course-day-1
Linux introductory-course-day-1Linux introductory-course-day-1
Linux introductory-course-day-1
 
Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to Unix
 
Unix tutorial-08
Unix tutorial-08Unix tutorial-08
Unix tutorial-08
 

Dernier

Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Dernier (20)

UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 

Linux commands

  • 2. What is command?  A command is an instruction given to our computer by us to do whatever we want.  In Mac OS, and Linux it is called terminal, whereas, in windows it is called command prompt. Commands are always case sensitive.  Commands are executed by typing in at the command line followed by pressing enter key.  This command further passes to the shell which reads the command and execute it. Shell is a method for the user to interact with the system.  Default shell in Linux is called bash (Bourne-Again Shell). There are two types of shell commands:  Built-in shell commands: They are part of a shell. Each shell has some built in commands.  External/Linux commands: Each external command is a separate executable program written in C or other programming languages.
  • 3. Command Navigation  Here is a list of commonly used keyboard shortcuts using the default shell, bash :
  • 4.
  • 5.
  • 6. Linux mkdir Command  The mkdir stands for 'make directory‘ Syntax: mkdir <dirname1>  To make multiple directories Syntax: mkdir <dirname1> <dirname2> <dirname3> ...
  • 8. Linux rmdir Command Command : rmdir <director name> This command is used to delete a directory. But will not be able to delete a directory including a sub-directory. It means, a directory has to be empty to be deleted. Command : rmdir –p This command will delete a directory including its sub-directories all at once. In below picture, all sub-directories have been deleted with 'rmdir -p' command.
  • 9.
  • 10.
  • 11. Types of Files  Regular files (-): It contain programs, executable files and text files.  Directory files (d): It is shown in blue color. It contain list of files.  Special files • Block file (b) • Character device file (c) • Named pipe file (p) • Symbolic link file (l) • Socket file (s)
  • 12.
  • 14. Linux touch Command • touch command is a way to create empty files (there are some other methods also). • You can update the modification and access time of each file with the help of touch command. Syntax: touch <filename> touch myfile1 myfile2 // To create multiple files in one command
  • 15. Linux touch Command • To see the access and change time of your file, you need to use stat command. Now after using touch -r demo.txt Demo.txt command, time of Demo.txt has been changed wit reference to time of demo.txt
  • 18. Man Command  The "man" is a short term for manual page. In Unix like operating systems such as Linux, man is an interface to view the system's reference manual.  A user can request to display a man page by simply typing man followed by a space and then argument. Here its argument can be a command, utility or function. A manual page associated with each of these arguments is displayed.  If you will provide a section number in the command, then man will be directed to look into that section number of the manual and that section page will be displayed. And if not, then by default it will display the first page and you have to go through the entire sections in a pre- defined manner.
  • 19. Man Command  Command : man –ls  This command will display all the information about 'ls' command as shown in the screen shot. 
  • 20. Sections in the man Page:  Executable programs and shell commands  System calls  Library calls  Special files  File formats and conventions  Games  Miscellaneous  System administration commands  Kernel routines Syntax for a particular section: man section_number keyword For example : man 2 passwd
  • 21.
  • 22. Command Man –a  This command help us to show all the man page sections of a particular topic.  Sections will come in ascending order that is lowest section number will come first. To go to the next section press 'q' and then enter.  In the next slide, we have given the command 'man -a chmod'. We know that chmod has two sections (1) and (2).
  • 24. Linux man -f (whatis) This command works like 'whatis' command which we'll study in later sections. It searches for the manual page name for a given command and displays the result with a short description about the particular manual page.
  • 25. Linux man -k This command works like 'whatis' command which we'll study in later sections. It searches for the manual page name for a given command and displays the result with a short description about the particular manual page. $ man –k chmod
  • 27. Linux head command  The 'head' command displays the starting content of a file. By default, it displays starting 10 lines of any file. For example : head jtp.txt  If we'll write two file names then it will display first ten lines (in this case file has five lines only) of each file separated by a heading. For example : head doc1.txt doc2.txt  The 'head -n' option displays specified number of lines. For example : head -15 jtp.txt  The 'head -c' command counts the number of bytes of a file. For example : head -c 20 jtp.txt
  • 28. Linux Tail command  The 'tail' command displays the last lines of a file. Its main purpose is to read the error message. By default, it will also display the last ten lines of a file. For example : tail jtp.txt  The ‘tail -n' option displays specified number of lines. For example : tail -n<number> <file name>  The 'tail -c' option displays the specified number of bytes from the last. Syntax: tail -c<number> <file name> Example: tail -c12 jtp.txt
  • 29. Linux cat command  Linux cat command (to create a file)  The 'cat' command can be used to create a new file with greater than sign (>). Command : cat >filename  Press 'enter' after every line and you will be directed to the next line. To save your file, go to the next line, press 'ctrl+d' and your file will be saved.  The 'cat' command with double greater than sign (>>) append (add something in the last of a file) something in your already existing file. Syntax: cat >> file name Example: cat >> filename
  • 30. Linux cat command  The 'cat' command can be used to copy the content of a file into another file. Syntax: cat (older file name)>(newer file name) Example: cat combo>combo2  The 'cat' command can be used to concatenate the contents of multiple files in a single new file. Syntax: cat <filename1> <filename2>.... > <newFilename> Example: cat file1 file2 file3 >combo
  • 31. Linux cat command  To Insert A New Line  A new line will be inserted while concatenating multiple files by using a hyphen (-). syntax: cat - <filename1> <filename2>. . . . > <new filename> Example: cat - file1 file2 file3 >combo  The 'cat -n' option displays line numbers in front of each line in a file.  The 'cat -n' option displays line numbers in front of each line in a file.  Syntax: cat -n <fileName>  Example: cat -n jtp.txt
  • 32. Linux cat command  The 'cat -b' option removes the empty lines. Syntax: cat -b (file name) Example: cat -b meenu.txt  The 'cat -n' option displays line numbers in front of each line in a file. Syntax: cat -n <fileName> Example: cat -n meenu.txt  The 'cat-e' option displays a '$' sign at the end of every line. Syntax: cat -e <fileName> Example: cat -e prog.txt
  • 33. Linux cat command  The 'cat -b' option removes the empty lines. Syntax: cat -b (file name) Example: cat -b meenu.txt  The 'cat << EOF ' option displays an end marker at the end of a file. It is called here directive and file content will be saved at the given end marker.  The file can be saved with the help of 'ctrl + d ' keys also. It works like the end marker.  Note: Any word other than 'EOF' can be used for the end marker. Syntax: cat << EOF Example: cat > exm.txt << EOF
  • 34. Linux tac command  The 'tac' command is the reverse of the 'cat' command. It is also known as 'cat' backward. It will display the file content in reverse order. It prints the last line first, then second last and so on. Such way, it prints the first line at last. Syntax: tac <file name> Example: tac count  To Separate The Content  The 'tac --separator' command will separate the content from the mentioned string or keyword from the rest of the file content. Syntax: tac <file name> --separator "<string>" Example: tac count --separator "two" tac count --separator "five" tac count --separator "one"
  • 35. Linux More command  As 'cat' command displays the file content. Same way 'more' command also displays the content of a file.  Only difference is that, in case of larger files, 'cat' command output will scroll off your screen while 'more' command displays output one screen ful at a time. Following keys are used in 'more' command to scroll the page:  Enter key: To scroll down page line by line.  Space bar: To go to next page.  b key: To go to the backward page.  / key: Lets you search the string. Syntax: more <file name> Example: more /var/log/udev
  • 36. Linux More command  Note: The 'more' command can't be used to display binary files.
  • 37. Linux Filesystem Hierarchy Standard (FHS) The Root Directory  Ubuntu with the help of the command "ls /". Here, we have written (/) to represent root directory.  Enter the command man hier. It will display directory structure of your system.
  • 38.
  • 39.
  • 40. Linux Binary Directory  Binary files are the files which contain compiled source code (or machine code). They are also called executable files because they can be executed on the computer. Binary directory contains following directories:  /bin  /sbin  /lib  /opt  /bin
  • 41. Linux Binary Directory  The '/bin' directory contains user binaries, executable files, Linux commands that are used in single user mode, and common commands that are used by all the users, like cat, cp, cd, ls, etc.  The '/bin' directory doesn't contain directories.  Example: ls /bin
  • 42. Linux Binary Directory  The '/sbin' directory also contains executable files, but unlike '/bin' it only contains system binaries which require root privilege to perform certain tasks and are helpful for system maintenance purpose. e.g. fsck, root, init, ifconfig, etc. Example: ls /sbin
  • 43. Linux Binary Directory  The '/lib' directory contains shared libraries which are often used by the '/bin' and '/sbin' directories. It also contains kernel module. These filenames are identiable as ld* or lib*.so.*.  Example: ls /lib  /lib/modules: The '/lib/modules' stores kernel modules and has a directory for each installed kernel. Modules are meant to use extra hardware support without making a new kernel.  /lib32 and /lib64: During compilation time of libraries you'll encounter through the directories named '/lib32' and '/lib64' which will clarify register size to be used. A 64-bit system may have compatibility for 32-bit binary.
  • 44. Linux Configuration Directory  The configuration directory contains configured files which configures the parameters and initial settings for some computer programs.  Configuration directory have following sub-directories: 1. /boot  The '/boot' directory contains boot loader files which are essential to boot the system. In other words, they only contain files which are needed for a basic Linux system to get up and going.  You may find '/boot/grub' directory which contains '/boot/grub/grub.cfg' (older system may have /boot/grub/grub.conf) which defines boot menu that is displayed before the kernel starts.  Example: ls /boot
  • 45. Linux Configuration Directory  Configuration directory have following sub-directories: 1. /boot
  • 46. Linux Configuration Directory  Configuration directory have following sub-directories: 2. /etc  All the machine related configuration files are kept in '/etc'. Almost everything related to the configuration of your system is placed here. It also contain startup and shutdown shell script which is used to start and stop a program. All the files are static and text based and no binary files can be placed in this directory.  The meaning of 'etc' is very controversial. Earlier it was referred to as 'Etcetera' because it could contain all the files that did not belong from anywhere else. But recently its most likely meaning is 'Editable Text Configuration' or 'Extended Tool chest'.  Configuration files will have an extension of .conf.
  • 47. Linux Configuration Directory  Configuration directory have following sub-directories: 2. /etc  Some common directories of /etc are:  /etc/init.d/: The term 'init' is short for initialization. This directory contains script to control the system or to start and stop the daemons (background process). The 'init' is a daemon process that continues running until the system is shut down.  /etc/X11/: The X Window system configuration files are stored in this directory. The configuration file of graphical display (xorg.conf) is also stored here.  /etc/skel/: The term 'skel' is short for skeleton. Everything in the system has a skeleton which is called hidden file and is stored in this directory. It is not an important part in the system and can be deleted but still it serves a specific purpose. Its purpose is to serve the basic set of files, a basic framework which can be used in the creation of a new user.
  • 48. Linux Data Directory  Data directory is used to store data of the system.  Data directory contains following directories.  /home  /root  /srv  /media  /mnt  /tmp
  • 49. Linux Data Directory  The '/home' directory stores users personnel files. After the '/home' there is a directory which is generally named at the user's name like we have '/home/meenu'. Inside this directory we have our sub-directories like Desktop, Downloads, Documents, pictures, etc.  Example: ls /home ls /home/meenu  The '/root' directory is the home directory of the root user.  Please note that '/root' directory is different from (/) root.  The term 'srv' is short for service. The '/srv' directory contains server specific data for services provided by the system like www, cvs, rysync, ftp, etc.  The '/media' directory acts as a mount point for removable media devices such as CD-Rom, floppy, USB devices, etc.  This is newly introduced directory and hence a system can run without this directory also. Example: ls /media
  • 50. Linux Data Directory  The term 'mnt' stands for mount. The '/mnt' directory should be empty and sysadmins can only mount temporary filesystems.  The term 'tmp' stands for temporary. Data stored in '/tmp' is temporary and may use either disk space or RAM. When system is rebooted, files under this directory is automatically deleted. So it is advisable that never use '/tmp' to store important data.
  • 51. Linux Memory Directory Memory directory contains files of the whole system. All the device information, process running indata or system related information are stored in this directory.  Memory directory contains the following directories.  /dev  /proc  /sys  /dev  The term 'dev' is short for device. As you know in Linux operating system everything is a file. It appears to be an ordinary file but doesn't take up disk space. Files which are used to represent and access devices are stored here including terminal devices like usb. All the files stored in '/dev' are not related to real devices, some are related to virtual devices also.  /dev/tty and /dev/pts: The '/dev/tty' file represents the command line interface that is a terminl or console attached to the system. Typing commands in a terminal is a part of the graphical interface like Gnome or KDE, then terminal will be represented as '/dev/pts/1' (here 1 is replacable by any another number).  /dev/null: The '/dev/null' file is considered as black hole, it has unlimited storage but nothing can be retrieved from it. You can discard your unwanted output from the terminal but can't retrieve it back.
  • 52. Linux Memory Directory /proc  The term 'proc' is short for process. Same as '/dev', '/proc' also doesn't take up disk space. It contains process information. It is a pseudo file system that contains information about running processes. It also works as virtual file system containing text information about system resources.  /proc conversation with the kernel: The '/proc' displays view of the kernel, what the kernel manages and it is a means to directly communicate with the kernel.  Also most of the files in '/proc' are of 0 bytes yet they contain a lot of data. Most of the files are readable only, some require root privileges and some are writable.  /proc/interrupts: The '/proc/interrupts' displays the interrupt.  Example: cat /proc/interrupts /sys  The term 'sys' is short for system. Basically it contains kernel information about hardware. It was created for Linux 2.6 kernel. It is a kind of '/proc' and is used for plug and play configuration.
  • 53. Linux Memory Directory  Look at the below snapshot, command "ls /proc" displays content of '/proc'. Many files are named as numbers and some named files are also there.  The '/proc' has some file properties like date, which keeps on updating as shown in the below snapshot.