SlideShare a Scribd company logo
1 of 17
Download to read offline
Command Line
From zero to hero.
What is a shell?
Look, a shell! —>
* Unix pioneered shells.

* Shells are computer programs [Bash, ZSH, Fish, etc]

* You can talk to your OS by issuing commands to the shell, in a
command line interface / terminal.

* You can change your default shell using chsh
Which shell does macOS use?
Did you just say GPL?
* macOS used to use a very old version of bash, the most popular and
well known shell.

* Newest versions of Bash use GPL3 License. Shipping this with
macOS would mean Apple would need to publish source code for their
programs, which sounds like it would empower the user.

* macOS now uses zsh
So what programs can you run?
Anything that is in PATH
If you run echo $PATH you can see places where programs are
loaded from for your current shell session
.

Traditionally: /usr/bi
n

Modern: /usr/local/bin (<— This is where home-brew puts its programs
)

You can run apropos and a search term to find programs that match
your term, i.e apropos text editing
How to use a program
Conventions help discovery
ProgramName -f flagValue input


ProgramName --flag flagValue input
Unix + File Systems
Everything is a
fi
le
Files, Files & More Files
Things you can do with
fi
les
* ls <- List files

* ls -la <- List files including hidden files (start with a .)

* file my_file.txt <- Describe file

* pwd <- Where am I in the filesystem?

* cd aDirectory/ <- change directory to aDirectory

* cd ~ <- change directory to home

* rm aFile ~ <- Remove a file

* rm -rf aDirectory/ ~ <- Remove a directory
History
Re-running commands
* Press up on D-Pad to get last command
* Ctrl + R <- search over history of previous commands
.

* sudo !! <- Rerun last command as Sudo
Pipes
Take output from one command, use it in another
cat file.txt | grep “a string I think is in this file”


cat file.txt | wc -l
Copy & Paste
pbcopy < file.txt


pbpaste > file.txt
pbpaste >> file.txt
Overwrite
Append
Symlinks
* ln ~/some_folder/some_file <- hard link a file

* ln -s ~/some_folder/some_file <- soft link a file
Backgrounding Processes
* Ctrl+Z <- background current process.

* fg <- re-focus process.
De
fi
ne an alias
Run alias to see all aliases currently load in the shell
Profiles + Custom Configuration
~/.zshrc
Change this, and source it (or restart your terminal)
Cool stuff I use
* fzf <- Fuzzy finder

* oh-my-zsh <- Lots of additions to zsh + plugin support (I use git + fzf
plugins)

* jenv, pyenv, rvm, nvm <- Language managers

* tmux <- Terminal multiplexer

* rg <- Ripgrep, much faster that grep

More Related Content

What's hot

Linux commands
Linux commandsLinux commands
Linux commandsU.P Police
 
Top 10 Random Linux/Ubuntu Commands
Top 10 Random Linux/Ubuntu CommandsTop 10 Random Linux/Ubuntu Commands
Top 10 Random Linux/Ubuntu CommandsYusuf Felly
 
3.1.a linux commands reference
3.1.a linux commands reference3.1.a linux commands reference
3.1.a linux commands referenceAcácio Oliveira
 
Linux command for beginners
Linux command for beginnersLinux command for beginners
Linux command for beginnersSuKyeong Jang
 
Basic command ppt
Basic command pptBasic command ppt
Basic command pptRohit Kumar
 
One Page Linux Manual
One Page Linux ManualOne Page Linux Manual
One Page Linux Manualdummy
 
Module 02 Using Linux Command Shell
Module 02 Using Linux Command ShellModule 02 Using Linux Command Shell
Module 02 Using Linux Command ShellTushar B Kute
 
Basic linux bash
Basic linux bashBasic linux bash
Basic linux bash皓鈞 張
 
[PDF] 2021 Termux basic commands list
[PDF] 2021 Termux basic commands list [PDF] 2021 Termux basic commands list
[PDF] 2021 Termux basic commands list nisivaasdfghj
 
Basic unix commands
Basic unix commandsBasic unix commands
Basic unix commandsswtjerin4u
 
Compression
CompressionCompression
Compressionaswathyu
 
Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014Noé Fernández-Pozo
 

What's hot (19)

Linux commands
Linux commandsLinux commands
Linux commands
 
Top 10 Random Linux/Ubuntu Commands
Top 10 Random Linux/Ubuntu CommandsTop 10 Random Linux/Ubuntu Commands
Top 10 Random Linux/Ubuntu Commands
 
Basic linux commands
Basic linux commandsBasic linux commands
Basic linux commands
 
Linux command line
Linux command lineLinux command line
Linux command line
 
Linux basics
Linux basicsLinux basics
Linux basics
 
3.1.a linux commands reference
3.1.a linux commands reference3.1.a linux commands reference
3.1.a linux commands reference
 
Linux command for beginners
Linux command for beginnersLinux command for beginners
Linux command for beginners
 
Linux cheat-sheet
Linux cheat-sheetLinux cheat-sheet
Linux cheat-sheet
 
Basic command ppt
Basic command pptBasic command ppt
Basic command ppt
 
One Page Linux Manual
One Page Linux ManualOne Page Linux Manual
One Page Linux Manual
 
Module 02 Using Linux Command Shell
Module 02 Using Linux Command ShellModule 02 Using Linux Command Shell
Module 02 Using Linux Command Shell
 
Linux cheat sheet
Linux cheat sheetLinux cheat sheet
Linux cheat sheet
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
 
Basic linux bash
Basic linux bashBasic linux bash
Basic linux bash
 
[PDF] 2021 Termux basic commands list
[PDF] 2021 Termux basic commands list [PDF] 2021 Termux basic commands list
[PDF] 2021 Termux basic commands list
 
Basic unix commands
Basic unix commandsBasic unix commands
Basic unix commands
 
Compression
CompressionCompression
Compression
 
Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014
 
Unix for Librarians
Unix for LibrariansUnix for Librarians
Unix for Librarians
 

Similar to Using the command line on macOS

Linux basic for CADD biologist
Linux basic for CADD biologistLinux basic for CADD biologist
Linux basic for CADD biologistAjay Murali
 
Linux Basic Commands
Linux Basic CommandsLinux Basic Commands
Linux Basic CommandsHanan Nmr
 
8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unixsouthees
 
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformaticsBITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformaticsBITS
 
An Introduction to Linux
An Introduction to LinuxAn Introduction to Linux
An Introduction to LinuxDimas Prasetyo
 
Command Line Tools
Command Line ToolsCommand Line Tools
Command Line ToolsDavid Harris
 
Shell_Scripting.ppt
Shell_Scripting.pptShell_Scripting.ppt
Shell_Scripting.pptKiranMantri
 
Using Unix
Using UnixUsing Unix
Using UnixDr.Ravi
 
Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013Wave Digitech
 
Module 3 Using Linux Softwares.
Module 3 Using Linux Softwares.Module 3 Using Linux Softwares.
Module 3 Using Linux Softwares.Tushar B Kute
 
Linux presentation
Linux presentationLinux presentation
Linux presentationNikhil Jain
 

Similar to Using the command line on macOS (20)

Linux basic for CADD biologist
Linux basic for CADD biologistLinux basic for CADD biologist
Linux basic for CADD biologist
 
Linux Basic Commands
Linux Basic CommandsLinux Basic Commands
Linux Basic Commands
 
8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unix
 
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformaticsBITS: Introduction to Linux - Text manipulation tools for bioinformatics
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
 
Directories description
Directories descriptionDirectories description
Directories description
 
Linux Presentation
Linux PresentationLinux Presentation
Linux Presentation
 
An Introduction to Linux
An Introduction to LinuxAn Introduction to Linux
An Introduction to Linux
 
Unix Basics For Testers
Unix Basics For TestersUnix Basics For Testers
Unix Basics For Testers
 
linux cmds.pptx
linux cmds.pptxlinux cmds.pptx
linux cmds.pptx
 
Examples -partII
Examples -partIIExamples -partII
Examples -partII
 
Command Line Tools
Command Line ToolsCommand Line Tools
Command Line Tools
 
50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unix
 
50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unix
 
Shell_Scripting.ppt
Shell_Scripting.pptShell_Scripting.ppt
Shell_Scripting.ppt
 
Using Unix
Using UnixUsing Unix
Using Unix
 
Linux shell scripting
Linux shell scriptingLinux shell scripting
Linux shell scripting
 
Linux
LinuxLinux
Linux
 
Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013
 
Module 3 Using Linux Softwares.
Module 3 Using Linux Softwares.Module 3 Using Linux Softwares.
Module 3 Using Linux Softwares.
 
Linux presentation
Linux presentationLinux presentation
Linux presentation
 

Recently uploaded

How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfFIDO Alliance
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...CzechDreamin
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty SecureFemke de Vroome
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka DoktorováCzechDreamin
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...FIDO Alliance
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessUXDXConf
 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Julian Hyde
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxJennifer Lim
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...FIDO Alliance
 
The UX of Automation by AJ King, Senior UX Researcher, Ocado
The UX of Automation by AJ King, Senior UX Researcher, OcadoThe UX of Automation by AJ King, Senior UX Researcher, Ocado
The UX of Automation by AJ King, Senior UX Researcher, OcadoUXDXConf
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceSamy Fodil
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutesconfluent
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FIDO Alliance
 
THE BEST IPTV in GERMANY for 2024: IPTVreel
THE BEST IPTV in  GERMANY for 2024: IPTVreelTHE BEST IPTV in  GERMANY for 2024: IPTVreel
THE BEST IPTV in GERMANY for 2024: IPTVreelreely ones
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeCzechDreamin
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyJohn Staveley
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfFIDO Alliance
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxDavid Michel
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?Mark Billinghurst
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftshyamraj55
 

Recently uploaded (20)

How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
The UX of Automation by AJ King, Senior UX Researcher, Ocado
The UX of Automation by AJ King, Senior UX Researcher, OcadoThe UX of Automation by AJ King, Senior UX Researcher, Ocado
The UX of Automation by AJ King, Senior UX Researcher, Ocado
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
 
THE BEST IPTV in GERMANY for 2024: IPTVreel
THE BEST IPTV in  GERMANY for 2024: IPTVreelTHE BEST IPTV in  GERMANY for 2024: IPTVreel
THE BEST IPTV in GERMANY for 2024: IPTVreel
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 

Using the command line on macOS

  • 2.
  • 3. What is a shell? Look, a shell! —> * Unix pioneered shells. * Shells are computer programs [Bash, ZSH, Fish, etc] * You can talk to your OS by issuing commands to the shell, in a command line interface / terminal. * You can change your default shell using chsh
  • 4. Which shell does macOS use? Did you just say GPL? * macOS used to use a very old version of bash, the most popular and well known shell. * Newest versions of Bash use GPL3 License. Shipping this with macOS would mean Apple would need to publish source code for their programs, which sounds like it would empower the user. * macOS now uses zsh
  • 5. So what programs can you run? Anything that is in PATH If you run echo $PATH you can see places where programs are loaded from for your current shell session . Traditionally: /usr/bi n Modern: /usr/local/bin (<— This is where home-brew puts its programs ) You can run apropos and a search term to find programs that match your term, i.e apropos text editing
  • 6. How to use a program Conventions help discovery ProgramName -f flagValue input ProgramName --flag flagValue input
  • 7. Unix + File Systems Everything is a fi le
  • 8.
  • 9. Files, Files & More Files Things you can do with fi les * ls <- List files * ls -la <- List files including hidden files (start with a .) * file my_file.txt <- Describe file * pwd <- Where am I in the filesystem? * cd aDirectory/ <- change directory to aDirectory * cd ~ <- change directory to home * rm aFile ~ <- Remove a file * rm -rf aDirectory/ ~ <- Remove a directory
  • 10. History Re-running commands * Press up on D-Pad to get last command * Ctrl + R <- search over history of previous commands . * sudo !! <- Rerun last command as Sudo
  • 11. Pipes Take output from one command, use it in another cat file.txt | grep “a string I think is in this file” cat file.txt | wc -l
  • 12. Copy & Paste pbcopy < file.txt pbpaste > file.txt pbpaste >> file.txt Overwrite Append
  • 13. Symlinks * ln ~/some_folder/some_file <- hard link a file * ln -s ~/some_folder/some_file <- soft link a file
  • 14. Backgrounding Processes * Ctrl+Z <- background current process. * fg <- re-focus process.
  • 15. De fi ne an alias Run alias to see all aliases currently load in the shell
  • 16. Profiles + Custom Configuration ~/.zshrc Change this, and source it (or restart your terminal)
  • 17. Cool stuff I use * fzf <- Fuzzy finder * oh-my-zsh <- Lots of additions to zsh + plugin support (I use git + fzf plugins) * jenv, pyenv, rvm, nvm <- Language managers * tmux <- Terminal multiplexer * rg <- Ripgrep, much faster that grep