Using the Command Line with Magento

@ma$hewhaworth
SSH@ma$hewhaworth
Make use of SSH
config
@ma$hewhaworth
SSH Config file
# ~/.ssh/config
Host myclient-dev
HostName dev.example.com
Port 2020
User myclientu
IdentityFile ~/.ssh/id_rsa
@ma$hewhaworth
SSH Config file
# ~/.ssh/config
Host myclient-dev
HostName dev.example.com
Port 2020
User myclientu
IdentityFile ~/.ssh/id_rsa
$ ssh myclient-dev
@ma$hewhaworth
Use screen
@ma$hewhaworth
screen
Start terminal sessions that you can
disconnect from and resume at any
3me.
@ma$hewhaworth
Screen Cheatsheet
# Create and name a new screen session
$ screen -S <name>
# Detach from screen (but keep it alive)
$ Ctrl+a d
# Resume a named session
$ screen -r <name>
# List active sessions
$ screen -ls
# Catch all (use existing, or create new)
$ screen -dRR
@ma$hewhaworth
Escape a dead
SSH connec-on
@ma$hewhaworth
Enter ~ .
Kills a dead SSH session and lets you
keep your terminal
@ma$hewhaworth
Files@ma$hewhaworth
Tricks to ge,ng
around
@ma$hewhaworth
This makes me want to kill you
$ cd app
$ cd code
$ cd MyVendor
$ cd MyModule
$ cd etc
$ cd ../../..
$ cd ..
$ cd ..
@ma$hewhaworth
This is much nicer
$ cd app/code/MyVendor/MyModule/etc
$ cd -
@ma$hewhaworth
Using tar for archiving and compression
@ma$hewhaworth
Tar
tar czf myarchive.tar.gz <files>
c - Create new archive
z - Zip
f - Filename
@ma$hewhaworth
@ma$hewhaworth
T-arghh!
$ tar czf magento_backup.tar.gz <files>
c - Create
z - Ze
f - Files
@ma$hewhaworth
T-arghh!
$ tar czf magento_backup.tar.gz <files>
c - Create
z - Ze
f - Files
$ tar xzf magento_backup.tar.gz
x - eXtract
z - Ze
f - Files
@ma$hewhaworth
A bit more on tar
# Extract to specific directory
$ tar xf magento_ce.tar.gz -C myDirectory
# Only extract a particular file
$ tar xf magento_ce.tar.gz magento
@ma$hewhaworth
mkdir magic
@ma$hewhaworth
mkdir magic
-p allows you to create children and parents at the
same 4me
# Verbose
$ mkdir app && mkdir app/code && mkdir app/code/MyModule
# Better
$ mkdir -p app/code/MyModule
@ma$hewhaworth
mkdir magic
Using {} allows you to create mul4ple directories at
once
$ mkdir -p app/code/MHCommerce/{ShippingMethods,Checkout}/{Block,Model,etc}
└── app
└── code
└── MHCommerce
├── Checkout
│   ├── Block
│   ├── Model
│   └── etc
└── ShippingMethods
├── Block
├── Model
└── etc
@ma$hewhaworth
tree
$ brew install tree
$ tree
└── app
└── code
└── MHCommerce
├── Checkout
│   ├── Block
│   ├── Model
│   └── etc
└── ShippingMethods
├── Block
├── Model
└── etc
@ma$hewhaworth
Keeping an eye on files
@ma$hewhaworth
less and Shift + F
Browse file and s-ck to the bo3om
$ less var/log/system.log
[Shift + F]
@ma$hewhaworth
tail -f
Print end of file to standard out
# Prints last ten lines to standard out
$ tail var/log/system.log
# Prints the end of the file continuously
$ tail -f var/log/system.log
# Print last x lines
$ tail -f -n20 var/log/system.log
@ma$hewhaworth
watch
Con$nuously execute a command
$ brew install watch
$ watch -n[update_interval] "[command]"
$ watch -n1 "cat var/log/system.log"
$ watch -n0.1 "ls -lsah"
@ma$hewhaworth
Other useful file based commands
- grep - Filter lines in a file
- sed - Find and replace on a file
- awk - More complex text manipulation
@ma$hewhaworth
Processes
@ma$hewhaworth
Keeping processes
quiet
@ma$hewhaworth
Background Processes with &
$ tar czf backup.tar.gz magento &
[1] 13281
$ jobs
[1] + running tar czf backup.tar.gz magento
# some time later ...
[1] + 13281 done tar czf backup.tar.gz magento
@ma$hewhaworth
Hal$ng Processes
$ tar czf backup.tar.gz magento
[Ctrl + z]
[1] + 13552 suspended tar czf backup.tar.gz magento
$ bg
[1] + 13552 continued tar czf backup.tar.gz magento
$ jobs
[1] + running tar czf backup.tar.gz magento
$ fg
[1] + 13613 running tar czf backup.tar.gz magento
@ma$hewhaworth
Hal$ng SSH
SSH is just another process, it can be halted and
resumed in the same way
$ ssh my-client-staging
my-client-staging $
Enter + ~ then [Ctrl + z]
[1] + 13702 suspended ssh my-client-staging
$ fg
[1] + 13702 continued ssh my-client-staging
my-client-staging $ ls #...
@ma$hewhaworth
Pipe viewer
View the progress of pipe'd input
$ brew install pv
$ pv db.sql | mysql -uroot my_client_db
178MiB 0:00:38 [17.9MiB/s] [==========> ] 60% ETA 0:00:28
@ma$hewhaworth
Other useful process based commands
- top - See a process list
- htop - See a colourful and more interactive process list
- ps - Print out processes to std out, use `ps aux`
- kill - Kill a process by id
- killall - Kill all processes with a certain name
@ma$hewhaworth
Shortcuts
@ma$hewhaworth
Forgot sudo? Lazy?
$ service mysql restart
Permission denied
$ sudo !!
MySQL restarted
# equivalent to...
$ sudo service mysql restart
MySQL restarted
@ma$hewhaworth
Already wri+en a file path once? Lazy?
$ ls -lash app/etc/env.php
$ vim !$
# equivalent to...
$ vim app/etc/env.php
@ma$hewhaworth
Want to pull in a command from history?
$ history
...
1028 ls -lash
1029 vim app/etc/local.xml
1030 rm app/etc/local.xml
# Re-run command 1028
$ !1028
OR
[Ctrl + r] allows you to search through previous commands
@ma$hewhaworth
Wri$en a command that's star1ng to
get too long?
[Ctrl + x] [Ctrl + e]
This will open a text editor containing the command
you currently have wri7en on the command line
@ma$hewhaworth
Further Reading
Mac users
---------
- https://brew.sh/ - Homebrew
- https://github.com/robbyrussell/oh-my-zsh
All Unix
--------
- http://www.commandlinefu.com/
- https://github.com/learnbyexample/
@ma$hewhaworth
Thank you!
Specifically those who suffered my prac5ce runs...
Sam Beckingham-Cook: @SamboBeckingham
Lee Frankland: @leefrankland
Lissie Cox: @LissieCox
Phil Turner: @FlipTurner
Vinai Kopp: @VinaiKopp
@ma$hewhaworth
1 of 43

Recommended

Vim Hacks (OSSF) by
Vim Hacks (OSSF)Vim Hacks (OSSF)
Vim Hacks (OSSF)Lin Yo-An
2.2K views45 slides
我在 Mac 上的常用开发工具 by
我在 Mac 上的常用开发工具我在 Mac 上的常用开发工具
我在 Mac 上的常用开发工具dennis zhuang
732 views13 slides
serverstats by
serverstatsserverstats
serverstatsBen De Koster
246 views4 slides
Asynchronous PHP and Real-time Messaging by
Asynchronous PHP and Real-time MessagingAsynchronous PHP and Real-time Messaging
Asynchronous PHP and Real-time MessagingSteve Rhoades
19.2K views45 slides
App-o-Lockalypse now! by
App-o-Lockalypse now!App-o-Lockalypse now!
App-o-Lockalypse now!Oddvar Moe
811 views58 slides
Puppet Camp 2012 by
Puppet Camp 2012Puppet Camp 2012
Puppet Camp 2012Server Density
843 views20 slides

More Related Content

What's hot

Web Apps in Perl - HTTP 101 by
Web Apps in Perl - HTTP 101Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101hendrikvb
2.9K views29 slides
Ruby 1.9 by
Ruby 1.9Ruby 1.9
Ruby 1.9guestaef7ea
914 views32 slides
Writing Modular Command-line Apps with App::Cmd by
Writing Modular Command-line Apps with App::CmdWriting Modular Command-line Apps with App::Cmd
Writing Modular Command-line Apps with App::CmdRicardo Signes
6.7K views155 slides
Simple php backdoor_by_dk by
Simple php backdoor_by_dkSimple php backdoor_by_dk
Simple php backdoor_by_dkStan Adrian
797 views1 slide
Cis 216 – shell scripting by
Cis 216 – shell scriptingCis 216 – shell scripting
Cis 216 – shell scriptingDan Morrill
500 views12 slides
Bash Scripting Workshop by
Bash Scripting WorkshopBash Scripting Workshop
Bash Scripting WorkshopAhmed Magdy Ezzeldin, MSc.
2K views16 slides

What's hot(20)

Web Apps in Perl - HTTP 101 by hendrikvb
Web Apps in Perl - HTTP 101Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101
hendrikvb2.9K views
Writing Modular Command-line Apps with App::Cmd by Ricardo Signes
Writing Modular Command-line Apps with App::CmdWriting Modular Command-line Apps with App::Cmd
Writing Modular Command-line Apps with App::Cmd
Ricardo Signes6.7K views
Simple php backdoor_by_dk by Stan Adrian
Simple php backdoor_by_dkSimple php backdoor_by_dk
Simple php backdoor_by_dk
Stan Adrian797 views
Cis 216 – shell scripting by Dan Morrill
Cis 216 – shell scriptingCis 216 – shell scripting
Cis 216 – shell scripting
Dan Morrill500 views
Process monitoring in UNIX shell scripting by Dan Morrill
Process monitoring in UNIX shell scriptingProcess monitoring in UNIX shell scripting
Process monitoring in UNIX shell scripting
Dan Morrill5.3K views
Simple tricks to speed you up on the command line by Janos Gyerik
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
Janos Gyerik327 views
React PHP: the NodeJS challenger by vanphp
React PHP: the NodeJS challengerReact PHP: the NodeJS challenger
React PHP: the NodeJS challenger
vanphp6.7K views
The promise of asynchronous PHP by Wim Godden
The promise of asynchronous PHPThe promise of asynchronous PHP
The promise of asynchronous PHP
Wim Godden16.4K views
ZeroMQ Is The Answer by Ian Barber
ZeroMQ Is The AnswerZeroMQ Is The Answer
ZeroMQ Is The Answer
Ian Barber114K views
Module 03 Programming on Linux by Tushar B Kute
Module 03 Programming on LinuxModule 03 Programming on Linux
Module 03 Programming on Linux
Tushar B Kute1.1K views

Similar to Using the Command Line with Magento

Really useful linux commands by
Really useful linux commandsReally useful linux commands
Really useful linux commandsMichael J Geiser
1.6K views26 slides
A journey through the years of UNIX and Linux service management by
A journey through the years of UNIX and Linux service managementA journey through the years of UNIX and Linux service management
A journey through the years of UNIX and Linux service managementLubomir Rintel
1.3K views23 slides
NYPHP March 2009 Presentation by
NYPHP March 2009 PresentationNYPHP March 2009 Presentation
NYPHP March 2009 Presentationbrian_dailey
906 views48 slides
Puppet @ Seat by
Puppet @ SeatPuppet @ Seat
Puppet @ SeatAlessandro Franceschi
5.9K views45 slides
Session Server - Maintaing State between several Servers by
Session Server - Maintaing State between several ServersSession Server - Maintaing State between several Servers
Session Server - Maintaing State between several ServersStephan Schmidt
1.8K views34 slides
Introduction to WP-CLI: Manage WordPress from the command line by
Introduction to WP-CLI: Manage WordPress from the command lineIntroduction to WP-CLI: Manage WordPress from the command line
Introduction to WP-CLI: Manage WordPress from the command lineBehzod Saidov
102 views30 slides

Similar to Using the Command Line with Magento(20)

A journey through the years of UNIX and Linux service management by Lubomir Rintel
A journey through the years of UNIX and Linux service managementA journey through the years of UNIX and Linux service management
A journey through the years of UNIX and Linux service management
Lubomir Rintel1.3K views
NYPHP March 2009 Presentation by brian_dailey
NYPHP March 2009 PresentationNYPHP March 2009 Presentation
NYPHP March 2009 Presentation
brian_dailey906 views
Session Server - Maintaing State between several Servers by Stephan Schmidt
Session Server - Maintaing State between several ServersSession Server - Maintaing State between several Servers
Session Server - Maintaing State between several Servers
Stephan Schmidt1.8K views
Introduction to WP-CLI: Manage WordPress from the command line by Behzod Saidov
Introduction to WP-CLI: Manage WordPress from the command lineIntroduction to WP-CLI: Manage WordPress from the command line
Introduction to WP-CLI: Manage WordPress from the command line
Behzod Saidov102 views
How we used ruby to build locaweb's cloud (http://presentations.pothix.com/ru... by Willian Molinari
How we used ruby to build locaweb's cloud (http://presentations.pothix.com/ru...How we used ruby to build locaweb's cloud (http://presentations.pothix.com/ru...
How we used ruby to build locaweb's cloud (http://presentations.pothix.com/ru...
Willian Molinari789 views
Ultimate Unix Meetup Presentation by JacobMenke1
Ultimate Unix Meetup PresentationUltimate Unix Meetup Presentation
Ultimate Unix Meetup Presentation
JacobMenke11.8K views
Capital onehadoopclass by Doug Chang
Capital onehadoopclassCapital onehadoopclass
Capital onehadoopclass
Doug Chang388 views

Recently uploaded

The Power of Heat Decarbonisation Plans in the Built Environment by
The Power of Heat Decarbonisation Plans in the Built EnvironmentThe Power of Heat Decarbonisation Plans in the Built Environment
The Power of Heat Decarbonisation Plans in the Built EnvironmentIES VE
69 views20 slides
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue by
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlueCloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlueShapeBlue
93 views15 slides
Future of AR - Facebook Presentation by
Future of AR - Facebook PresentationFuture of AR - Facebook Presentation
Future of AR - Facebook PresentationRob McCarty
62 views27 slides
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ... by
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...ShapeBlue
144 views12 slides
Business Analyst Series 2023 - Week 4 Session 8 by
Business Analyst Series 2023 -  Week 4 Session 8Business Analyst Series 2023 -  Week 4 Session 8
Business Analyst Series 2023 - Week 4 Session 8DianaGray10
86 views13 slides
Business Analyst Series 2023 - Week 4 Session 7 by
Business Analyst Series 2023 -  Week 4 Session 7Business Analyst Series 2023 -  Week 4 Session 7
Business Analyst Series 2023 - Week 4 Session 7DianaGray10
126 views31 slides

Recently uploaded(20)

The Power of Heat Decarbonisation Plans in the Built Environment by IES VE
The Power of Heat Decarbonisation Plans in the Built EnvironmentThe Power of Heat Decarbonisation Plans in the Built Environment
The Power of Heat Decarbonisation Plans in the Built Environment
IES VE69 views
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue by ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlueCloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
ShapeBlue93 views
Future of AR - Facebook Presentation by Rob McCarty
Future of AR - Facebook PresentationFuture of AR - Facebook Presentation
Future of AR - Facebook Presentation
Rob McCarty62 views
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ... by ShapeBlue
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
ShapeBlue144 views
Business Analyst Series 2023 - Week 4 Session 8 by DianaGray10
Business Analyst Series 2023 -  Week 4 Session 8Business Analyst Series 2023 -  Week 4 Session 8
Business Analyst Series 2023 - Week 4 Session 8
DianaGray1086 views
Business Analyst Series 2023 - Week 4 Session 7 by DianaGray10
Business Analyst Series 2023 -  Week 4 Session 7Business Analyst Series 2023 -  Week 4 Session 7
Business Analyst Series 2023 - Week 4 Session 7
DianaGray10126 views
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ... by ShapeBlue
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
ShapeBlue123 views
Confidence in CloudStack - Aron Wagner, Nathan Gleason - Americ by ShapeBlue
Confidence in CloudStack - Aron Wagner, Nathan Gleason - AmericConfidence in CloudStack - Aron Wagner, Nathan Gleason - Americ
Confidence in CloudStack - Aron Wagner, Nathan Gleason - Americ
ShapeBlue88 views
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T by ShapeBlue
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&TCloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
ShapeBlue112 views
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ... by ShapeBlue
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
ShapeBlue79 views
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ... by ShapeBlue
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...
ShapeBlue146 views
"Surviving highload with Node.js", Andrii Shumada by Fwdays
"Surviving highload with Node.js", Andrii Shumada "Surviving highload with Node.js", Andrii Shumada
"Surviving highload with Node.js", Andrii Shumada
Fwdays53 views
Keynote Talk: Open Source is Not Dead - Charles Schulz - Vates by ShapeBlue
Keynote Talk: Open Source is Not Dead - Charles Schulz - VatesKeynote Talk: Open Source is Not Dead - Charles Schulz - Vates
Keynote Talk: Open Source is Not Dead - Charles Schulz - Vates
ShapeBlue210 views
Digital Personal Data Protection (DPDP) Practical Approach For CISOs by Priyanka Aash
Digital Personal Data Protection (DPDP) Practical Approach For CISOsDigital Personal Data Protection (DPDP) Practical Approach For CISOs
Digital Personal Data Protection (DPDP) Practical Approach For CISOs
Priyanka Aash153 views
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R... by ShapeBlue
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
ShapeBlue132 views
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava... by ShapeBlue
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
ShapeBlue101 views
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ... by ShapeBlue
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...
ShapeBlue85 views

Using the Command Line with Magento

  • 3. Make use of SSH config @ma$hewhaworth
  • 4. SSH Config file # ~/.ssh/config Host myclient-dev HostName dev.example.com Port 2020 User myclientu IdentityFile ~/.ssh/id_rsa @ma$hewhaworth
  • 5. SSH Config file # ~/.ssh/config Host myclient-dev HostName dev.example.com Port 2020 User myclientu IdentityFile ~/.ssh/id_rsa $ ssh myclient-dev @ma$hewhaworth
  • 7. screen Start terminal sessions that you can disconnect from and resume at any 3me. @ma$hewhaworth
  • 8. Screen Cheatsheet # Create and name a new screen session $ screen -S <name> # Detach from screen (but keep it alive) $ Ctrl+a d # Resume a named session $ screen -r <name> # List active sessions $ screen -ls # Catch all (use existing, or create new) $ screen -dRR @ma$hewhaworth
  • 9. Escape a dead SSH connec-on @ma$hewhaworth
  • 10. Enter ~ . Kills a dead SSH session and lets you keep your terminal @ma$hewhaworth
  • 13. This makes me want to kill you $ cd app $ cd code $ cd MyVendor $ cd MyModule $ cd etc $ cd ../../.. $ cd .. $ cd .. @ma$hewhaworth
  • 14. This is much nicer $ cd app/code/MyVendor/MyModule/etc $ cd - @ma$hewhaworth
  • 15. Using tar for archiving and compression @ma$hewhaworth
  • 16. Tar tar czf myarchive.tar.gz <files> c - Create new archive z - Zip f - Filename @ma$hewhaworth
  • 18. T-arghh! $ tar czf magento_backup.tar.gz <files> c - Create z - Ze f - Files @ma$hewhaworth
  • 19. T-arghh! $ tar czf magento_backup.tar.gz <files> c - Create z - Ze f - Files $ tar xzf magento_backup.tar.gz x - eXtract z - Ze f - Files @ma$hewhaworth
  • 20. A bit more on tar # Extract to specific directory $ tar xf magento_ce.tar.gz -C myDirectory # Only extract a particular file $ tar xf magento_ce.tar.gz magento @ma$hewhaworth
  • 22. mkdir magic -p allows you to create children and parents at the same 4me # Verbose $ mkdir app && mkdir app/code && mkdir app/code/MyModule # Better $ mkdir -p app/code/MyModule @ma$hewhaworth
  • 23. mkdir magic Using {} allows you to create mul4ple directories at once $ mkdir -p app/code/MHCommerce/{ShippingMethods,Checkout}/{Block,Model,etc} └── app └── code └── MHCommerce ├── Checkout │   ├── Block │   ├── Model │   └── etc └── ShippingMethods ├── Block ├── Model └── etc @ma$hewhaworth
  • 24. tree $ brew install tree $ tree └── app └── code └── MHCommerce ├── Checkout │   ├── Block │   ├── Model │   └── etc └── ShippingMethods ├── Block ├── Model └── etc @ma$hewhaworth
  • 25. Keeping an eye on files @ma$hewhaworth
  • 26. less and Shift + F Browse file and s-ck to the bo3om $ less var/log/system.log [Shift + F] @ma$hewhaworth
  • 27. tail -f Print end of file to standard out # Prints last ten lines to standard out $ tail var/log/system.log # Prints the end of the file continuously $ tail -f var/log/system.log # Print last x lines $ tail -f -n20 var/log/system.log @ma$hewhaworth
  • 28. watch Con$nuously execute a command $ brew install watch $ watch -n[update_interval] "[command]" $ watch -n1 "cat var/log/system.log" $ watch -n0.1 "ls -lsah" @ma$hewhaworth
  • 29. Other useful file based commands - grep - Filter lines in a file - sed - Find and replace on a file - awk - More complex text manipulation @ma$hewhaworth
  • 32. Background Processes with & $ tar czf backup.tar.gz magento & [1] 13281 $ jobs [1] + running tar czf backup.tar.gz magento # some time later ... [1] + 13281 done tar czf backup.tar.gz magento @ma$hewhaworth
  • 33. Hal$ng Processes $ tar czf backup.tar.gz magento [Ctrl + z] [1] + 13552 suspended tar czf backup.tar.gz magento $ bg [1] + 13552 continued tar czf backup.tar.gz magento $ jobs [1] + running tar czf backup.tar.gz magento $ fg [1] + 13613 running tar czf backup.tar.gz magento @ma$hewhaworth
  • 34. Hal$ng SSH SSH is just another process, it can be halted and resumed in the same way $ ssh my-client-staging my-client-staging $ Enter + ~ then [Ctrl + z] [1] + 13702 suspended ssh my-client-staging $ fg [1] + 13702 continued ssh my-client-staging my-client-staging $ ls #... @ma$hewhaworth
  • 35. Pipe viewer View the progress of pipe'd input $ brew install pv $ pv db.sql | mysql -uroot my_client_db 178MiB 0:00:38 [17.9MiB/s] [==========> ] 60% ETA 0:00:28 @ma$hewhaworth
  • 36. Other useful process based commands - top - See a process list - htop - See a colourful and more interactive process list - ps - Print out processes to std out, use `ps aux` - kill - Kill a process by id - killall - Kill all processes with a certain name @ma$hewhaworth
  • 38. Forgot sudo? Lazy? $ service mysql restart Permission denied $ sudo !! MySQL restarted # equivalent to... $ sudo service mysql restart MySQL restarted @ma$hewhaworth
  • 39. Already wri+en a file path once? Lazy? $ ls -lash app/etc/env.php $ vim !$ # equivalent to... $ vim app/etc/env.php @ma$hewhaworth
  • 40. Want to pull in a command from history? $ history ... 1028 ls -lash 1029 vim app/etc/local.xml 1030 rm app/etc/local.xml # Re-run command 1028 $ !1028 OR [Ctrl + r] allows you to search through previous commands @ma$hewhaworth
  • 41. Wri$en a command that's star1ng to get too long? [Ctrl + x] [Ctrl + e] This will open a text editor containing the command you currently have wri7en on the command line @ma$hewhaworth
  • 42. Further Reading Mac users --------- - https://brew.sh/ - Homebrew - https://github.com/robbyrussell/oh-my-zsh All Unix -------- - http://www.commandlinefu.com/ - https://github.com/learnbyexample/ @ma$hewhaworth
  • 43. Thank you! Specifically those who suffered my prac5ce runs... Sam Beckingham-Cook: @SamboBeckingham Lee Frankland: @leefrankland Lissie Cox: @LissieCox Phil Turner: @FlipTurner Vinai Kopp: @VinaiKopp @ma$hewhaworth