SlideShare uma empresa Scribd logo
1 de 13
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

Linux introductory-course-day-1
Linux introductory-course-day-1Linux introductory-course-day-1
Linux introductory-course-day-1
Julio Pulido
 
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
 

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

Teachers record management system project report..pdf
Teachers record management system project report..pdfTeachers record management system project report..pdf
Teachers record management system project report..pdf
Kamal Acharya
 
ONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdf
ONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdfONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdf
ONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdf
Kamal Acharya
 

Último (20)

Teachers record management system project report..pdf
Teachers record management system project report..pdfTeachers record management system project report..pdf
Teachers record management system project report..pdf
 
"United Nations Park" Site Visit Report.
"United Nations Park" Site  Visit Report."United Nations Park" Site  Visit Report.
"United Nations Park" Site Visit Report.
 
Operating System chapter 9 (Virtual Memory)
Operating System chapter 9 (Virtual Memory)Operating System chapter 9 (Virtual Memory)
Operating System chapter 9 (Virtual Memory)
 
Electrical shop management system project report.pdf
Electrical shop management system project report.pdfElectrical shop management system project report.pdf
Electrical shop management system project report.pdf
 
Filters for Electromagnetic Compatibility Applications
Filters for Electromagnetic Compatibility ApplicationsFilters for Electromagnetic Compatibility Applications
Filters for Electromagnetic Compatibility Applications
 
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptxSLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
 
RM&IPR M5 notes.pdfResearch Methodolgy & Intellectual Property Rights Series 5
RM&IPR M5 notes.pdfResearch Methodolgy & Intellectual Property Rights Series 5RM&IPR M5 notes.pdfResearch Methodolgy & Intellectual Property Rights Series 5
RM&IPR M5 notes.pdfResearch Methodolgy & Intellectual Property Rights Series 5
 
Lab Manual Arduino UNO Microcontrollar.docx
Lab Manual Arduino UNO Microcontrollar.docxLab Manual Arduino UNO Microcontrollar.docx
Lab Manual Arduino UNO Microcontrollar.docx
 
ONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdf
ONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdfONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdf
ONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdf
 
The battle for RAG, explore the pros and cons of using KnowledgeGraphs and Ve...
The battle for RAG, explore the pros and cons of using KnowledgeGraphs and Ve...The battle for RAG, explore the pros and cons of using KnowledgeGraphs and Ve...
The battle for RAG, explore the pros and cons of using KnowledgeGraphs and Ve...
 
Quiz application system project report..pdf
Quiz application system project report..pdfQuiz application system project report..pdf
Quiz application system project report..pdf
 
E-Commerce Shopping using MERN Stack where different modules are present
E-Commerce Shopping using MERN Stack where different modules are presentE-Commerce Shopping using MERN Stack where different modules are present
E-Commerce Shopping using MERN Stack where different modules are present
 
Artificial Intelligence Bayesian Reasoning
Artificial Intelligence Bayesian ReasoningArtificial Intelligence Bayesian Reasoning
Artificial Intelligence Bayesian Reasoning
 
Attraction and Repulsion type Moving Iron Instruments.pptx
Attraction and Repulsion type Moving Iron Instruments.pptxAttraction and Repulsion type Moving Iron Instruments.pptx
Attraction and Repulsion type Moving Iron Instruments.pptx
 
Research Methodolgy & Intellectual Property Rights Series 1
Research Methodolgy & Intellectual Property Rights Series 1Research Methodolgy & Intellectual Property Rights Series 1
Research Methodolgy & Intellectual Property Rights Series 1
 
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdfInstruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
 
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdf
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdfRESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdf
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdf
 
Linux Systems Programming: Semaphores, Shared Memory, and Message Queues
Linux Systems Programming: Semaphores, Shared Memory, and Message QueuesLinux Systems Programming: Semaphores, Shared Memory, and Message Queues
Linux Systems Programming: Semaphores, Shared Memory, and Message Queues
 
ChatGPT Prompt Engineering for project managers.pdf
ChatGPT Prompt Engineering for project managers.pdfChatGPT Prompt Engineering for project managers.pdf
ChatGPT Prompt Engineering for project managers.pdf
 
Interfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdfInterfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdf
 

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)