SlideShare uma empresa Scribd logo
Unix Shell Programming
Outline
 Revision
 Simple Filter Commands
 Filter Using Regular Expression
 Redirection of Standard Input and Output
 File and Directory Access Modes
 Changing the File Permission
Priti Patel 2/20/2024
2
Redirection of Standard Input and Output
Terminal: In context of redirection the terminal is generic
name that represents the screen, display or keyboard.
Command output and error message on terminal (Display).
Provides commands input through terminal (keyboard).
When user logs in , the shell makes available three files
representing three streams.
Standard Input- The file (or Stream) for input
Standard Output- The file(or Stream) for output
Standard Error- for Error message. Connected to display.
Priti Patel 2/20/2024
3
Redirection of Standard Input and Output
Standard Input: The input of a command be redirected
from a file.
The less-than character < is used to redirect the input of
a command.
case1: wc –l users
case2: wc -l < users
Difference In the first case, wc knows that it is reading
its input from the file users.
 In the second case, it only knows that it is reading its
input from standard input so it does not display file
name.
Priti Patel 2/20/2024
4
Redirection of Standard Input and Output
Standard Output: If the notation > file is appended to
any command that normally writes its output to standard
output, the output of that command will be written to file
instead of your terminal.
You can use >> operator to append the output in an
existing file.
For Eg: cut –d “ “ –f 2 1.txt > std_out
Priti Patel 2/20/2024
5
Redirection of Standard Input and Output
Standard Error: The three standard files are
represented by a number called a file descriptor.
The kernel maintains a table of file descriptor for every
process running in the system.
Three standard streams are :
 0-Standard input
1- Standard output
2- Standard error
The descriptor are implicitly prefixed to the redirection
symbols.
Priti Patel 2/20/2024
6
Redirection of Standard Input and Output
< , 0< and > ,1> mean same.
Standard error : Enter incorrect command or try to open
nonexistent file, certain diagnostic message show up the
screen.
For Eg.
Cat test > errorfile is incorrect
Cat test 2> errorfile is correct
tty: Knowing your terminal
UNIX treats terminal as a files.
One who wants to know about filename of the terminal you
are using.
tty (teletype)command
Syntax: $tty
Priti Patel 2/20/2024
7
File Access Mode
The permissions of a file are the first line of defense in the
security of a Unix system. The basic building blocks of Unix
permissions are the read, write, and execute permissions,
which are described below −
1. Read
Grants the capability to read ie. view the contents of the file.
2. Write
Grants the capability to modify, or remove the content of the
file.
3. Execute
User with execute permissions can run a file as a program.
Priti Patel 2/20/2024
8
Directory Access Mode
 Directory access modes are listed and organized in the same
manner as any other file. There are a few differences that need to
be mentioned:
1. Read
 Access to a directory means that the user can read the contents.
The user can look at the filenames inside the directory.
2. Write
 Access means that the user can add or delete files to the contents
of the directory.
3. Execute
 Executing a directory doesn't really make a lot of sense so think
of this as a traverse permission.
 A user must have execute access to the bin directory in order to
execute ls or cd command.
Priti Patel 2/20/2024
9
Changing The File Permission - chmod
When system administrator creates user account, he has to
assign these parameters to the user:
The user-id : both its name and numeric number
The group-id: both its name and numeric number
Chmod command sets the permission of one or more
files for all the categories of users.
The command can be used in two manners:
Relative Manner –By specifying changes to the current
permission
Absolute Manner- By Specifying the final permission
Priti Patel 2/20/2024
10
Relative Permission
Here it only changes the permissions specified in command
line & leaves other permissions unchanged.
Syntax: chmod category operation permission filename
Chmod takes as arguments an expression comprising some
letters & symbols that describe the user category & type of
permission being assigned or removed.
User category (user, group, others)
Operation means remove or assign permissions
Type of permission (read, write, execute)
Priti Patel 2/20/2024
11
Relative Permission
Chmod u+x temp.txt
Chmod ugo+x temp.txt
Chmod u+x temp.txt temp1 temp2
Chmod a+x temp.txt
Chmod +x temp.txt
Chmod u-r temp.txt
Chmod a-x,go+r temp.txt
Priti Patel 2/20/2024
12
Relative Permission
Abbreviation Used by chmod
Priti Patel 2/20/2024
13
Category Operation Permission
u – User + Assign Permission r – Read Permission
g – Group - Removes Permission w – Write
Permission
o – Others = Assign absolute Permission x – Execute
Permission
a – All(ugo)

Mais conteúdo relacionado

Semelhante a Linux Operating System. Unix_Lec-6.pptx

Unix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell ScriptUnix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell Script
sbmguys
 
Linux file commands and shell scripts
Linux file commands and shell scriptsLinux file commands and shell scripts
Linux file commands and shell scripts
PrashantTechment
 
101 4.5 manage file permissions and ownership v3
101 4.5 manage file permissions and ownership v3101 4.5 manage file permissions and ownership v3
101 4.5 manage file permissions and ownership v3
Acácio Oliveira
 
Linux practicals T.Y.B.ScIT
Linux practicals T.Y.B.ScITLinux practicals T.Y.B.ScIT
Linux practicals T.Y.B.ScIT
vignesh0009
 
OS Unit IV.ppt
OS Unit IV.pptOS Unit IV.ppt
OS Unit IV.ppt
FarhanaMariyam1
 
Linux introductory-course-day-1
Linux introductory-course-day-1Linux introductory-course-day-1
Linux introductory-course-day-1
Julio Pulido
 
FILE PERMISSION OR ACCESS MODE
 FILE PERMISSION OR ACCESS MODE FILE PERMISSION OR ACCESS MODE
FILE PERMISSION OR ACCESS MODE
Vpmv
 
prateekporwal
prateekporwalprateekporwal
prateekporwal
prateekporwal
 
Introduction 2 linux
Introduction 2 linuxIntroduction 2 linux
Introduction 2 linux
Papu Kumar
 
Linux Systems Programming: File Handling
Linux Systems Programming: File HandlingLinux Systems Programming: File Handling
Linux Systems Programming: File Handling
RashidFaridChishti
 
4.5 manage file permissions and ownership v3
4.5 manage file permissions and ownership v34.5 manage file permissions and ownership v3
4.5 manage file permissions and ownership v3
Acácio Oliveira
 
Unix-module3.pptx
Unix-module3.pptxUnix-module3.pptx
Unix-module3.pptx
ssuser8594b8
 
App A
App AApp A
Host security
Host securityHost security
Host security
Nguyen Tam
 
Host security
Host securityHost security
Host security
Nguyen Tam
 
Unix.system.calls
Unix.system.callsUnix.system.calls
Unix.system.calls
GRajendra
 
Linux 4 you
Linux 4 youLinux 4 you
Linux 4 you
Shashwat Shriparv
 
101 3.2 process text streams using filters
101 3.2 process text streams using filters101 3.2 process text streams using filters
101 3.2 process text streams using filters
Acácio Oliveira
 
101 3.4 use streams, pipes and redirects v2
101 3.4 use streams, pipes and redirects v2101 3.4 use streams, pipes and redirects v2
101 3.4 use streams, pipes and redirects v2
Acácio Oliveira
 
intro unix/linux 09
intro unix/linux 09intro unix/linux 09
intro unix/linux 09
duquoi
 

Semelhante a Linux Operating System. Unix_Lec-6.pptx (20)

Unix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell ScriptUnix/Linux Basic Commands and Shell Script
Unix/Linux Basic Commands and Shell Script
 
Linux file commands and shell scripts
Linux file commands and shell scriptsLinux file commands and shell scripts
Linux file commands and shell scripts
 
101 4.5 manage file permissions and ownership v3
101 4.5 manage file permissions and ownership v3101 4.5 manage file permissions and ownership v3
101 4.5 manage file permissions and ownership v3
 
Linux practicals T.Y.B.ScIT
Linux practicals T.Y.B.ScITLinux practicals T.Y.B.ScIT
Linux practicals T.Y.B.ScIT
 
OS Unit IV.ppt
OS Unit IV.pptOS Unit IV.ppt
OS Unit IV.ppt
 
Linux introductory-course-day-1
Linux introductory-course-day-1Linux introductory-course-day-1
Linux introductory-course-day-1
 
FILE PERMISSION OR ACCESS MODE
 FILE PERMISSION OR ACCESS MODE FILE PERMISSION OR ACCESS MODE
FILE PERMISSION OR ACCESS MODE
 
prateekporwal
prateekporwalprateekporwal
prateekporwal
 
Introduction 2 linux
Introduction 2 linuxIntroduction 2 linux
Introduction 2 linux
 
Linux Systems Programming: File Handling
Linux Systems Programming: File HandlingLinux Systems Programming: File Handling
Linux Systems Programming: File Handling
 
4.5 manage file permissions and ownership v3
4.5 manage file permissions and ownership v34.5 manage file permissions and ownership v3
4.5 manage file permissions and ownership v3
 
Unix-module3.pptx
Unix-module3.pptxUnix-module3.pptx
Unix-module3.pptx
 
App A
App AApp A
App A
 
Host security
Host securityHost security
Host security
 
Host security
Host securityHost security
Host security
 
Unix.system.calls
Unix.system.callsUnix.system.calls
Unix.system.calls
 
Linux 4 you
Linux 4 youLinux 4 you
Linux 4 you
 
101 3.2 process text streams using filters
101 3.2 process text streams using filters101 3.2 process text streams using filters
101 3.2 process text streams using filters
 
101 3.4 use streams, pipes and redirects v2
101 3.4 use streams, pipes and redirects v2101 3.4 use streams, pipes and redirects v2
101 3.4 use streams, pipes and redirects v2
 
intro unix/linux 09
intro unix/linux 09intro unix/linux 09
intro unix/linux 09
 

Último

Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
MDSABBIROJJAMANPAYEL
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
KrishnaveniKrishnara1
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
shadow0702a
 
Applications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdfApplications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdf
Atif Razi
 
artificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptxartificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptx
GauravCar
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
Madan Karki
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
171ticu
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
VICTOR MAESTRE RAMIREZ
 
Software Quality Assurance-se412-v11.ppt
Software Quality Assurance-se412-v11.pptSoftware Quality Assurance-se412-v11.ppt
Software Quality Assurance-se412-v11.ppt
TaghreedAltamimi
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
Material for memory and display system h
Material for memory and display system hMaterial for memory and display system h
Material for memory and display system h
gowrishankartb2005
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
kandramariana6
 
An improved modulation technique suitable for a three level flying capacitor ...
An improved modulation technique suitable for a three level flying capacitor ...An improved modulation technique suitable for a three level flying capacitor ...
An improved modulation technique suitable for a three level flying capacitor ...
IJECEIAES
 
Design and optimization of ion propulsion drone
Design and optimization of ion propulsion droneDesign and optimization of ion propulsion drone
Design and optimization of ion propulsion drone
bjmsejournal
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
Gino153088
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
Hitesh Mohapatra
 
People as resource Grade IX.pdf minimala
People as resource Grade IX.pdf minimalaPeople as resource Grade IX.pdf minimala
People as resource Grade IX.pdf minimala
riddhimaagrawal986
 
Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
21UME003TUSHARDEB
 
Welding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdfWelding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdf
AjmalKhan50578
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
RamonNovais6
 

Último (20)

Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
 
Applications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdfApplications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdf
 
artificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptxartificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptx
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
 
Software Quality Assurance-se412-v11.ppt
Software Quality Assurance-se412-v11.pptSoftware Quality Assurance-se412-v11.ppt
Software Quality Assurance-se412-v11.ppt
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
Material for memory and display system h
Material for memory and display system hMaterial for memory and display system h
Material for memory and display system h
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
 
An improved modulation technique suitable for a three level flying capacitor ...
An improved modulation technique suitable for a three level flying capacitor ...An improved modulation technique suitable for a three level flying capacitor ...
An improved modulation technique suitable for a three level flying capacitor ...
 
Design and optimization of ion propulsion drone
Design and optimization of ion propulsion droneDesign and optimization of ion propulsion drone
Design and optimization of ion propulsion drone
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
 
People as resource Grade IX.pdf minimala
People as resource Grade IX.pdf minimalaPeople as resource Grade IX.pdf minimala
People as resource Grade IX.pdf minimala
 
Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
 
Welding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdfWelding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdf
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
 

Linux Operating System. Unix_Lec-6.pptx

  • 2. Outline  Revision  Simple Filter Commands  Filter Using Regular Expression  Redirection of Standard Input and Output  File and Directory Access Modes  Changing the File Permission Priti Patel 2/20/2024 2
  • 3. Redirection of Standard Input and Output Terminal: In context of redirection the terminal is generic name that represents the screen, display or keyboard. Command output and error message on terminal (Display). Provides commands input through terminal (keyboard). When user logs in , the shell makes available three files representing three streams. Standard Input- The file (or Stream) for input Standard Output- The file(or Stream) for output Standard Error- for Error message. Connected to display. Priti Patel 2/20/2024 3
  • 4. Redirection of Standard Input and Output Standard Input: The input of a command be redirected from a file. The less-than character < is used to redirect the input of a command. case1: wc –l users case2: wc -l < users Difference In the first case, wc knows that it is reading its input from the file users.  In the second case, it only knows that it is reading its input from standard input so it does not display file name. Priti Patel 2/20/2024 4
  • 5. Redirection of Standard Input and Output Standard Output: If the notation > file is appended to any command that normally writes its output to standard output, the output of that command will be written to file instead of your terminal. You can use >> operator to append the output in an existing file. For Eg: cut –d “ “ –f 2 1.txt > std_out Priti Patel 2/20/2024 5
  • 6. Redirection of Standard Input and Output Standard Error: The three standard files are represented by a number called a file descriptor. The kernel maintains a table of file descriptor for every process running in the system. Three standard streams are :  0-Standard input 1- Standard output 2- Standard error The descriptor are implicitly prefixed to the redirection symbols. Priti Patel 2/20/2024 6
  • 7. Redirection of Standard Input and Output < , 0< and > ,1> mean same. Standard error : Enter incorrect command or try to open nonexistent file, certain diagnostic message show up the screen. For Eg. Cat test > errorfile is incorrect Cat test 2> errorfile is correct tty: Knowing your terminal UNIX treats terminal as a files. One who wants to know about filename of the terminal you are using. tty (teletype)command Syntax: $tty Priti Patel 2/20/2024 7
  • 8. File Access Mode The permissions of a file are the first line of defense in the security of a Unix system. The basic building blocks of Unix permissions are the read, write, and execute permissions, which are described below − 1. Read Grants the capability to read ie. view the contents of the file. 2. Write Grants the capability to modify, or remove the content of the file. 3. Execute User with execute permissions can run a file as a program. Priti Patel 2/20/2024 8
  • 9. Directory Access Mode  Directory access modes are listed and organized in the same manner as any other file. There are a few differences that need to be mentioned: 1. Read  Access to a directory means that the user can read the contents. The user can look at the filenames inside the directory. 2. Write  Access means that the user can add or delete files to the contents of the directory. 3. Execute  Executing a directory doesn't really make a lot of sense so think of this as a traverse permission.  A user must have execute access to the bin directory in order to execute ls or cd command. Priti Patel 2/20/2024 9
  • 10. Changing The File Permission - chmod When system administrator creates user account, he has to assign these parameters to the user: The user-id : both its name and numeric number The group-id: both its name and numeric number Chmod command sets the permission of one or more files for all the categories of users. The command can be used in two manners: Relative Manner –By specifying changes to the current permission Absolute Manner- By Specifying the final permission Priti Patel 2/20/2024 10
  • 11. Relative Permission Here it only changes the permissions specified in command line & leaves other permissions unchanged. Syntax: chmod category operation permission filename Chmod takes as arguments an expression comprising some letters & symbols that describe the user category & type of permission being assigned or removed. User category (user, group, others) Operation means remove or assign permissions Type of permission (read, write, execute) Priti Patel 2/20/2024 11
  • 12. Relative Permission Chmod u+x temp.txt Chmod ugo+x temp.txt Chmod u+x temp.txt temp1 temp2 Chmod a+x temp.txt Chmod +x temp.txt Chmod u-r temp.txt Chmod a-x,go+r temp.txt Priti Patel 2/20/2024 12
  • 13. Relative Permission Abbreviation Used by chmod Priti Patel 2/20/2024 13 Category Operation Permission u – User + Assign Permission r – Read Permission g – Group - Removes Permission w – Write Permission o – Others = Assign absolute Permission x – Execute Permission a – All(ugo)