SlideShare une entreprise Scribd logo
1  sur  43
Télécharger pour lire hors ligne
@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

Contenu connexe

Tendances

Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101hendrikvb
 
Writing Modular Command-line Apps with App::Cmd
Writing Modular Command-line Apps with App::CmdWriting Modular Command-line Apps with App::Cmd
Writing Modular Command-line Apps with App::CmdRicardo Signes
 
Simple php backdoor_by_dk
Simple php backdoor_by_dkSimple php backdoor_by_dk
Simple php backdoor_by_dkStan Adrian
 
Cis 216 – shell scripting
Cis 216 – shell scriptingCis 216 – shell scripting
Cis 216 – shell scriptingDan Morrill
 
Process monitoring in UNIX shell scripting
Process monitoring in UNIX shell scriptingProcess monitoring in UNIX shell scripting
Process monitoring in UNIX shell scriptingDan Morrill
 
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 lineJanos Gyerik
 
React PHP: the NodeJS challenger
React PHP: the NodeJS challengerReact PHP: the NodeJS challenger
React PHP: the NodeJS challengervanphp
 
The promise of asynchronous PHP
The promise of asynchronous PHPThe promise of asynchronous PHP
The promise of asynchronous PHPWim Godden
 
ZeroMQ Is The Answer
ZeroMQ Is The AnswerZeroMQ Is The Answer
ZeroMQ Is The AnswerIan Barber
 
Asynchronous I/O in PHP
Asynchronous I/O in PHPAsynchronous I/O in PHP
Asynchronous I/O in PHPThomas Weinert
 
Module 03 Programming on Linux
Module 03 Programming on LinuxModule 03 Programming on Linux
Module 03 Programming on LinuxTushar B Kute
 
Tempos modernos com fabric
Tempos modernos com fabricTempos modernos com fabric
Tempos modernos com fabricCarlos Maniero
 

Tendances (20)

Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101
 
Ruby 1.9
Ruby 1.9Ruby 1.9
Ruby 1.9
 
Writing Modular Command-line Apps with App::Cmd
Writing Modular Command-line Apps with App::CmdWriting Modular Command-line Apps with App::Cmd
Writing Modular Command-line Apps with App::Cmd
 
Simple php backdoor_by_dk
Simple php backdoor_by_dkSimple php backdoor_by_dk
Simple php backdoor_by_dk
 
Cis 216 – shell scripting
Cis 216 – shell scriptingCis 216 – shell scripting
Cis 216 – shell scripting
 
Bash Scripting Workshop
Bash Scripting WorkshopBash Scripting Workshop
Bash Scripting Workshop
 
Process monitoring in UNIX shell scripting
Process monitoring in UNIX shell scriptingProcess monitoring in UNIX shell scripting
Process monitoring in UNIX shell scripting
 
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
 
Bash Scripting
Bash ScriptingBash Scripting
Bash Scripting
 
clonehd01
clonehd01clonehd01
clonehd01
 
React PHP: the NodeJS challenger
React PHP: the NodeJS challengerReact PHP: the NodeJS challenger
React PHP: the NodeJS challenger
 
Tres Gemas De Ruby
Tres Gemas De RubyTres Gemas De Ruby
Tres Gemas De Ruby
 
The promise of asynchronous PHP
The promise of asynchronous PHPThe promise of asynchronous PHP
The promise of asynchronous PHP
 
Mojo as a_client
Mojo as a_clientMojo as a_client
Mojo as a_client
 
ZeroMQ Is The Answer
ZeroMQ Is The AnswerZeroMQ Is The Answer
ZeroMQ Is The Answer
 
Paexec -- distributed tasks over network or cpus
Paexec -- distributed tasks over network or cpusPaexec -- distributed tasks over network or cpus
Paexec -- distributed tasks over network or cpus
 
Asynchronous I/O in PHP
Asynchronous I/O in PHPAsynchronous I/O in PHP
Asynchronous I/O in PHP
 
Unix 5 en
Unix 5 enUnix 5 en
Unix 5 en
 
Module 03 Programming on Linux
Module 03 Programming on LinuxModule 03 Programming on Linux
Module 03 Programming on Linux
 
Tempos modernos com fabric
Tempos modernos com fabricTempos modernos com fabric
Tempos modernos com fabric
 

Similaire à Master SSH, files, processes and shortcuts

Really useful linux commands
Really useful linux commandsReally useful linux commands
Really useful linux commandsMichael J Geiser
 
A journey through the years of UNIX and Linux service management
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
 
NYPHP March 2009 Presentation
NYPHP March 2009 PresentationNYPHP March 2009 Presentation
NYPHP March 2009 Presentationbrian_dailey
 
Session Server - Maintaing State between several Servers
Session Server - Maintaing State between several ServersSession Server - Maintaing State between several Servers
Session Server - Maintaing State between several ServersStephan Schmidt
 
Introduction to WP-CLI: Manage WordPress from the command line
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
 
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...
How we used ruby to build locaweb's cloud (http://presentations.pothix.com/ru...Willian Molinari
 
Ultimate Unix Meetup Presentation
Ultimate Unix Meetup PresentationUltimate Unix Meetup Presentation
Ultimate Unix Meetup PresentationJacobMenke1
 
Capital onehadoopclass
Capital onehadoopclassCapital onehadoopclass
Capital onehadoopclassDoug Chang
 

Similaire à Master SSH, files, processes and shortcuts (20)

Really useful linux commands
Really useful linux commandsReally useful linux commands
Really useful linux commands
 
A journey through the years of UNIX and Linux service management
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
 
NYPHP March 2009 Presentation
NYPHP March 2009 PresentationNYPHP March 2009 Presentation
NYPHP March 2009 Presentation
 
Puppet @ Seat
Puppet @ SeatPuppet @ Seat
Puppet @ Seat
 
Session Server - Maintaing State between several Servers
Session Server - Maintaing State between several ServersSession Server - Maintaing State between several Servers
Session Server - Maintaing State between several Servers
 
Introduction to WP-CLI: Manage WordPress from the command line
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
 
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...
How we used ruby to build locaweb's cloud (http://presentations.pothix.com/ru...
 
lec4.docx
lec4.docxlec4.docx
lec4.docx
 
Ssh cookbook v2
Ssh cookbook v2Ssh cookbook v2
Ssh cookbook v2
 
Ssh cookbook
Ssh cookbookSsh cookbook
Ssh cookbook
 
EC2
EC2EC2
EC2
 
My sql administration
My sql administrationMy sql administration
My sql administration
 
Linuxserver harden
Linuxserver hardenLinuxserver harden
Linuxserver harden
 
Ubic
UbicUbic
Ubic
 
Ubic-public
Ubic-publicUbic-public
Ubic-public
 
Ultimate Unix Meetup Presentation
Ultimate Unix Meetup PresentationUltimate Unix Meetup Presentation
Ultimate Unix Meetup Presentation
 
screen and tmux
screen and tmuxscreen and tmux
screen and tmux
 
Dtalk shell
Dtalk shellDtalk shell
Dtalk shell
 
FreeBSD: Dev to Prod
FreeBSD: Dev to ProdFreeBSD: Dev to Prod
FreeBSD: Dev to Prod
 
Capital onehadoopclass
Capital onehadoopclassCapital onehadoopclass
Capital onehadoopclass
 

Dernier

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
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 AutomationSafe Software
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 

Dernier (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

Master SSH, files, processes and shortcuts

  • 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