SlideShare a Scribd company logo
Linux shell tricks
Topics
Topics
● Me talking
○ Useful key combinations
○ Basic commands
○ Special shell expressions
○ Pipes and redirects
○ On-the-fly “scripts”
○ vim survival guide
○ Customizing the shell
● You doing
○ Get information from a set of
log files
● Q&A
Key combinations
Key combinations
Ctrl+C Panic button. Usually stops what’s going on (C = Cancel)
↑, ↓ Move through previous commands
Ctrl+R Search in history. (Start typing to search, arrow keys to use + modify command)
Ctrl+Z Suspend current program without terminating it. Resume with fg
Basic commands
Basic commands
ls List files du Show disk usage of files
touch Create a file or update mtime df Show free disk space
mkdir / rmdir Create/delete directory lsof List open files / sockets
rm Delete file ssh Secure shell on another machine
find Find files and directories xargs Run command for every line of input
cat Show file contents sed Modify text files
less Show file contents for users cut Select columns
grep Find text in file(s) man Get Help
head, tail Get first / last lines
Special chars
Special shell expressions
* Match 0, 1 or more characters in file names
? Match exactly 1 character in file names
{N..M} Generate a sequence of numbers from N to M
`...` Backticks: Execute the command between the backticks and insert the output at that place
~ The home directory
Shell expansions
Often-used characters
- Dash: The previous ‘thing’ (cd, git, …) or the input (cat)
-- Double dash: End of arguments (more on that later)
Pipes and Redirects
Pipes and redirects
Input:
● standard input (“STDIN”)
○ usually the user typing on their keyboard
Outputs:
● standard output (“STDOUT”)
○ usually printed on the screen
● standard error (“STDERR”)
○ usually printed on the screen
Pipes and redirects
| Pipe: pass the output of one program to another program
> Save the output of a program into a file, deletes the old file contents!
>> Same as >, but appends to the original file (creates the file if necessary)
< Pass the contents of a file as input to the program
2>, 2>> Same as >, >> but for error output
&1 Instead of a filename, this is the standard output.
For example: 2> &1 redirects the error output to standard output.
On-the-fly scripts
On-the-fly scripts
● Chain commands with ;
● Sub shells with ( )
● loops with for and while
vim survival guide
vim survival guide
The first thing you do when bad things happen: Get a clean state
● ESC ESC ESC ^C ^C ESC ESC
Edit text: Hit I (“insert mode” - then vim works almost like an ordinary editor).
● Leave insert mode with ESC
Undo: Hit U (press repeated times to go back further)
Copy & Paste:
● Start selection with v or Shift+V (whole lines)
● Hit Y to copy or D to cut. Move to new position and hit p
Save and quit: type “:wq” and hit Return
Quit without saving: “:q!” + Return
Shell Customizations
Hands-On
Hands-On
Log file processing:
● Count the occurrences of HTTP status codes
● Get a list of customer IDs which were denied for manual refunds

More Related Content

PPT
Vi editor in linux
PDF
PPTX
Linux Basic commands and VI Editor
PDF
Basic basic solaris quick referent card
PPT
ODP
Linux commd
ODP
Linux commd
PDF
Unit 5 vim an advanced text editor
Vi editor in linux
Linux Basic commands and VI Editor
Basic basic solaris quick referent card
Linux commd
Linux commd
Unit 5 vim an advanced text editor

What's hot (20)

PDF
Unit 6 bash shell
PPTX
Unix - Shell Scripts
PPTX
Pipes and filters
PPTX
Linux commands part4
DOCX
Basic linux commands
PDF
Command line for the beginner - Using the command line in developing for the...
TXT
PPTX
Terminal commands ubuntu 2
PDF
Unit 11 configuring the bash shell – shell script
DOCX
lec4.docx
PPT
Linux commands part3
PDF
Tips and Tricks for Increased Development Efficiency
PPT
Basic command ppt
PPT
Linux directory commands:more options on cd and ls command
PPTX
Unix - Filters/Editors
PDF
Linux basic commands with examples
PPTX
Command-Line 101
ODP
Introduction to Shell script
ODP
Ubuntu Terminal
PDF
2.1.using the shell
Unit 6 bash shell
Unix - Shell Scripts
Pipes and filters
Linux commands part4
Basic linux commands
Command line for the beginner - Using the command line in developing for the...
Terminal commands ubuntu 2
Unit 11 configuring the bash shell – shell script
lec4.docx
Linux commands part3
Tips and Tricks for Increased Development Efficiency
Basic command ppt
Linux directory commands:more options on cd and ls command
Unix - Filters/Editors
Linux basic commands with examples
Command-Line 101
Introduction to Shell script
Ubuntu Terminal
2.1.using the shell
Ad

Similar to Tech talk 01.06.2017 (20)

PPTX
578781850-RHSA-1-Chapte578781850-RHSA-1-Chapter-4r-4.pptx
PPT
Using Unix
PPT
workshop_1.ppt
ODP
Linuxs1
PPTX
Lpt lopsa
PPT
02 linux desktop usage
PPT
101 3.4 use streams, pipes and redirects
PPTX
Using Vi Editor.pptx
PPTX
Using Vi Editor.pptx
PPTX
ODP
Nithi
PDF
2023comp90024_linux2.pdf
PPTX
Licão 08 system redirects
PPTX
Commands and shell programming (3)
PPTX
Linux Fundamentals
PPTX
Linux System commands Essentialsand Basics.pptx
PDF
21bUc8YeDzZpE
PDF
21bUc8YeDzZpE
PDF
(Ebook) linux shell scripting tutorial
PDF
21bUc8YeDzZpE
578781850-RHSA-1-Chapte578781850-RHSA-1-Chapter-4r-4.pptx
Using Unix
workshop_1.ppt
Linuxs1
Lpt lopsa
02 linux desktop usage
101 3.4 use streams, pipes and redirects
Using Vi Editor.pptx
Using Vi Editor.pptx
Nithi
2023comp90024_linux2.pdf
Licão 08 system redirects
Commands and shell programming (3)
Linux Fundamentals
Linux System commands Essentialsand Basics.pptx
21bUc8YeDzZpE
21bUc8YeDzZpE
(Ebook) linux shell scripting tutorial
21bUc8YeDzZpE
Ad

More from AboutYouGmbH (20)

PDF
Retention Strategies in Mobile E-Commerce
PDF
Rethinking Fashion E-Commerce
PDF
ABOUT YOU get on board
PDF
Niels Leenheer - Weird browsers - code.talks 2015
PDF
Dennis Benkert & Matthias Lübken - Patterns in a containerized world? - code....
PDF
Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...
PDF
Lars Jankowfsky - Learn or Die - code.talks 2015
PDF
Dr. Jeremias Rößler - Wenn Affen Testen - Das Ende der Bananensoftware - code...
PDF
Zeljko Kvesic - Scrum in verteilten Teams / Agil über die Landesgrenzen - cod...
PDF
Uwe Friedrichsen - CRDT und mehr - über extreme Verfügbarkeit und selbstheile...
PDF
Kai Voigt - Big Data zum Anfassen - code.talks 2015
PDF
Dr. Andreas Lattner - Aufsetzen skalierbarer Prognose- und Analysedienste mit...
PDF
Marcel Hild - Spryker (e)commerce framework als Alternative zu traditioneller...
PDF
Wolfram Kriesing - EcmaScript6 for real - code.talks 2015
PDF
Stefanie Grewenig & Johannes Thönes - Internet ausdrucken mit JavaScript - c...
PDF
Alex Korotkikh - From 0 to N: Lessons Learned - code.talks 2015
PDF
Christian Haider & Helge Nowak - Mehr Demokratie durch Haushaltstransparenz ...
PDF
Bernhard Wick - appserver.io - code.talks 2015
PDF
Moritz Siuts & Robert von Massow - Data Pipeline mit Apache Kafka - code.tal...
PDF
Carina Bittihn & Linda Dettmann - Same Same but Different - code.talks 2015
Retention Strategies in Mobile E-Commerce
Rethinking Fashion E-Commerce
ABOUT YOU get on board
Niels Leenheer - Weird browsers - code.talks 2015
Dennis Benkert & Matthias Lübken - Patterns in a containerized world? - code....
Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...
Lars Jankowfsky - Learn or Die - code.talks 2015
Dr. Jeremias Rößler - Wenn Affen Testen - Das Ende der Bananensoftware - code...
Zeljko Kvesic - Scrum in verteilten Teams / Agil über die Landesgrenzen - cod...
Uwe Friedrichsen - CRDT und mehr - über extreme Verfügbarkeit und selbstheile...
Kai Voigt - Big Data zum Anfassen - code.talks 2015
Dr. Andreas Lattner - Aufsetzen skalierbarer Prognose- und Analysedienste mit...
Marcel Hild - Spryker (e)commerce framework als Alternative zu traditioneller...
Wolfram Kriesing - EcmaScript6 for real - code.talks 2015
Stefanie Grewenig & Johannes Thönes - Internet ausdrucken mit JavaScript - c...
Alex Korotkikh - From 0 to N: Lessons Learned - code.talks 2015
Christian Haider & Helge Nowak - Mehr Demokratie durch Haushaltstransparenz ...
Bernhard Wick - appserver.io - code.talks 2015
Moritz Siuts & Robert von Massow - Data Pipeline mit Apache Kafka - code.tal...
Carina Bittihn & Linda Dettmann - Same Same but Different - code.talks 2015

Recently uploaded (20)

PDF
Encapsulation theory and applications.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
August Patch Tuesday
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Empathic Computing: Creating Shared Understanding
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Spectroscopy.pptx food analysis technology
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Machine learning based COVID-19 study performance prediction
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PPTX
Machine Learning_overview_presentation.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
Encapsulation theory and applications.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
NewMind AI Weekly Chronicles - August'25-Week II
Assigned Numbers - 2025 - Bluetooth® Document
August Patch Tuesday
Spectral efficient network and resource selection model in 5G networks
Empathic Computing: Creating Shared Understanding
MIND Revenue Release Quarter 2 2025 Press Release
Diabetes mellitus diagnosis method based random forest with bat algorithm
OMC Textile Division Presentation 2021.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Advanced methodologies resolving dimensionality complications for autism neur...
Spectroscopy.pptx food analysis technology
Univ-Connecticut-ChatGPT-Presentaion.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Machine learning based COVID-19 study performance prediction
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Machine Learning_overview_presentation.pptx
Per capita expenditure prediction using model stacking based on satellite ima...

Tech talk 01.06.2017

  • 3. Topics ● Me talking ○ Useful key combinations ○ Basic commands ○ Special shell expressions ○ Pipes and redirects ○ On-the-fly “scripts” ○ vim survival guide ○ Customizing the shell ● You doing ○ Get information from a set of log files ● Q&A
  • 5. Key combinations Ctrl+C Panic button. Usually stops what’s going on (C = Cancel) ↑, ↓ Move through previous commands Ctrl+R Search in history. (Start typing to search, arrow keys to use + modify command) Ctrl+Z Suspend current program without terminating it. Resume with fg
  • 7. Basic commands ls List files du Show disk usage of files touch Create a file or update mtime df Show free disk space mkdir / rmdir Create/delete directory lsof List open files / sockets rm Delete file ssh Secure shell on another machine find Find files and directories xargs Run command for every line of input cat Show file contents sed Modify text files less Show file contents for users cut Select columns grep Find text in file(s) man Get Help head, tail Get first / last lines
  • 9. Special shell expressions * Match 0, 1 or more characters in file names ? Match exactly 1 character in file names {N..M} Generate a sequence of numbers from N to M `...` Backticks: Execute the command between the backticks and insert the output at that place ~ The home directory Shell expansions Often-used characters - Dash: The previous ‘thing’ (cd, git, …) or the input (cat) -- Double dash: End of arguments (more on that later)
  • 11. Pipes and redirects Input: ● standard input (“STDIN”) ○ usually the user typing on their keyboard Outputs: ● standard output (“STDOUT”) ○ usually printed on the screen ● standard error (“STDERR”) ○ usually printed on the screen
  • 12. Pipes and redirects | Pipe: pass the output of one program to another program > Save the output of a program into a file, deletes the old file contents! >> Same as >, but appends to the original file (creates the file if necessary) < Pass the contents of a file as input to the program 2>, 2>> Same as >, >> but for error output &1 Instead of a filename, this is the standard output. For example: 2> &1 redirects the error output to standard output.
  • 14. On-the-fly scripts ● Chain commands with ; ● Sub shells with ( ) ● loops with for and while
  • 16. vim survival guide The first thing you do when bad things happen: Get a clean state ● ESC ESC ESC ^C ^C ESC ESC Edit text: Hit I (“insert mode” - then vim works almost like an ordinary editor). ● Leave insert mode with ESC Undo: Hit U (press repeated times to go back further) Copy & Paste: ● Start selection with v or Shift+V (whole lines) ● Hit Y to copy or D to cut. Move to new position and hit p Save and quit: type “:wq” and hit Return Quit without saving: “:q!” + Return
  • 19. Hands-On Log file processing: ● Count the occurrences of HTTP status codes ● Get a list of customer IDs which were denied for manual refunds