SlideShare una empresa de Scribd logo
1 de 86
Descargar para leer sin conexión
Text shells
Matt Mokary
and important productivity tips
TERMINAL-ogy
● Terminal window terminal window
TERMINAL-ogy
● Terminal window
● Terminal emulator
terminal emulator
terminal window
TERMINAL-ogy
● Terminal window
● Terminal emulator
terminal emulator
terminal window
TERMINAL-ogy
● Terminal window
● Terminal emulator
● Shell
terminal emulator
shell
terminal window
Modern Shells
● C Shell (csh)
● Bourne Again Shell (bash)
● Korn Shell (ksh)
● Z Shell (zsh)
Modern Shells
● C Shell (csh)
● Bourne Again Shell (bash)
● Korn Shell (ksh)
● Z Shell (zsh)
Basic usage
<program name> <program flags> [ arg1, arg2, … ]
$ ls
Basic usage
<program name> <program flags> [ arg1, arg2, … ]
$ ls
Applications Documents Library
Desktop Downloads Music
$
Basic usage
<program name> <program flags> [ arg1, arg2, … ]
$ ls -a
<program name> <program flags> [ arg1, arg2, … ]
$ ls -a
drwxr-xr-x 3 mattmokary staff 102 Feb 24 12:56 Applications
drwx------+ 5 mattmokary staff 170 Mar 20 17:06 Desktop
drwx------+ 11 mattmokary staff 374 Mar 20 12:03 Documents
drwx------+ 56 mattmokary staff 1904 Mar 20 14:54 Downloads
drwx------@ 49 mattmokary staff 1666 Feb 12 15:42 Library
drwx------+ 5 mattmokary staff 170 Feb 20 00:12 Music
$
Basic usage
<program name> <program flags> [ arg1, arg2, … ]
$ grep -n TODO MyProject.java
Basic usage
Basic usage
<program name> <program flags> [ arg1, arg2, … ]
$ grep -n TODO MyProject.java
23: // TODO is there an off-by-one error here?
131: // TODO document this function
340: // TODO make this more efficient
$
<program name> <program flags> [ arg1, arg2, … ]
$ gcc -o HelloWorld hello_world.c
Basic usage
<program name> <program flags> [ arg1, arg2, … ]
$ gcc -o HelloWorld hello_world.c
$
Basic usage
<program name> <program flags> [ arg1, arg2, … ]
$ gcc -o HelloWorld hello_world.c
$ ls
HelloWorld hello_world.c hello_world.o
$
Basic usage
Streams
Streams
● Standard Input (stdin)
Streams
● Standard Input (stdin)
● Standard Output (stdout)
Streams
● Standard Input (stdin)
● Standard Output (stdout)
● Standard Error (stderr)
Streams
$ cat test.txt
Streams
$ cat test.txt
This is a test file.
It has several lines,
none of which are very helpful.
This is the last line of the file.
$
Stream Redirection
● >
Stream Redirection
● > $ grep TODO MyProject.java
Stream Redirection
● > $ grep TODO MyProject.java
// TODO make this better
// TODO delete these
$
Stream Redirection
● > $ grep TODO MyProject.java > todo.txt
Stream Redirection
● > $ grep TODO MyProject.java > todo.txt
$
Stream Redirection
● > $ grep TODO MyProject.java > todo.txt
$ ls
MyProject.java todo.txt
$
Stream Redirection
● > $ grep TODO MyProject.java > todo.txt
$ ls
MyProject.java todo.txt
$ cat todo.txt
// TODO make this better
// TODO delete these
$
Stream Redirection
● >
>>
$ grep TODO MyProject.java > todo.txt
$ ls
MyProject.java todo.txt
$ cat todo.txt
// TODO make this better
// TODO delete these
$
Stream Redirection
● >
>>
● <
Stream Redirection
● >
>>
● <
$ grep TODO MyProject.java
// TODO make this better
// TODO delete these
$
Stream Redirection
● >
>>
● <
$ grep TODO < MyProject.java
// TODO make this better
// TODO delete these
$
Stream Redirection
● >
>>
● <
● |
Stream Redirection
● >
>>
● <
● |
$ grep TODO MyProject.java > todo.txt
$ wc -l todo.txt
2
$ rm todo.txt
Stream Redirection
● >
>>
● <
● |
$ grep TODO MyProject.java | wc -l
Stream Redirection
● >
>>
● <
● |
$ grep TODO MyProject.java | wc -l
2
Stream Redirection
● >
>>
● <
● |
$ grep TODO MyProject.java | wc -l
2
$ ruby get_hockey_tweets.rb 
| grep -in sedin | grep -i henrik 
| wc -l
173
$
Stream Redirection
● > redirect stdout to file stream
>> append stdout to file stream
● < redirect file stream to stdin
● | redirect stdout and stderr to stdin
Stream Redirection
● stdin (channel 0)
● stdout (channel 1)
● stderr (channel 2)
Stream Redirection
$ ./sqrt -1 2> errors.txt
No real solution.
$
Stream Redirection
$ ./sqrt -1 2> errors.txt
No real solution.
$ cat errors.txt
Argument is less than zero.
$
Stream Redirection
$ ./sqrt -1 2> errors.txt 1> /dev/null
$ cat errors.txt
Argument is less than zero.
$
Stream Redirection
$ ./postfix-solver 3 4 + 2>&1 > /dev/null 
| grep syntax > syntax-errors.txt
Stream Redirection
$ ./postfix-solver 3 4 + 2>&1 > /dev/null 
| grep syntax > syntax-errors.txt
Stream Redirection
$ ./postfix-solver 3 4 + 2>&1 > /dev/null 
| grep syntax > syntax-errors.txt
Stream Redirection
$ ./postfix-solver 3 4 + 2>&1 > /dev/null 
| grep syntax > syntax-errors.txt
Stream Redirection
$ ./postfix-solver 3 4 + 2>&1 > /dev/null 
| grep syntax > syntax-errors.txt
Stream Redirection
$ ./postfix-solver 3 4 + 2>&1 > /dev/null 
| grep syntax > syntax-errors.txt
Stream Redirection
$ ./postfix-solver 3 4 + 2>&1 > /dev/null 
| grep syntax > syntax-errors.txt
$
Stream Redirection
$ ./postfix-solver 3 4 + 2>&1 > /dev/null 
| grep syntax > syntax-errors.txt
$ ls
postfix-solver syntax-errors.txt
$
Stream Redirection
$ ./postfix-solver 3 4 + 2>&1 > /dev/null 
| grep syntax > syntax-errors.txt
$ ls
postfix-solver syntax-errors.txt
$ cat syntax-errors.txt
$
Stream Redirection
● stdin 0
● stdout 1
● stderr 2
● 2> redirect stderr to file stream
● 2>&1 redirect stderr to current stdout
etc.
Every SE Ever:
Every SE Ever:
“I have no idea why this isn’t working.”
Every SE Ever:
“I have no idea why this isn’t working.”
“I have no idea why this is working.”
Every SE Ever:
“I have no idea why this isn’t working.”
“I have no idea why this is working.”
“How do I get out of vim?”
vim Modes
● Normal
vim Modes
● Normal
o insert a new line beneath the cursor, move to it,
and enter insert mode
$ move to the end of the line and remain in
normal mode
i enter insert mode at the cursor’s current
position
I move to the beginning of the line and enter
insert mode
dd cut the current line
vim Modes
● Normal
● Insert
vim Modes
● Normal
● Insert
● Command
vim Modes
● Normal
● Insert
● Command
:w write the buffer to the disk
:q quit vim; will stop you if the file has changed
since the last write
:q! quit vim and discard changes since last write
:wq write the buffer and quit vim
:x same as :wq
:<some number>
move the cursor to line <some number>
Typical vim Workflow
Typical vim Workflow
$ vim some-file.txt
Typical vim Workflow
$ vim some-file.txt
until you’ve made all the desired changes:
navigate through the file in normal mode
Typical vim Workflow
$ vim some-file.txt
until you’ve made all the desired changes:
navigate through the file in normal mode
bounce between normal and insert until part is fixed
Typical vim Workflow
$ vim some-file.txt
until you’ve made all the desired changes:
navigate through the file in normal mode
bounce between normal and insert until part is fixed
enter normal mode and write the file with “:w”
Typical vim Workflow
$ vim some-file.txt
until you’ve made all the desired changes:
navigate through the file in normal mode
bounce between normal and insert until part is fixed
enter normal mode and write the file with “:w”
enter normal mode
Typical vim Workflow
$ vim some-file.txt
until you’ve made all the desired changes:
navigate through the file in normal mode
bounce between normal and insert until part is fixed
enter normal mode and write the file with “:w”
enter normal mode
write the file and quit vim with “:wq” or “:x”
vim Visual Mode
vim Visual Mode
x cut the highlighted text and save it to vim’s
clipboard
y copy the highlighted text and save it to vim’s
clipboard
p (in normal mode)
paste the text in vim’s clipboard into the buffer
after the cursor
P (in normal mode)
paste the text in vim’s clipboard into the buffer
before the cursor
tmux
tmux
$ Shell
tmux
$ tmux new -s Crypto
$
Shell
tmux session
“Crypto”
tmux
$ tmux new -s Crypto
$ tmux ls
Crypto: 1 windows … (attached)
$
Shell
tmux session
“Crypto”
tmux
$ tmux new -s Crypto
$ tmux ls
Crypto: 1 windows … (attached)
$ tmux detach
$
Shell
tmux session
“Crypto”
tmux
$ tmux new -s Crypto
$ tmux ls
Crypto: 1 windows … (attached)
$ tmux detach
$ tmux new -s Grading
$
Shell
tmux session
“Crypto”
tmux session
“Grading”
tmux
$ tmux new -s Crypto
$ tmux ls
Crypto: 1 windows … (attached)
$ tmux detach
$ tmux new -s Grading
$ tmux kill-session -t Crypto
$
Shell
tmux session
“Grading”
tmux
$ tmux new -s Crypto
$ tmux ls
Crypto: 1 windows … (attached)
$ tmux detach
$ tmux new -s Grading
$ tmux kill-session -t Crypto
$ tmux detach
$
Shell
tmux session
“Grading”
tmux Session
tmux Session
CTRL+b % vertical split
tmux Session
CTRL+b % vertical split
CTRL+b “ horizontal
split
tmux Session
CTRL+b % vertical split
CTRL+b “ horizontal
split
CTRL+b x y kill pane
tmux Session
CTRL+b % vertical split
CTRL+b “ horizontal
split
CTRL+b x y kill pane
CTRL+b arrows
navigate panes
My Personal Setup
Thanks!

Más contenido relacionado

La actualidad más candente

Tomáš Čorej - OpenSSH
Tomáš Čorej - OpenSSHTomáš Čorej - OpenSSH
Tomáš Čorej - OpenSSH
webelement
 

La actualidad más candente (20)

Perl - laziness, impatience, hubris, and one liners
Perl - laziness, impatience, hubris, and one linersPerl - laziness, impatience, hubris, and one liners
Perl - laziness, impatience, hubris, and one liners
 
Fast HTTP string processing algorithms
Fast HTTP string processing algorithmsFast HTTP string processing algorithms
Fast HTTP string processing algorithms
 
groovy & grails - lecture 4
groovy & grails - lecture 4groovy & grails - lecture 4
groovy & grails - lecture 4
 
お題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part Aお題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part A
 
Processes And Job Control
Processes And Job ControlProcesses And Job Control
Processes And Job Control
 
Redis & ZeroMQ: How to scale your application
Redis & ZeroMQ: How to scale your applicationRedis & ZeroMQ: How to scale your application
Redis & ZeroMQ: How to scale your application
 
Node.js streaming csv downloads proxy
Node.js streaming csv downloads proxyNode.js streaming csv downloads proxy
Node.js streaming csv downloads proxy
 
Tomáš Čorej - OpenSSH
Tomáš Čorej - OpenSSHTomáš Čorej - OpenSSH
Tomáš Čorej - OpenSSH
 
Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020
Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020
Redis is not just a cache, Andrew Lavers, ConFoo Montreal 2020
 
Basic linux commands
Basic linux commands Basic linux commands
Basic linux commands
 
Introduction to shell scripting
Introduction to shell scriptingIntroduction to shell scripting
Introduction to shell scripting
 
Cis 216 – shell scripting
Cis 216 – shell scriptingCis 216 – shell scripting
Cis 216 – shell scripting
 
R snippet
R snippetR snippet
R snippet
 
Class
ClassClass
Class
 
Getting groovy (ODP)
Getting groovy (ODP)Getting groovy (ODP)
Getting groovy (ODP)
 
Redis as a message queue
Redis as a message queueRedis as a message queue
Redis as a message queue
 
Tech talk 01.06.2017
Tech talk 01.06.2017Tech talk 01.06.2017
Tech talk 01.06.2017
 
Simple tricks to speed you up on the command line
Simple tricks to speed you up on the command lineSimple tricks to speed you up on the command line
Simple tricks to speed you up on the command line
 
Process monitoring in UNIX shell scripting
Process monitoring in UNIX shell scriptingProcess monitoring in UNIX shell scripting
Process monitoring in UNIX shell scripting
 
realpathキャッシュと OPcacheの面倒すぎる関係
realpathキャッシュと OPcacheの面倒すぎる関係realpathキャッシュと OPcacheの面倒すぎる関係
realpathキャッシュと OPcacheの面倒すぎる関係
 

Similar a Unix shell talk - RIT SSE

Biicode OpenExpoDay
Biicode OpenExpoDayBiicode OpenExpoDay
Biicode OpenExpoDay
fcofdezc
 
101 3.4 use streams, pipes and redirects
101 3.4 use streams, pipes and redirects101 3.4 use streams, pipes and redirects
101 3.4 use streams, pipes and redirects
Acácio Oliveira
 
II BCA OS pipes and filters.pptx
II BCA OS pipes and filters.pptxII BCA OS pipes and filters.pptx
II BCA OS pipes and filters.pptx
Savitha74
 
Tuffarsi in vim
Tuffarsi in vimTuffarsi in vim
Tuffarsi in vim
sambismo
 

Similar a Unix shell talk - RIT SSE (20)

Biicode OpenExpoDay
Biicode OpenExpoDayBiicode OpenExpoDay
Biicode OpenExpoDay
 
101 3.4 use streams, pipes and redirects
101 3.4 use streams, pipes and redirects101 3.4 use streams, pipes and redirects
101 3.4 use streams, pipes and redirects
 
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
 
3.4 use streams, pipes and redirects v2
3.4 use streams, pipes and redirects v23.4 use streams, pipes and redirects v2
3.4 use streams, pipes and redirects v2
 
Devel::hdb debugger talk
Devel::hdb debugger talkDevel::hdb debugger talk
Devel::hdb debugger talk
 
Gun make
Gun makeGun make
Gun make
 
Vim Hacks
Vim HacksVim Hacks
Vim Hacks
 
Vim Hacks
Vim HacksVim Hacks
Vim Hacks
 
Course 102: Lecture 8: Composite Commands
Course 102: Lecture 8: Composite Commands Course 102: Lecture 8: Composite Commands
Course 102: Lecture 8: Composite Commands
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
 
Love Your Command Line
Love Your Command LineLove Your Command Line
Love Your Command Line
 
II BCA OS pipes and filters.pptx
II BCA OS pipes and filters.pptxII BCA OS pipes and filters.pptx
II BCA OS pipes and filters.pptx
 
Tuffarsi in vim
Tuffarsi in vimTuffarsi in vim
Tuffarsi in vim
 
50 Most Frequently Used UNIX Linux Commands -hmftj
50 Most Frequently Used UNIX  Linux Commands -hmftj50 Most Frequently Used UNIX  Linux Commands -hmftj
50 Most Frequently Used UNIX Linux Commands -hmftj
 
Vim Eye for the Rails Guy - Cheatsheet
Vim Eye for the Rails Guy - CheatsheetVim Eye for the Rails Guy - Cheatsheet
Vim Eye for the Rails Guy - Cheatsheet
 
workshop_1.ppt
workshop_1.pptworkshop_1.ppt
workshop_1.ppt
 
shellScriptAlt.pptx
shellScriptAlt.pptxshellScriptAlt.pptx
shellScriptAlt.pptx
 
Understanding Autovacuum
Understanding AutovacuumUnderstanding Autovacuum
Understanding Autovacuum
 
Adrian Mouat - Docker Tips and Tricks
 Adrian Mouat - Docker Tips and Tricks Adrian Mouat - Docker Tips and Tricks
Adrian Mouat - Docker Tips and Tricks
 
One-Liners to Rule Them All
One-Liners to Rule Them AllOne-Liners to Rule Them All
One-Liners to Rule Them All
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 

Unix shell talk - RIT SSE