SlideShare a Scribd company logo
UNIX Operating Systems
and
Commands
Introduction
• Operating System:
 It acts as an interface between the user and
system.
 a system that manages the resources of a
computer.
• Resources:
 CPUs, Memory, I/O devices, Network etc..
Unix Architecture
 Hardware
 Kernel
 Shell
hardware
kernel
sh who
date
ed
wc
grep
as
nroff
ld
cpp
Other apps
Kernel
• Three major tasks of kernel:
 Process Management
 Device Management
 File Management
Shell
 The shell acts as an interface between
the user and the kernel
 A shell is an environment in which we
can run our commands, it is also called
as a command-line interpreter
Basic Linux Commands
• File Handling
• Text Processing
• System Administration
• Process Management
• Archival
• Network
• File Systems
• Advanced Commands
Files
 Everything in unix is considered as a file,
including the physical devices like flash
device, network cards etc..
 Logical collection of files is called as file
system or Unix file system(UFS).
 A UFS(unix file system) contains both inode
and contents of the file.
 Every file as a unique number to identify, this
number is called as an inode number.
Files…..
 We can classify files into 3
1. Ordinary Files
• Text File
• Binary File
2. Device Files
3. Directory Files / Special Files
Unix File Attributes
 File Permissions
1. Read: ‘r’ If you have read permission of a file, you
can see the contents of the file.
2. Write: ‘w’ If you have write permission of a file,
you can change the file. This means you can add to
a file, or overwrite a file. You can empty a file.
3. Execute: ‘x’ If the file has execute permission, then
you can ask the operating system to run the file as
if it were a program. If it's a binary file/program,
you can execute it like any other program.
File Attribute…
1. File type/File Permissions
2. Link
3. Owner
4. Group
5. Size
6. Last Modified Time
7. File Name
NOTE: ‘ls –l’ command lists the files in
the directory along with their attributes.
1. File type/ File permissions
 The first field of ls –l command gives the details of file type
and file permission
 This field as 10 characters.
_|_ _ _|_ _ _|_ _ _
FILE TYPE
FILE PERMISSIONS
1. FILE TYPE
the first character of the first field defines the type of the
file.
‘d’ – specifies that the file is a ‘directory file’ or a ‘special file’
‘-’ – spefies that a file is not a directory file.
 File Permissions:
Unix has three categories of file permission.
_ _ _ | _ _ _ | _ _ _
r w x r w x r w x
USER (U)
GROUP (G)
OTHER (O)
U G O
To change file Permission
 ‘chmod’ command is used to change the permissions of
the file.
USAGE: chmod [options] mode[,mode] file1 [file2 ...]
 Unix allows the user to specify modes in two ways.
1. Absolute
2. Relative
1. Absolute:
in this we use a series of 3 octal numbers to specify
the permission of a file.
Ex: chmod 501 demo.txt, chmod 777 demo.txt
 | rwx | 111 | 7 | Read, write and execute |
 | rw- | 110 | 6 | Read, write |
 | r-x | 101 | 5 | Read, and execute |
 | r-- | 100 | 4 | Read, |
 | -wx | 011 | 3 | Write and execute |
 | -w- | 010 | 2 | Write |
 | --x | 001 | 1 | Execute |
 | --- | 000 | 0 | no permissions |
+----------------------------------------------------+
 RELATIVE
In this mode ‘=‘ , ‘+’, ‘-’ operators are used to
assign, give and remove permissions.
On the LHS specify the category u,g,o,a.
On the RHS specify the permission r,w,x.
Ex: chmod u+r demo.txt
chmod u+rw demo.txt
chmod ug+rwx demo.txt
chmod a+rwx demo.txt
chmod u+rw,g+x demo.txt
INODE
 Is a data structure and it contains following details of the
file:
1. Mode/permission (protection)
2. Owner ID
3. Group ID
4. Size of file
5. Number of hard links to the file
6. Time last accessed
7. Time last modified
8. Time inode last modified
 ‘-i’ option along with ls command is used to see the
inode number of a file.
2. Link
 A link in UNIX is a pointer to a file. Like pointers in
any programming languages, links in UNIX are
pointers pointing to a file or a directory . Creating
links is a kind of shortcuts to access a file.
 It is similar to creating multiple names of the file to
access from different directories.
 The two different types of links in UNIX are:
1. Soft Links or Symbolic Links
2. Hard links
ln Command
 This command is used to create link for a file.
USAGE: ln [option] target link_name
ex: ln file1 file2
 ‘-s’ option is used to provide a soft link.
USAGE: ln –s target_file Link_name
ex: ln –s file1 file3
Hard link
 A hard link is an additional name for an existing file
on Unix-like operating systems. Any number of hard
links can be created for a file, and thus any number of
names, can be created for any file
 The inode of the hard linked file remains same as the
original file.
 On deleting the original file, hard linked file can still be
accessed.
 By giving the hard link the link count of the file will
increase.
 Hard links do not need any extra data memory to save
since it uses links
 Can be created only on files, not on directories.
Soft/Symbolic Link
 In computing, a symbolic link (soft link) is the nickname for
any file that contains a reference to another file or directory in
the form of an absolute or relative path and that affects
pathname resolution.
 Soft link can be created for non exiting file.
 oft link has a different inode number than the original file
 On deleting the original file, soft link cannot be accessed.
 Soft link needs extra memory to store the original file name as
its data.
 Access to the file is slower due to the overhead to access file.
3. Owner
 Gives the name of the owner of the file.
 We can change the owner of the file using the
command ‘chown’.
usage: chown owner file
4.Group
 Gives the name of the group a file belong to.
 We can change the group of the file using the
command ‘chgrp’.
Usage: chgrp group file
Sources to learn commands??
(man)
λ
Primary – man(manual) pages.1
2
man <command> ­ shows all information about the
command ex: man ls
<command> ­­­­help ­ shows the available options
for that command ex: ls ­­help
File Handling
commands
•
•
mkdir – is used to create directories
Usage: mkdir [OPTION]
DIRECTORY...
ex: mkdir demo
ls – is used to list all the files and
subdirectories
of the current directory.
Usage: ls [OPTION]... [FILE]...
eg. ls, ls ­l, ls ­l demo
File
Handling(contd...)
• pwd -­ print name of current working directory
Usage: pwd
• cd ­ change directories
Usage: cd [DIRECTORY]
eg. cd demo
Note: the Directory can be a relative or absolute path
of Directory
cp – copy files and directories
Usage: cp [OPTION]... SOURCE DEST
Examples:
1. cp file1 file2
cp a.txt b.txt
2. cp file 1 file2…. filen directory
cp file1 file2 /home/user/demo
mv – this command is used to move a file
from one directory to another
It is also used to rename a file.
Usage: mv [OPTION]... SOURCE DEST
eg. mv source.txt target_dir
mv old.txt new.txt
rm ­ remove files or directories
Usage: rm [OPTION]... FILE... eg. rm file1.txt , rm ­rf
some_dir
• find – search for files in a directory
hierarchy
Usage: find [OPTION] [path]
[action]
eg. 1. find file1.txt,
2. find ­­name file1.txt
• history – prints recently used commands
Usage: history
TO create an USER
 ‘addusr’ command is used to create a user.
 To create a new user the user should be logged
in as a root­user.
usage: addusr user_name
TO switch User
 ‘su’ command is used to switch from one user to another
Usage: su User_name
 It asks for the password to login.
 ‘exit’ command is used to come out of the logged in
user.
How to login as root ?
 ‘sudo su’ command is used to login as a root-user.
usage: sudo su
 It will ask for the password.
 The user should have permission to login as the root-user.
 All the users having root permissions are stored in a file
‘visudo’.
To remove User
 ‘delusr’ command is used to delete a user.
usage: delusr user-name
 You should be log-in as a root-user to delete an
user.
Basic Regular Expression
 The BRE a{1,2} matches a{1,2} literally,
while a{1,2} matches a or aa.
 As {,},+,?,(,),.. Are treated as a normal
symbols and we have to use a ‘’ to give
special meaning to them.
 As ?,+,.. Are not supported by POSIX
(Portable Operating system Interface for Unix)
BRE.
 We use grep command for BRE.
Extended Regular Expression
 The quantifiers ?, +, {n}, {n,m} and {n,} repea
t the preceding token zero or once, once or
more, n times, between n and m times, and n or
more times, respectively.
 These above quantifiers are supported by
POSIX ERE and we use egrep or grep –E
command.
Metacharacters
 ^ (Caret)=match expression at the start of a line, as in
^A.
 $ (Dollar)=match expression at the end of a line, as in
A$.
  (Back Slash)=turn off the special meaning of the next
character, as in ^.
 [ ] (Brackets)=match any one of the enclosed characters,
as in [aeiou]. Use Hyphen "-" for a range, as in [0-9].
 [^ ]=match any one character except those enclosed in
[ ], as in [^0-9].
 . (Period)=match a single character of any
value, except end of line.
 * (Asterisk)=match zero or more of the
preceding character or expression.
 {x,y}=match x to y occurrences of the
preceding.
 {x}=match exactly x occurrences of the
preceding.
 {x,}=match x or more occurrences of
the preceding.
Searching for a pattern in UINIX
 Unix has a special family of commands for handling
search requirements.
 The main member of this family is the grep
command.
GREP: (Global Regular Expression Parser)
 It scans its input for a pattern and displays lines
containing the pattern.
Examples
 grep '^From: ' demo.txt
 grep '[a-zA-Z]'{any line with at least one
letter}
 grep '[^a-zA-Z0-9]{anything not a letter or
number}
 grep '[0-9]{3}-[0-9]{4}'{999-9999, like
phone numbers}
 grep '^.$'{lines with exactly one character}
 grep '"smug"'{'smug' within double
quotes}
 grep '"*smug"*'{'smug', with or without
quotes}
 grep '^.'{any line that starts with a
Period "."}
 grep '^.[a-z][a-z]'{line start with "." and
2 letters}

More Related Content

What's hot (20)

PPT
Linux Commands
Ramasubbu .P
 
PDF
File management
Mohd Arif
 
PDF
Shell scripting
Manav Prasad
 
PPT
Linux command ppt
kalyanineve
 
PPT
Bash shell
xylas121
 
PPT
active-directory-domain-services
202066
 
PPTX
Case study operating systems
Akhil Bevara
 
PPTX
A beginners introduction to unix
zafarali1981
 
PPTX
Unix OS & Commands
Mohit Belwal
 
PPTX
Basics of shell programming
Chandan Kumar Rana
 
PPT
Linux file system nevigation
hetaldobariya
 
PPTX
Know the UNIX Commands
Brahma Killampalli
 
PPSX
Management file and directory in linux
Zkre Saleh
 
PPT
Basic command ppt
Rohit Kumar
 
PPTX
Unix
Erm78
 
PPTX
SHELL PROGRAMMING
jinal thakrar
 
PPTX
15 Setup BIND 9
Hameda Hurmat
 
PPTX
Vi editor
Ramakrishna kapa
 
PPT
Basic 50 linus command
MAGNA COLLEGE OF ENGINEERING
 
PPTX
Filepermissions in linux
Subashini Pandiarajan
 
Linux Commands
Ramasubbu .P
 
File management
Mohd Arif
 
Shell scripting
Manav Prasad
 
Linux command ppt
kalyanineve
 
Bash shell
xylas121
 
active-directory-domain-services
202066
 
Case study operating systems
Akhil Bevara
 
A beginners introduction to unix
zafarali1981
 
Unix OS & Commands
Mohit Belwal
 
Basics of shell programming
Chandan Kumar Rana
 
Linux file system nevigation
hetaldobariya
 
Know the UNIX Commands
Brahma Killampalli
 
Management file and directory in linux
Zkre Saleh
 
Basic command ppt
Rohit Kumar
 
Unix
Erm78
 
SHELL PROGRAMMING
jinal thakrar
 
15 Setup BIND 9
Hameda Hurmat
 
Vi editor
Ramakrishna kapa
 
Basic 50 linus command
MAGNA COLLEGE OF ENGINEERING
 
Filepermissions in linux
Subashini Pandiarajan
 

Viewers also liked (20)

PPT
QSpiders - Automation using Selenium
Qspiders - Software Testing Training Institute
 
PPTX
QSpiders - Selenium Webdriver
Qspiders - Software Testing Training Institute
 
ODP
intro unix/linux 02
duquoi
 
PPT
Unix(introduction)
meashi
 
PDF
Unix Command Line Productivity Tips
Keith Bennett
 
PPT
UNIX and Linux - an introduction by Mathias Homann
Mathias Homann
 
PDF
Linux intro 3 grep + Unix piping
Giovanni Marco Dall'Olio
 
PDF
Unix - An Introduction
Deepanshu Gahlaut
 
PPTX
UNIX Operating System
Unless Yuriko
 
PPT
Unix memory management
Tech_MX
 
PPT
Unix command-line tools
Eric Wilson
 
PPTX
Unix Operating System
subhsikha
 
PPTX
UNIX/Linux training
Michael Olafusi
 
PPT
Practical Example of grep command in unix
Javin Paul
 
PPTX
QSpiders - Day1 Network Basics
Qspiders - Software Testing Training Institute
 
PDF
Unix Training - 1
ankitmehta21
 
PPTX
QSpiders - SQL (Data Base)
Qspiders - Software Testing Training Institute
 
PPTX
QSpiders - Aptitude Assignments
Qspiders - Software Testing Training Institute
 
QSpiders - Automation using Selenium
Qspiders - Software Testing Training Institute
 
QSpiders - Selenium Webdriver
Qspiders - Software Testing Training Institute
 
intro unix/linux 02
duquoi
 
Unix(introduction)
meashi
 
Unix Command Line Productivity Tips
Keith Bennett
 
UNIX and Linux - an introduction by Mathias Homann
Mathias Homann
 
Linux intro 3 grep + Unix piping
Giovanni Marco Dall'Olio
 
Unix - An Introduction
Deepanshu Gahlaut
 
UNIX Operating System
Unless Yuriko
 
Unix memory management
Tech_MX
 
Unix command-line tools
Eric Wilson
 
Unix Operating System
subhsikha
 
UNIX/Linux training
Michael Olafusi
 
Practical Example of grep command in unix
Javin Paul
 
QSpiders - Day1 Network Basics
Qspiders - Software Testing Training Institute
 
Unix Training - 1
ankitmehta21
 
QSpiders - Aptitude Assignments
Qspiders - Software Testing Training Institute
 
Ad

Similar to QSpiders - Unix Operating Systems and Commands (20)

PPTX
Commands and shell programming (3)
christ university
 
PPTX
os lab commanaaaaaaaaaaaaaaaaaaaaaads.pptx
AdityaGupta221734
 
PPTX
Unix training session 1
Anil Kumar Kapil,PMP®
 
TXT
Unix3
Krishna Prasad
 
PPT
Unit 7
siddr
 
PPTX
linux chapter 5.pptx lesson About introduction to linux
zakiaxmed534
 
PPT
04-1-Linux.ppt
EidTahir
 
PPTX
An Introduction to Linux
Dimas Prasetyo
 
PPT
Basic Linux
Tan Huynh Cong
 
PPT
Lession1 Linux Preview
leminhvuong
 
PPT
linux-lecture4.ppt
LuigysToro
 
PPT
linux-lecture4.pptuyhbjhbiibihbiuhbbihbi
YajnadattaPattanayak
 
PPTX
Rishav Mishra final presentation on UNIX Final.pptx
rishavmishra041
 
PPTX
2. UNIX OS System Architecture easy.pptx
Priyadarshini648418
 
PPT
2ab. UNIX files.ppt JSS science and technology university
tempemailtemp19
 
PPT
Karkha unix shell scritping
chockit88
 
PPTX
various shell commands in unix operating system.pptx
ssuserc26f8f
 
PPT
Linuxnishustud
Vicky Singh
 
PDF
Basic unix commands_1
thakor bharati
 
PPT
Linux ppt
Sanmuga Nathan
 
Commands and shell programming (3)
christ university
 
os lab commanaaaaaaaaaaaaaaaaaaaaaads.pptx
AdityaGupta221734
 
Unix training session 1
Anil Kumar Kapil,PMP®
 
Unit 7
siddr
 
linux chapter 5.pptx lesson About introduction to linux
zakiaxmed534
 
04-1-Linux.ppt
EidTahir
 
An Introduction to Linux
Dimas Prasetyo
 
Basic Linux
Tan Huynh Cong
 
Lession1 Linux Preview
leminhvuong
 
linux-lecture4.ppt
LuigysToro
 
linux-lecture4.pptuyhbjhbiibihbiuhbbihbi
YajnadattaPattanayak
 
Rishav Mishra final presentation on UNIX Final.pptx
rishavmishra041
 
2. UNIX OS System Architecture easy.pptx
Priyadarshini648418
 
2ab. UNIX files.ppt JSS science and technology university
tempemailtemp19
 
Karkha unix shell scritping
chockit88
 
various shell commands in unix operating system.pptx
ssuserc26f8f
 
Linuxnishustud
Vicky Singh
 
Basic unix commands_1
thakor bharati
 
Linux ppt
Sanmuga Nathan
 
Ad

More from Qspiders - Software Testing Training Institute (20)

PPS
QSpiders - Variable Length-Subnet-Masks
Qspiders - Software Testing Training Institute
 
PPS
QSpiders - Upper layer-protocols
Qspiders - Software Testing Training Institute
 
PPTX
QSpiders - Chapter 7 Debugging
Qspiders - Software Testing Training Institute
 
PPTX
QSpiders - Chapter 4 Checkpoints
Qspiders - Software Testing Training Institute
 
PPTX
QSpiders - Simple Recording and Configuration of recording options for HP Loa...
Qspiders - Software Testing Training Institute
 
PPTX
QSpiders - Wonderlic Sample Question
Qspiders - Software Testing Training Institute
 
PPTX
QSpiders - Chapter- 3 Synchronization point
Qspiders - Software Testing Training Institute
 
PPTX
QSpiders - Presentation JMeter
Qspiders - Software Testing Training Institute
 
PPTX
QSpiders - Memory (JVM architecture)
Qspiders - Software Testing Training Institute
 
PPTX
QSpiders - Jdk Jvm Jre and Jit
Qspiders - Software Testing Training Institute
 
PPTX
QSpiders - Simple replay and run time settings Loadrunner
Qspiders - Software Testing Training Institute
 
PPTX
QSpiders - Major difference
Qspiders - Software Testing Training Institute
 
PPTX
QSpiders - Introduction to HP Load Runner
Qspiders - Software Testing Training Institute
 
PPTX
QSpiders - Interacting with My SQL Database
Qspiders - Software Testing Training Institute
 
PPTX
QSpiders - Server Architecture
Qspiders - Software Testing Training Institute
 
PPTX
QSpiders - Installation and Brief Dose of Load Runner
Qspiders - Software Testing Training Institute
 
PPT
QSpiders - Good to Know Network Concepts
Qspiders - Software Testing Training Institute
 
PPT
QSpiders - Cloud computing(cloud server)
Qspiders - Software Testing Training Institute
 
PPT
QSpiders - Basic intel architecture
Qspiders - Software Testing Training Institute
 
QSpiders - Variable Length-Subnet-Masks
Qspiders - Software Testing Training Institute
 
QSpiders - Upper layer-protocols
Qspiders - Software Testing Training Institute
 
QSpiders - Chapter 7 Debugging
Qspiders - Software Testing Training Institute
 
QSpiders - Chapter 4 Checkpoints
Qspiders - Software Testing Training Institute
 
QSpiders - Simple Recording and Configuration of recording options for HP Loa...
Qspiders - Software Testing Training Institute
 
QSpiders - Wonderlic Sample Question
Qspiders - Software Testing Training Institute
 
QSpiders - Chapter- 3 Synchronization point
Qspiders - Software Testing Training Institute
 
QSpiders - Presentation JMeter
Qspiders - Software Testing Training Institute
 
QSpiders - Memory (JVM architecture)
Qspiders - Software Testing Training Institute
 
QSpiders - Jdk Jvm Jre and Jit
Qspiders - Software Testing Training Institute
 
QSpiders - Simple replay and run time settings Loadrunner
Qspiders - Software Testing Training Institute
 
QSpiders - Introduction to HP Load Runner
Qspiders - Software Testing Training Institute
 
QSpiders - Interacting with My SQL Database
Qspiders - Software Testing Training Institute
 
QSpiders - Server Architecture
Qspiders - Software Testing Training Institute
 
QSpiders - Installation and Brief Dose of Load Runner
Qspiders - Software Testing Training Institute
 
QSpiders - Good to Know Network Concepts
Qspiders - Software Testing Training Institute
 
QSpiders - Cloud computing(cloud server)
Qspiders - Software Testing Training Institute
 
QSpiders - Basic intel architecture
Qspiders - Software Testing Training Institute
 

Recently uploaded (20)

PPTX
Controller Request and Response in Odoo18
Celine George
 
PPTX
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
PPTX
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PDF
epi editorial commitee meeting presentation
MIPLM
 
PDF
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
PDF
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
PDF
AI-Powered-Visual-Storytelling-for-Nonprofits.pdf
TechSoup
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PPTX
infertility, types,causes, impact, and management
Ritu480198
 
PDF
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PDF
Mahidol_Change_Agent_Note_2025-06-27-29_MUSEF
Tassanee Lerksuthirat
 
PPTX
TRANSLATIONAL AND ROTATIONAL MOTION.pptx
KIPAIZAGABAWA1
 
PPTX
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
PDF
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PDF
Is Assignment Help Legal in Australia_.pdf
thomas19williams83
 
Controller Request and Response in Odoo18
Celine George
 
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
epi editorial commitee meeting presentation
MIPLM
 
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
AI-Powered-Visual-Storytelling-for-Nonprofits.pdf
TechSoup
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
infertility, types,causes, impact, and management
Ritu480198
 
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
Mahidol_Change_Agent_Note_2025-06-27-29_MUSEF
Tassanee Lerksuthirat
 
TRANSLATIONAL AND ROTATIONAL MOTION.pptx
KIPAIZAGABAWA1
 
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
Is Assignment Help Legal in Australia_.pdf
thomas19williams83
 

QSpiders - Unix Operating Systems and Commands

  • 2. Introduction • Operating System:  It acts as an interface between the user and system.  a system that manages the resources of a computer. • Resources:  CPUs, Memory, I/O devices, Network etc..
  • 3. Unix Architecture  Hardware  Kernel  Shell hardware kernel sh who date ed wc grep as nroff ld cpp Other apps
  • 4. Kernel • Three major tasks of kernel:  Process Management  Device Management  File Management
  • 5. Shell  The shell acts as an interface between the user and the kernel  A shell is an environment in which we can run our commands, it is also called as a command-line interpreter
  • 6. Basic Linux Commands • File Handling • Text Processing • System Administration • Process Management • Archival • Network • File Systems • Advanced Commands
  • 7. Files  Everything in unix is considered as a file, including the physical devices like flash device, network cards etc..  Logical collection of files is called as file system or Unix file system(UFS).  A UFS(unix file system) contains both inode and contents of the file.  Every file as a unique number to identify, this number is called as an inode number.
  • 8. Files…..  We can classify files into 3 1. Ordinary Files • Text File • Binary File 2. Device Files 3. Directory Files / Special Files
  • 9. Unix File Attributes  File Permissions 1. Read: ‘r’ If you have read permission of a file, you can see the contents of the file. 2. Write: ‘w’ If you have write permission of a file, you can change the file. This means you can add to a file, or overwrite a file. You can empty a file. 3. Execute: ‘x’ If the file has execute permission, then you can ask the operating system to run the file as if it were a program. If it's a binary file/program, you can execute it like any other program.
  • 10. File Attribute… 1. File type/File Permissions 2. Link 3. Owner 4. Group 5. Size 6. Last Modified Time 7. File Name NOTE: ‘ls –l’ command lists the files in the directory along with their attributes.
  • 11. 1. File type/ File permissions  The first field of ls –l command gives the details of file type and file permission  This field as 10 characters. _|_ _ _|_ _ _|_ _ _ FILE TYPE FILE PERMISSIONS 1. FILE TYPE the first character of the first field defines the type of the file. ‘d’ – specifies that the file is a ‘directory file’ or a ‘special file’ ‘-’ – spefies that a file is not a directory file.
  • 12.  File Permissions: Unix has three categories of file permission. _ _ _ | _ _ _ | _ _ _ r w x r w x r w x USER (U) GROUP (G) OTHER (O) U G O
  • 13. To change file Permission  ‘chmod’ command is used to change the permissions of the file. USAGE: chmod [options] mode[,mode] file1 [file2 ...]  Unix allows the user to specify modes in two ways. 1. Absolute 2. Relative 1. Absolute: in this we use a series of 3 octal numbers to specify the permission of a file. Ex: chmod 501 demo.txt, chmod 777 demo.txt
  • 14.  | rwx | 111 | 7 | Read, write and execute |  | rw- | 110 | 6 | Read, write |  | r-x | 101 | 5 | Read, and execute |  | r-- | 100 | 4 | Read, |  | -wx | 011 | 3 | Write and execute |  | -w- | 010 | 2 | Write |  | --x | 001 | 1 | Execute |  | --- | 000 | 0 | no permissions | +----------------------------------------------------+
  • 15.  RELATIVE In this mode ‘=‘ , ‘+’, ‘-’ operators are used to assign, give and remove permissions. On the LHS specify the category u,g,o,a. On the RHS specify the permission r,w,x. Ex: chmod u+r demo.txt chmod u+rw demo.txt chmod ug+rwx demo.txt chmod a+rwx demo.txt chmod u+rw,g+x demo.txt
  • 16. INODE  Is a data structure and it contains following details of the file: 1. Mode/permission (protection) 2. Owner ID 3. Group ID 4. Size of file 5. Number of hard links to the file 6. Time last accessed 7. Time last modified 8. Time inode last modified  ‘-i’ option along with ls command is used to see the inode number of a file.
  • 17. 2. Link  A link in UNIX is a pointer to a file. Like pointers in any programming languages, links in UNIX are pointers pointing to a file or a directory . Creating links is a kind of shortcuts to access a file.  It is similar to creating multiple names of the file to access from different directories.  The two different types of links in UNIX are: 1. Soft Links or Symbolic Links 2. Hard links
  • 18. ln Command  This command is used to create link for a file. USAGE: ln [option] target link_name ex: ln file1 file2  ‘-s’ option is used to provide a soft link. USAGE: ln –s target_file Link_name ex: ln –s file1 file3
  • 19. Hard link  A hard link is an additional name for an existing file on Unix-like operating systems. Any number of hard links can be created for a file, and thus any number of names, can be created for any file  The inode of the hard linked file remains same as the original file.  On deleting the original file, hard linked file can still be accessed.  By giving the hard link the link count of the file will increase.  Hard links do not need any extra data memory to save since it uses links  Can be created only on files, not on directories.
  • 20. Soft/Symbolic Link  In computing, a symbolic link (soft link) is the nickname for any file that contains a reference to another file or directory in the form of an absolute or relative path and that affects pathname resolution.  Soft link can be created for non exiting file.  oft link has a different inode number than the original file  On deleting the original file, soft link cannot be accessed.  Soft link needs extra memory to store the original file name as its data.  Access to the file is slower due to the overhead to access file.
  • 21. 3. Owner  Gives the name of the owner of the file.  We can change the owner of the file using the command ‘chown’. usage: chown owner file
  • 22. 4.Group  Gives the name of the group a file belong to.  We can change the group of the file using the command ‘chgrp’. Usage: chgrp group file
  • 23. Sources to learn commands?? (man) λ Primary – man(manual) pages.1 2 man <command> ­ shows all information about the command ex: man ls <command> ­­­­help ­ shows the available options for that command ex: ls ­­help
  • 24. File Handling commands • • mkdir – is used to create directories Usage: mkdir [OPTION] DIRECTORY... ex: mkdir demo ls – is used to list all the files and subdirectories of the current directory. Usage: ls [OPTION]... [FILE]... eg. ls, ls ­l, ls ­l demo
  • 25. File Handling(contd...) • pwd -­ print name of current working directory Usage: pwd • cd ­ change directories Usage: cd [DIRECTORY] eg. cd demo Note: the Directory can be a relative or absolute path of Directory
  • 26. cp – copy files and directories Usage: cp [OPTION]... SOURCE DEST Examples: 1. cp file1 file2 cp a.txt b.txt 2. cp file 1 file2…. filen directory cp file1 file2 /home/user/demo
  • 27. mv – this command is used to move a file from one directory to another It is also used to rename a file. Usage: mv [OPTION]... SOURCE DEST eg. mv source.txt target_dir mv old.txt new.txt rm ­ remove files or directories Usage: rm [OPTION]... FILE... eg. rm file1.txt , rm ­rf some_dir
  • 28. • find – search for files in a directory hierarchy Usage: find [OPTION] [path] [action] eg. 1. find file1.txt, 2. find ­­name file1.txt • history – prints recently used commands Usage: history
  • 29. TO create an USER  ‘addusr’ command is used to create a user.  To create a new user the user should be logged in as a root­user. usage: addusr user_name
  • 30. TO switch User  ‘su’ command is used to switch from one user to another Usage: su User_name  It asks for the password to login.  ‘exit’ command is used to come out of the logged in user.
  • 31. How to login as root ?  ‘sudo su’ command is used to login as a root-user. usage: sudo su  It will ask for the password.  The user should have permission to login as the root-user.  All the users having root permissions are stored in a file ‘visudo’.
  • 32. To remove User  ‘delusr’ command is used to delete a user. usage: delusr user-name  You should be log-in as a root-user to delete an user.
  • 33. Basic Regular Expression  The BRE a{1,2} matches a{1,2} literally, while a{1,2} matches a or aa.  As {,},+,?,(,),.. Are treated as a normal symbols and we have to use a ‘’ to give special meaning to them.  As ?,+,.. Are not supported by POSIX (Portable Operating system Interface for Unix) BRE.  We use grep command for BRE.
  • 34. Extended Regular Expression  The quantifiers ?, +, {n}, {n,m} and {n,} repea t the preceding token zero or once, once or more, n times, between n and m times, and n or more times, respectively.  These above quantifiers are supported by POSIX ERE and we use egrep or grep –E command.
  • 35. Metacharacters  ^ (Caret)=match expression at the start of a line, as in ^A.  $ (Dollar)=match expression at the end of a line, as in A$.  (Back Slash)=turn off the special meaning of the next character, as in ^.  [ ] (Brackets)=match any one of the enclosed characters, as in [aeiou]. Use Hyphen "-" for a range, as in [0-9].  [^ ]=match any one character except those enclosed in [ ], as in [^0-9].
  • 36.  . (Period)=match a single character of any value, except end of line.  * (Asterisk)=match zero or more of the preceding character or expression.  {x,y}=match x to y occurrences of the preceding.  {x}=match exactly x occurrences of the preceding.  {x,}=match x or more occurrences of the preceding.
  • 37. Searching for a pattern in UINIX  Unix has a special family of commands for handling search requirements.  The main member of this family is the grep command. GREP: (Global Regular Expression Parser)  It scans its input for a pattern and displays lines containing the pattern.
  • 38. Examples  grep '^From: ' demo.txt  grep '[a-zA-Z]'{any line with at least one letter}  grep '[^a-zA-Z0-9]{anything not a letter or number}  grep '[0-9]{3}-[0-9]{4}'{999-9999, like phone numbers}  grep '^.$'{lines with exactly one character}
  • 39.  grep '"smug"'{'smug' within double quotes}  grep '"*smug"*'{'smug', with or without quotes}  grep '^.'{any line that starts with a Period "."}  grep '^.[a-z][a-z]'{line start with "." and 2 letters}