SlideShare ist ein Scribd-Unternehmen logo
1 von 49
Downloaden Sie, um offline zu lesen
Shell Basic
@zhiyelee!
F2E!
https://github.com/zhiyelee
How to learn
• man man man !
• practice
dir/file manipulation
• mkdir / mkdir -p!
• rmdir / rmdir -p!
• rm -rf!
• cp -i!
• ln -s
cd
ls
• ls -- list directory contents!
• Options!
• -l,-a,-t!
• -Ut
ls
tree
• tree -- list files in tree-like format!
• Options!
• -a,-d,-f!
• -P,-I
tree
Display Files
cat
• cat - Concatenate Files!
• cat -n !
• cat -s
cat
cat multiple files
less & more
• less/more!
• less line move,more page move!
• does not read the entire input file before starting!
• less -N line-number!
• ls /etc | less
tail & head
• tail !
• tail -f!
• tail -5!
!
• head!
• head -5
wc
• wc -l
echo
• echo -e!
• echo -n
echo
Identifying Commands
• type - Display A Command's Type!
• type cd!
• type ll
type
Identifying Commands
• which - Display An Executable's Location!
• which ls!
• cat `which hlfile`
which
Redirction
Redirection
• stdin,stdout,stderr!
• 0 1 2!
• /dev/null!
• < > >>!
• Case!
• redirect error!
• redirect stdout and error to a file
2>&1
Permissions
" chmod – Change a file's mode!
" umask – Set the default file permissions!
" su – Run a shell as another user!
" sudo – Execute a command as another user!
" chown – Change a file's owner
from《The Linux Command Line》William E. Shotts, Jr.
umask
• umask!
• the default permissions of created file!
• octal notation !
• express a mask of bits to be removed from a file's
mode attributes!
• common default value: 022 002
umask
umask 022
owner group other
original file mode
rw-

110
rw-

110
rw-

110
umask 000 010 010
mode of created file
rw-

110
r—

100
r—

100
umask 002
owner group other
original file mode
rw-

110
rw-

110
rw-

110
umask 000 000 010
mode of created file
rw-

110
rw-

110
r—

100
chmod
• chmod!
• change file mode(permissions)!
• usage!
• chmod 755 file!
• chmod ug+x file
chmod
Search
Grep
• Options!
• -v, -l,-L, -A, -B,n, -r/-R!
• Case!
• get templates contains `misc` cssfile!
• get templates not contain `footer.php`!
• contain `misc` but not `footer.php`
get templates contains `misc` cssfile
get templates not contain `footer.php`
contain `misc` but not `footer.php`
Grep
Find
• Options!
• -name, -perm, -delete,-regex!
• !!
• Case!
• find all .swp files!
• delete all .swp files!
• find not .png and jpg file
find and delete
Find
find perm
trap
Case Study
• deploywww!
• fetch all imgs of a cssfile!
• git pu
fetch all imgs of a css file
git pu
Reference
• 《The Linux Command Line》William E. Shotts, Jr.!
• 20130109 - 李志业 - Shell编程

Weitere ähnliche Inhalte

Was ist angesagt?

UPenn on Rails pt 1
UPenn on Rails pt 1UPenn on Rails pt 1
UPenn on Rails pt 1
Mat Schaffer
 
Vim Script Programming
Vim Script ProgrammingVim Script Programming
Vim Script Programming
Lin Yo-An
 
UPenn on Rails pt 2
UPenn on Rails pt 2UPenn on Rails pt 2
UPenn on Rails pt 2
Mat Schaffer
 
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHP
Jeremy Kendall
 

Was ist angesagt? (15)

UPenn on Rails pt 1
UPenn on Rails pt 1UPenn on Rails pt 1
UPenn on Rails pt 1
 
Getting Started with Microsoft Bot Framework
Getting Started with Microsoft Bot FrameworkGetting Started with Microsoft Bot Framework
Getting Started with Microsoft Bot Framework
 
Word Play in the Digital Age: Building Text Bots with Tracery
Word Play in the Digital Age: Building Text Bots with TraceryWord Play in the Digital Age: Building Text Bots with Tracery
Word Play in the Digital Age: Building Text Bots with Tracery
 
Having Fun Programming!
Having Fun Programming!Having Fun Programming!
Having Fun Programming!
 
Vim Script Programming
Vim Script ProgrammingVim Script Programming
Vim Script Programming
 
UPenn on Rails pt 2
UPenn on Rails pt 2UPenn on Rails pt 2
UPenn on Rails pt 2
 
Efficient DBA: Gain Time by Reducing Command-Line Keystrokes
Efficient DBA: Gain Time by Reducing Command-Line KeystrokesEfficient DBA: Gain Time by Reducing Command-Line Keystrokes
Efficient DBA: Gain Time by Reducing Command-Line Keystrokes
 
Node.js
Node.jsNode.js
Node.js
 
Why ruby
Why rubyWhy ruby
Why ruby
 
구름 이야기(Feat. gcp) - 구글클라우드(GCP) 활용 사례
구름 이야기(Feat. gcp) - 구글클라우드(GCP) 활용 사례구름 이야기(Feat. gcp) - 구글클라우드(GCP) 활용 사례
구름 이야기(Feat. gcp) - 구글클라우드(GCP) 활용 사례
 
Php 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the GoodPhp 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the Good
 
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHP
 
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHP
 
Ruby on Rails: Tasty Burgers
Ruby on Rails: Tasty BurgersRuby on Rails: Tasty Burgers
Ruby on Rails: Tasty Burgers
 
Beginner's Sinatra
Beginner's SinatraBeginner's Sinatra
Beginner's Sinatra
 

Andere mochten auch

Diapositivas Joyas
Diapositivas Joyas Diapositivas Joyas
Diapositivas Joyas
jacko221
 
Extending the design process into the knowledge of the world
Extending the design process into the knowledge of the worldExtending the design process into the knowledge of the world
Extending the design process into the knowledge of the world
Pieter Pauwels
 
Diapositivas gemas
Diapositivas gemasDiapositivas gemas
Diapositivas gemas
jacko221
 

Andere mochten auch (20)

Diapositivas Joyas
Diapositivas Joyas Diapositivas Joyas
Diapositivas Joyas
 
Gratuity act
Gratuity actGratuity act
Gratuity act
 
How to give effective feedback
How to give effective feedbackHow to give effective feedback
How to give effective feedback
 
Extending the design process into the knowledge of the world
Extending the design process into the knowledge of the worldExtending the design process into the knowledge of the world
Extending the design process into the knowledge of the world
 
Examination endgame
Examination endgameExamination endgame
Examination endgame
 
Can ontologies help in a preliminary design stage?
Can ontologies help in a preliminary design stage?Can ontologies help in a preliminary design stage?
Can ontologies help in a preliminary design stage?
 
Diapositivas gemas
Diapositivas gemasDiapositivas gemas
Diapositivas gemas
 
__proto__-and-prototype
  __proto__-and-prototype  __proto__-and-prototype
__proto__-and-prototype
 
Increasing information feed in the process of structural steel design
Increasing information feed in the process of structural steel designIncreasing information feed in the process of structural steel design
Increasing information feed in the process of structural steel design
 
Interoperability for the design and construction industry through semantic we...
Interoperability for the design and construction industry through semantic we...Interoperability for the design and construction industry through semantic we...
Interoperability for the design and construction industry through semantic we...
 
Architectural Information Modelling in Construction History
Architectural Information Modelling in Construction HistoryArchitectural Information Modelling in Construction History
Architectural Information Modelling in Construction History
 
Praktikal 5 amali(2)
Praktikal 5   amali(2)Praktikal 5   amali(2)
Praktikal 5 amali(2)
 
Copy of the_industrial_disputes_act
Copy of the_industrial_disputes_actCopy of the_industrial_disputes_act
Copy of the_industrial_disputes_act
 
Reasoning with data: building performance checking and schema transformations
Reasoning with data: building performance checking and schema transformationsReasoning with data: building performance checking and schema transformations
Reasoning with data: building performance checking and schema transformations
 
Hospital attire is part of besic hygiene routines
Hospital attire is part of besic hygiene routinesHospital attire is part of besic hygiene routines
Hospital attire is part of besic hygiene routines
 
A 71 year old man with peripheral edema pleural effusion ascites and breathle...
A 71 year old man with peripheral edema pleural effusion ascites and breathle...A 71 year old man with peripheral edema pleural effusion ascites and breathle...
A 71 year old man with peripheral edema pleural effusion ascites and breathle...
 
Maternity benefit act_1961
Maternity benefit act_1961Maternity benefit act_1961
Maternity benefit act_1961
 
Basic of jMeter
Basic of jMeter Basic of jMeter
Basic of jMeter
 
Apache JMeter - A Brief Introduction
Apache JMeter - A Brief IntroductionApache JMeter - A Brief Introduction
Apache JMeter - A Brief Introduction
 
Nagios, Getting Started.
Nagios, Getting Started.Nagios, Getting Started.
Nagios, Getting Started.
 

Ähnlich wie Shell basic

Migrating a Site Quickly with SSH and WP-CLI (It's not as scary as you think!)
Migrating a Site Quickly with SSH and WP-CLI (It's not as scary as you think!)Migrating a Site Quickly with SSH and WP-CLI (It's not as scary as you think!)
Migrating a Site Quickly with SSH and WP-CLI (It's not as scary as you think!)
Japheth Thomson
 
Custom PDFs from the DITA OT
Custom PDFs from the DITA OTCustom PDFs from the DITA OT
Custom PDFs from the DITA OT
Leigh White
 
Linux operating system by Quontra Solutions
Linux operating system by Quontra SolutionsLinux operating system by Quontra Solutions
Linux operating system by Quontra Solutions
QUONTRASOLUTIONS
 
Fabric
FabricFabric
Fabric
JS Lee
 

Ähnlich wie Shell basic (20)

Linux commands
Linux commandsLinux commands
Linux commands
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Lpt lopsa
Lpt lopsaLpt lopsa
Lpt lopsa
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
 
Linex
LinexLinex
Linex
 
Migrating a Site Quickly with SSH and WP-CLI (It's not as scary as you think!)
Migrating a Site Quickly with SSH and WP-CLI (It's not as scary as you think!)Migrating a Site Quickly with SSH and WP-CLI (It's not as scary as you think!)
Migrating a Site Quickly with SSH and WP-CLI (It's not as scary as you think!)
 
redhat_by_Cbitss.ppt
redhat_by_Cbitss.pptredhat_by_Cbitss.ppt
redhat_by_Cbitss.ppt
 
System Programming and Administration
System Programming and AdministrationSystem Programming and Administration
System Programming and Administration
 
2. UNIX OS System Architecture easy.pptx
2. UNIX OS System Architecture easy.pptx2. UNIX OS System Architecture easy.pptx
2. UNIX OS System Architecture easy.pptx
 
LINUX_admin_commands.pptx
LINUX_admin_commands.pptxLINUX_admin_commands.pptx
LINUX_admin_commands.pptx
 
Scaling Servers and Storage for Film Assets
Scaling Servers and Storage for Film Assets  Scaling Servers and Storage for Film Assets
Scaling Servers and Storage for Film Assets
 
Custom PDFs from the DITA OT
Custom PDFs from the DITA OTCustom PDFs from the DITA OT
Custom PDFs from the DITA OT
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
 
Linux Shell Scripting.pptx
Linux Shell Scripting.pptxLinux Shell Scripting.pptx
Linux Shell Scripting.pptx
 
LinuxCommands (1).pdf
LinuxCommands (1).pdfLinuxCommands (1).pdf
LinuxCommands (1).pdf
 
Course 102: Lecture 10: Learning About the Shell
Course 102: Lecture 10: Learning About the Shell Course 102: Lecture 10: Learning About the Shell
Course 102: Lecture 10: Learning About the Shell
 
Linux operating system by Quontra Solutions
Linux operating system by Quontra SolutionsLinux operating system by Quontra Solutions
Linux operating system by Quontra Solutions
 
Linux again
Linux againLinux again
Linux again
 
Fabric
FabricFabric
Fabric
 
Class 2
Class   2Class   2
Class 2
 

Kürzlich hochgeladen

Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Lisi Hocke
 

Kürzlich hochgeladen (20)

The mythical technical debt. (Brooke, please, forgive me)
The mythical technical debt. (Brooke, please, forgive me)The mythical technical debt. (Brooke, please, forgive me)
The mythical technical debt. (Brooke, please, forgive me)
 
BusinessGPT - Security and Governance for Generative AI
BusinessGPT  - Security and Governance for Generative AIBusinessGPT  - Security and Governance for Generative AI
BusinessGPT - Security and Governance for Generative AI
 
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit MilanWorkshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
 
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
 
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
 
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
 
Lessons Learned from Building a Serverless Notifications System.pdf
Lessons Learned from Building a Serverless Notifications System.pdfLessons Learned from Building a Serverless Notifications System.pdf
Lessons Learned from Building a Serverless Notifications System.pdf
 
Abortion Clinic In Polokwane ](+27832195400*)[ 🏥 Safe Abortion Pills in Polok...
Abortion Clinic In Polokwane ](+27832195400*)[ 🏥 Safe Abortion Pills in Polok...Abortion Clinic In Polokwane ](+27832195400*)[ 🏥 Safe Abortion Pills in Polok...
Abortion Clinic In Polokwane ](+27832195400*)[ 🏥 Safe Abortion Pills in Polok...
 
From Theory to Practice: Utilizing SpiraPlan's REST API
From Theory to Practice: Utilizing SpiraPlan's REST APIFrom Theory to Practice: Utilizing SpiraPlan's REST API
From Theory to Practice: Utilizing SpiraPlan's REST API
 
Spring into AI presented by Dan Vega 5/14
Spring into AI presented by Dan Vega 5/14Spring into AI presented by Dan Vega 5/14
Spring into AI presented by Dan Vega 5/14
 
Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...
Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...
Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...
 
How to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabberHow to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabber
 
Weeding your micro service landscape.pdf
Weeding your micro service landscape.pdfWeeding your micro service landscape.pdf
Weeding your micro service landscape.pdf
 
What is a Recruitment Management Software?
What is a Recruitment Management Software?What is a Recruitment Management Software?
What is a Recruitment Management Software?
 
Transformer Neural Network Use Cases with Links
Transformer Neural Network Use Cases with LinksTransformer Neural Network Use Cases with Links
Transformer Neural Network Use Cases with Links
 
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
 
^Clinic ^%[+27788225528*Abortion Pills For Sale In soweto
^Clinic ^%[+27788225528*Abortion Pills For Sale In soweto^Clinic ^%[+27788225528*Abortion Pills For Sale In soweto
^Clinic ^%[+27788225528*Abortion Pills For Sale In soweto
 
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
 
Salesforce Introduced Zero Copy Partner Network to Simplify the Process of In...
Salesforce Introduced Zero Copy Partner Network to Simplify the Process of In...Salesforce Introduced Zero Copy Partner Network to Simplify the Process of In...
Salesforce Introduced Zero Copy Partner Network to Simplify the Process of In...
 
OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024
 

Shell basic