SlideShare a Scribd company logo
1 of 46
Download to read offline
L ve the Terminal
  Because life is better when you can
     work on the command line

               Mike West
   Yahoo! Frontend Summit, Dec. 2007
                  Slides:
   http://mikewest.org/file_download/12
The command line is complex, and
 quite impossible to cover fully.

So let’s begin by limiting our scope.
What’s the good stuff?
Foundations
Unix-style systems all behave according to
similar rules; understanding those
underlying ideas and processes is critical.
Connectivity
My computer is a paperweight without a
network; I need to get secure access to
many remote machines, and do things there.
Scripting
Don’t type the same things over and over;
save your sanity with just a little
understanding of Bash aliases and functions.
Foundations




http://flickr.com/photos/johnseb/458716114/
Foundations



      Unix-style systems are built
   primarily on small, single-purpose
      utilities that can be chained
       together for larger effect.



http://flickr.com/photos/johnseb/458716114/
Foundations




Each of these tools operates in one
   way or another on streams.




http://flickr.com/photos/johnseb/458716114/
Foundations



                                             STDOUT


                $> ls
                file-1.txt                      file-2.txt
                $>




http://flickr.com/photos/johnseb/458716114/
Foundations



                                             STDIN

                $> perl
                $x = “Hello, world!”;
                print quot;n$xnquot;;
                ^D
                Hello, world!
                $>




http://flickr.com/photos/johnseb/458716114/
Foundations



                                             STDERROR


                $> perl
                $x = 1/0; print quot;n$xnquot;;
                Illegal division by zero at - line 1.
                $>




http://flickr.com/photos/johnseb/458716114/
Foundations




                               Stream Redirection




http://flickr.com/photos/johnseb/458716114/
Foundations



                           Input Redirection: `<`


            mikewest:~/some_dir westm$ validator < ./tmp.html

            mikewest:~/some_dir westm$




http://flickr.com/photos/johnseb/458716114/
Foundations



   Output Redirection: `>` and `>>`


                mikewest:~/some_dir westm$ ls > ./tmp

                mikewest:~/some_dir westm$




http://flickr.com/photos/johnseb/458716114/
Foundations



                        Error Redirection: `2>`


   mikewest:~/some_dir westm$ errorful 2> ./dev/null

   mikewest:~/some_dir westm$ errorful > ./dev/null 2>&1

   mikewest:~/some_dir westm$



http://flickr.com/photos/johnseb/458716114/
Foundations




                                    Chaining Streams




http://flickr.com/photos/johnseb/458716114/
Foundations



Small Utilities, Working Together: `|`

$> ls -la | sort -r -k                       5 | head -3
-rw-r--r--    1 westm                        westm 34749 Oct 19 12:11
    SiteAssistant.js
-rw-r--r--    1 westm                        westm   12292 Oct 18 22:51 .DS_Store
-rw-r--r--    1 westm                        westm    8161 Oct 19 11:35
    SiteAssistant.css

Lists the 3 (`head`) largest (`sort`) files in the current directory (`ls`)



http://flickr.com/photos/johnseb/458716114/
Foundations




                               Permissions System




http://flickr.com/photos/johnseb/458716114/
Foundations



Each file has an “owner”, a “group”,
 as well as 3 sets of execute, read,
    and write permission bits.



http://flickr.com/photos/johnseb/458716114/
Foundations

$> ls -lah
-rw-r--r--     1 westm                       westm   2K Aug   2   2001 xmalloc.c
$> chmod 777 xmalloc.c
$> ls -lah
-rwxrwxrwx     1 westm                       westm   2K Aug   2   2001 xmalloc.c


1   --x     execute
2   -w-     write
3   -wx     write and execute
4   r--     read
5   r-x     read and execute
6   rw-     read and write
7   rwx     read, write and execute




http://flickr.com/photos/johnseb/458716114/
Foundations




                                     Process Control




http://flickr.com/photos/johnseb/458716114/
Foundations


      You can start processes in the
       background with `&`, pause
     processes with Crtl-Z, and deal
     with paused processes using `fg`
                and `bg`.


http://flickr.com/photos/johnseb/458716114/
Foundations




                   Demo go herquot;




http://flickr.com/photos/johnseb/458716114/
Foundations




                                             Editing Files




http://flickr.com/photos/johnseb/458716114/
Foundations




           Avoid holy wars; just use VIM.




http://flickr.com/photos/johnseb/458716114/
Foundations




                   Demo go herquot;




http://flickr.com/photos/johnseb/458716114/
Connectivity




http://www.flickr.com/photos/hi-phi/36854889/
Connectivity




 Whatever your connectivity needs,
 SSH is almost certainly the answer.




http://www.flickr.com/photos/hi-phi/36854889/
Connectivity


                       Passwords are annoying



                       L
   mikewest:~ westm$ ssh mikewest@mikewest.org




                     I
   Password:
   Last login: Thu Nov 29 11:45:59 2007 from 193.93.196.161
               _____________________________________




                   A
     ________|                                       |_________
             |           girard.joyent.us           |           /
             |                                      |         /




                  F
             |    quot;Mrs. Robinson, you're trying     |       /
             |      to seduce me. Aren't you?quot;      |     /
         /    |_____________________________________|      
       /___________)                            (___________

   [girard:~] mikewest$


http://www.flickr.com/photos/hi-phi/36854889/
Connectivity




                   SSH Keys are much better




http://www.flickr.com/photos/hi-phi/36854889/
Connectivity




     SSH Keys are much friendlier and
       are trivial to create and use.




http://www.flickr.com/photos/hi-phi/36854889/
Connectivity



                             Just run `ssh-keygen`
  mikewest:~ westm$ ssh-keygen -t rsa -b 2048
  Generating public/private rsa key pair.
  Enter file in which to save the key (/Users/westm/.ssh/
      id_rsa): /Users/westm/.ssh/test_rsa
  Enter passphrase (empty for no passphrase):
  Enter same passphrase again:
  Your identification has been saved in /Users/westm/.ssh/
      test_rsa.
  Your public key has been saved in /Users/westm/.ssh/
      test_rsa.pub.
  The key fingerprint is:
  8f:0b:e7:ea:17:61:69:6a:11:06:f5:56:ac:70:c4:69
      westm@mikewest.munich.corp.yahoo.com
http://www.flickr.com/photos/hi-phi/36854889/
Connectivity

Upload to the server, and append to
      ~/.ssh/authorized_keys


  mikewest:~ westm$ scp /Users/westm/.ssh/test_rsa.pub 
  mikewest@mikewest.org:~/.ssh/authorized_keys




http://www.flickr.com/photos/hi-phi/36854889/
Connectivity



                   Of course, you will create
                   passphrased keys, because
                     anything else is idiocy.



http://www.flickr.com/photos/hi-phi/36854889/
Connectivity




                                               SSH Agent




http://www.flickr.com/photos/hi-phi/36854889/
Connectivity


                                    SSH Agent is Easy


  mikewest:~ westm$ eval `ssh-agent`
  Agent pid 80094
  mikewest:~ westm$ ssh-add
  Enter passphrase for /Users/westm/.ssh/id_rsa:
  Identity added: /Users/westm/.ssh/id_rsa (/Users/
      westm/.ssh/id_rsa)
  mikewest:~ westm$




http://www.flickr.com/photos/hi-phi/36854889/
Connectivity




                               SSH Agent + Screen




http://www.flickr.com/photos/hi-phi/36854889/
Connectivity




                    Demo go herquot;




http://www.flickr.com/photos/hi-phi/36854889/
Scripting




http://www.flickr.com/photos/mortimer/221051561/
 http://www.flickr.com/photos/hi-phi/36854889/
Scripting



    Elimination of mindless repetition
    from your daily life is essential to
          your continued sanity.



http://www.flickr.com/photos/mortimer/221051561/
 http://www.flickr.com/photos/hi-phi/36854889/
Scripting


     Uploading SSH Keys, for instance.
   #!/bin/bash

   KEY=quot;$HOME/.ssh/id_rsa.pubquot;

   if [ -z $1 ];then
       echo quot;Usage: `upload_keys username@host`quot;
   else
       echo quot;Putting your key on $1... quot;
       ssh -q $1 - HEREDOC
           umask 0077;
           mkdir -p ~/.ssh;
           echo quot;`cat $KEY`quot;  ~/.ssh/authorized_keys
           echo quot;done!quot;
   HEREDOC
   fi
http://www.flickr.com/photos/mortimer/221051561/
 http://www.flickr.com/photos/hi-phi/36854889/
Scripting


                                                  Aliases


    mikewest:~ westm$ ll
    -/bin/bash: ll: command not found
    mikewest:~ westm$ alias ll=’ls -lah’
    mikewest:~ westm$ ll
     magically insert result of `ls -lah` here 
    mikewest:~ westm$




http://www.flickr.com/photos/mortimer/221051561/
 http://www.flickr.com/photos/hi-phi/36854889/
Scripting


                                                  Functions

    mikewest:~ westm$ httpload() {
        echo quot;http://$1quot;  /var/tmp/$1.http_load_temp_file
        http_load -parallel $2 -seconds $3 /var/tmp/
    $1.http_load_temp_file
        rm -f /var/tmp/$1.http_load_temp_file
    }
    mikewest:~ westm$ httpload mikewest.org 1000 1000000
     magically insert my crashing, burning website here 
    mikewest:~ westm$


http://www.flickr.com/photos/mortimer/221051561/
 http://www.flickr.com/photos/hi-phi/36854889/
Scripting



      You can put frequently used
        functions or aliases into
   `~/.bash_login` so they’re available
              immediately.



http://www.flickr.com/photos/mortimer/221051561/
 http://www.flickr.com/photos/hi-phi/36854889/
Questions?
      Mike West
 mike@mikewest.org
 http://mikewest.org/

More Related Content

What's hot

ChefConf 2012 Spiceweasel
ChefConf 2012 SpiceweaselChefConf 2012 Spiceweasel
ChefConf 2012 SpiceweaselMatt Ray
 
Taking the pain out of signing users in
Taking the pain out of signing users inTaking the pain out of signing users in
Taking the pain out of signing users inFrancois Marier
 
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜Retrieva inc.
 
Apache Tomcat Shutdown Startup Script Shell
Apache Tomcat Shutdown Startup Script ShellApache Tomcat Shutdown Startup Script Shell
Apache Tomcat Shutdown Startup Script ShellAnar Godjaev
 
Persona: a federated and privacy-protecting login system for the whole Web
Persona: a federated and privacy-protecting login system for the whole WebPersona: a federated and privacy-protecting login system for the whole Web
Persona: a federated and privacy-protecting login system for the whole WebFrancois Marier
 
Getting Started With Play Framework
Getting Started With Play FrameworkGetting Started With Play Framework
Getting Started With Play FrameworkTreasury user10
 
HTTP For the Good or the Bad - FSEC Edition
HTTP For the Good or the Bad - FSEC EditionHTTP For the Good or the Bad - FSEC Edition
HTTP For the Good or the Bad - FSEC EditionXavier Mertens
 
The linux command line for total beginners
The linux command line  for total beginnersThe linux command line  for total beginners
The linux command line for total beginnersCorrie Watt
 
Time Travel - Predicting the Future and Surviving a Parallel Universe - JDC2012
Time Travel - Predicting the Future and Surviving a Parallel Universe - JDC2012 Time Travel - Predicting the Future and Surviving a Parallel Universe - JDC2012
Time Travel - Predicting the Future and Surviving a Parallel Universe - JDC2012 Hossam Karim
 
Linux Command Line Introduction for total beginners, Part 2
Linux Command Line Introduction for total beginners, Part 2 Linux Command Line Introduction for total beginners, Part 2
Linux Command Line Introduction for total beginners, Part 2 Corrie Watt
 
OpenStack Swift - MSST 2011 Tutorial Day
OpenStack Swift - MSST 2011 Tutorial DayOpenStack Swift - MSST 2011 Tutorial Day
OpenStack Swift - MSST 2011 Tutorial DayJoshua McKenty
 
Marko Gargenta_Remixing android
Marko Gargenta_Remixing androidMarko Gargenta_Remixing android
Marko Gargenta_Remixing androidDroidcon Berlin
 
LAMP_TRAINING_SESSION_6
LAMP_TRAINING_SESSION_6LAMP_TRAINING_SESSION_6
LAMP_TRAINING_SESSION_6umapst
 
What is systemd? Why use it? how does it work? - devoxx france 2017
What is systemd? Why use it? how does it work? - devoxx france 2017What is systemd? Why use it? how does it work? - devoxx france 2017
What is systemd? Why use it? how does it work? - devoxx france 2017Quentin Adam
 
DEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destruction
DEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destructionDEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destruction
DEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destructionFelipe Prado
 
Help mijn website is gehackt - Joomla User Group Den Bosch 2014
Help mijn website is gehackt - Joomla User Group Den Bosch 2014Help mijn website is gehackt - Joomla User Group Den Bosch 2014
Help mijn website is gehackt - Joomla User Group Den Bosch 2014Peter Martin
 
OSSEC @ ISSA Jan 21st 2010
OSSEC @ ISSA Jan 21st 2010OSSEC @ ISSA Jan 21st 2010
OSSEC @ ISSA Jan 21st 2010wremes
 
Search videos with youtube api3
Search videos with youtube api3Search videos with youtube api3
Search videos with youtube api3phanhung20
 
Linux 系統管理與安全:基本 Linux 系統知識
Linux 系統管理與安全:基本 Linux 系統知識Linux 系統管理與安全:基本 Linux 系統知識
Linux 系統管理與安全:基本 Linux 系統知識維泰 蔡
 

What's hot (20)

ChefConf 2012 Spiceweasel
ChefConf 2012 SpiceweaselChefConf 2012 Spiceweasel
ChefConf 2012 Spiceweasel
 
Taking the pain out of signing users in
Taking the pain out of signing users inTaking the pain out of signing users in
Taking the pain out of signing users in
 
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜
 
Apache Tomcat Shutdown Startup Script Shell
Apache Tomcat Shutdown Startup Script ShellApache Tomcat Shutdown Startup Script Shell
Apache Tomcat Shutdown Startup Script Shell
 
Persona: a federated and privacy-protecting login system for the whole Web
Persona: a federated and privacy-protecting login system for the whole WebPersona: a federated and privacy-protecting login system for the whole Web
Persona: a federated and privacy-protecting login system for the whole Web
 
Getting Started With Play Framework
Getting Started With Play FrameworkGetting Started With Play Framework
Getting Started With Play Framework
 
HTTP For the Good or the Bad - FSEC Edition
HTTP For the Good or the Bad - FSEC EditionHTTP For the Good or the Bad - FSEC Edition
HTTP For the Good or the Bad - FSEC Edition
 
The linux command line for total beginners
The linux command line  for total beginnersThe linux command line  for total beginners
The linux command line for total beginners
 
Time Travel - Predicting the Future and Surviving a Parallel Universe - JDC2012
Time Travel - Predicting the Future and Surviving a Parallel Universe - JDC2012 Time Travel - Predicting the Future and Surviving a Parallel Universe - JDC2012
Time Travel - Predicting the Future and Surviving a Parallel Universe - JDC2012
 
Linux Command Line Introduction for total beginners, Part 2
Linux Command Line Introduction for total beginners, Part 2 Linux Command Line Introduction for total beginners, Part 2
Linux Command Line Introduction for total beginners, Part 2
 
OpenStack Swift - MSST 2011 Tutorial Day
OpenStack Swift - MSST 2011 Tutorial DayOpenStack Swift - MSST 2011 Tutorial Day
OpenStack Swift - MSST 2011 Tutorial Day
 
From CGI to mod_perl 2.0, Fast!
From CGI to mod_perl 2.0, Fast! From CGI to mod_perl 2.0, Fast!
From CGI to mod_perl 2.0, Fast!
 
Marko Gargenta_Remixing android
Marko Gargenta_Remixing androidMarko Gargenta_Remixing android
Marko Gargenta_Remixing android
 
LAMP_TRAINING_SESSION_6
LAMP_TRAINING_SESSION_6LAMP_TRAINING_SESSION_6
LAMP_TRAINING_SESSION_6
 
What is systemd? Why use it? how does it work? - devoxx france 2017
What is systemd? Why use it? how does it work? - devoxx france 2017What is systemd? Why use it? how does it work? - devoxx france 2017
What is systemd? Why use it? how does it work? - devoxx france 2017
 
DEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destruction
DEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destructionDEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destruction
DEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destruction
 
Help mijn website is gehackt - Joomla User Group Den Bosch 2014
Help mijn website is gehackt - Joomla User Group Den Bosch 2014Help mijn website is gehackt - Joomla User Group Den Bosch 2014
Help mijn website is gehackt - Joomla User Group Den Bosch 2014
 
OSSEC @ ISSA Jan 21st 2010
OSSEC @ ISSA Jan 21st 2010OSSEC @ ISSA Jan 21st 2010
OSSEC @ ISSA Jan 21st 2010
 
Search videos with youtube api3
Search videos with youtube api3Search videos with youtube api3
Search videos with youtube api3
 
Linux 系統管理與安全:基本 Linux 系統知識
Linux 系統管理與安全:基本 Linux 系統知識Linux 系統管理與安全:基本 Linux 系統知識
Linux 系統管理與安全:基本 Linux 系統知識
 

Similar to Love The Terminal

파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Composeraccoony
 
yusukebe in Yokohama.pm 090909
yusukebe in Yokohama.pm 090909yusukebe in Yokohama.pm 090909
yusukebe in Yokohama.pm 090909Yusuke Wada
 
DCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDocker, Inc.
 
PFIセミナー資料 H27.10.22
PFIセミナー資料 H27.10.22PFIセミナー資料 H27.10.22
PFIセミナー資料 H27.10.22Yuya Takei
 
So you want to build a Facebook app
So you want to build a Facebook appSo you want to build a Facebook app
So you want to build a Facebook appkamal.fariz
 
Mac OS X Lion で作る WordPress local 環境
Mac OS X Lion で作る WordPress local 環境Mac OS X Lion で作る WordPress local 環境
Mac OS X Lion で作る WordPress local 環境Yuriko IKEDA
 
Capital onehadoopclass
Capital onehadoopclassCapital onehadoopclass
Capital onehadoopclassDoug Chang
 
hacking-embedded-devices.pptx
hacking-embedded-devices.pptxhacking-embedded-devices.pptx
hacking-embedded-devices.pptxssuserfcf43f
 
How we use and deploy Varnish at Opera
How we use and deploy Varnish at OperaHow we use and deploy Varnish at Opera
How we use and deploy Varnish at OperaCosimo Streppone
 
glance replicator
glance replicatorglance replicator
glance replicatoririx_jp
 

Similar to Love The Terminal (20)

Backups
BackupsBackups
Backups
 
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
 
Command
CommandCommand
Command
 
yusukebe in Yokohama.pm 090909
yusukebe in Yokohama.pm 090909yusukebe in Yokohama.pm 090909
yusukebe in Yokohama.pm 090909
 
Da APK al Golden Ticket
Da APK al Golden TicketDa APK al Golden Ticket
Da APK al Golden Ticket
 
DCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker Captains
 
Operation outbreak
Operation outbreakOperation outbreak
Operation outbreak
 
Ubic
UbicUbic
Ubic
 
Ubic-public
Ubic-publicUbic-public
Ubic-public
 
PFIセミナー資料 H27.10.22
PFIセミナー資料 H27.10.22PFIセミナー資料 H27.10.22
PFIセミナー資料 H27.10.22
 
So you want to build a Facebook app
So you want to build a Facebook appSo you want to build a Facebook app
So you want to build a Facebook app
 
load errorcmd
 load errorcmd load errorcmd
load errorcmd
 
Mac OS X Lion で作る WordPress local 環境
Mac OS X Lion で作る WordPress local 環境Mac OS X Lion で作る WordPress local 環境
Mac OS X Lion で作る WordPress local 環境
 
Capital onehadoopclass
Capital onehadoopclassCapital onehadoopclass
Capital onehadoopclass
 
hacking-embedded-devices.pptx
hacking-embedded-devices.pptxhacking-embedded-devices.pptx
hacking-embedded-devices.pptx
 
Dtalk shell
Dtalk shellDtalk shell
Dtalk shell
 
EC2
EC2EC2
EC2
 
How we use and deploy Varnish at Opera
How we use and deploy Varnish at OperaHow we use and deploy Varnish at Opera
How we use and deploy Varnish at Opera
 
glance replicator
glance replicatorglance replicator
glance replicator
 
Linux configer
Linux configerLinux configer
Linux configer
 

Recently uploaded

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...apidays
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
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 WorkerThousandEyes
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
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 educationjfdjdjcjdnsjd
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
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...apidays
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
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
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 

Recently uploaded (20)

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...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
+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...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
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...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
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
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 

Love The Terminal

  • 1. L ve the Terminal Because life is better when you can work on the command line Mike West Yahoo! Frontend Summit, Dec. 2007 Slides: http://mikewest.org/file_download/12
  • 2. The command line is complex, and quite impossible to cover fully. So let’s begin by limiting our scope.
  • 4. Foundations Unix-style systems all behave according to similar rules; understanding those underlying ideas and processes is critical.
  • 5. Connectivity My computer is a paperweight without a network; I need to get secure access to many remote machines, and do things there.
  • 6. Scripting Don’t type the same things over and over; save your sanity with just a little understanding of Bash aliases and functions.
  • 8. Foundations Unix-style systems are built primarily on small, single-purpose utilities that can be chained together for larger effect. http://flickr.com/photos/johnseb/458716114/
  • 9. Foundations Each of these tools operates in one way or another on streams. http://flickr.com/photos/johnseb/458716114/
  • 10. Foundations STDOUT $> ls file-1.txt file-2.txt $> http://flickr.com/photos/johnseb/458716114/
  • 11. Foundations STDIN $> perl $x = “Hello, world!”; print quot;n$xnquot;; ^D Hello, world! $> http://flickr.com/photos/johnseb/458716114/
  • 12. Foundations STDERROR $> perl $x = 1/0; print quot;n$xnquot;; Illegal division by zero at - line 1. $> http://flickr.com/photos/johnseb/458716114/
  • 13. Foundations Stream Redirection http://flickr.com/photos/johnseb/458716114/
  • 14. Foundations Input Redirection: `<` mikewest:~/some_dir westm$ validator < ./tmp.html mikewest:~/some_dir westm$ http://flickr.com/photos/johnseb/458716114/
  • 15. Foundations Output Redirection: `>` and `>>` mikewest:~/some_dir westm$ ls > ./tmp mikewest:~/some_dir westm$ http://flickr.com/photos/johnseb/458716114/
  • 16. Foundations Error Redirection: `2>` mikewest:~/some_dir westm$ errorful 2> ./dev/null mikewest:~/some_dir westm$ errorful > ./dev/null 2>&1 mikewest:~/some_dir westm$ http://flickr.com/photos/johnseb/458716114/
  • 17. Foundations Chaining Streams http://flickr.com/photos/johnseb/458716114/
  • 18. Foundations Small Utilities, Working Together: `|` $> ls -la | sort -r -k 5 | head -3 -rw-r--r-- 1 westm westm 34749 Oct 19 12:11 SiteAssistant.js -rw-r--r-- 1 westm westm 12292 Oct 18 22:51 .DS_Store -rw-r--r-- 1 westm westm 8161 Oct 19 11:35 SiteAssistant.css Lists the 3 (`head`) largest (`sort`) files in the current directory (`ls`) http://flickr.com/photos/johnseb/458716114/
  • 19. Foundations Permissions System http://flickr.com/photos/johnseb/458716114/
  • 20. Foundations Each file has an “owner”, a “group”, as well as 3 sets of execute, read, and write permission bits. http://flickr.com/photos/johnseb/458716114/
  • 21. Foundations $> ls -lah -rw-r--r-- 1 westm westm 2K Aug 2 2001 xmalloc.c $> chmod 777 xmalloc.c $> ls -lah -rwxrwxrwx 1 westm westm 2K Aug 2 2001 xmalloc.c 1 --x execute 2 -w- write 3 -wx write and execute 4 r-- read 5 r-x read and execute 6 rw- read and write 7 rwx read, write and execute http://flickr.com/photos/johnseb/458716114/
  • 22. Foundations Process Control http://flickr.com/photos/johnseb/458716114/
  • 23. Foundations You can start processes in the background with `&`, pause processes with Crtl-Z, and deal with paused processes using `fg` and `bg`. http://flickr.com/photos/johnseb/458716114/
  • 24. Foundations Demo go herquot; http://flickr.com/photos/johnseb/458716114/
  • 25. Foundations Editing Files http://flickr.com/photos/johnseb/458716114/
  • 26. Foundations Avoid holy wars; just use VIM. http://flickr.com/photos/johnseb/458716114/
  • 27. Foundations Demo go herquot; http://flickr.com/photos/johnseb/458716114/
  • 29. Connectivity Whatever your connectivity needs, SSH is almost certainly the answer. http://www.flickr.com/photos/hi-phi/36854889/
  • 30. Connectivity Passwords are annoying L mikewest:~ westm$ ssh mikewest@mikewest.org I Password: Last login: Thu Nov 29 11:45:59 2007 from 193.93.196.161 _____________________________________ A ________| |_________ | girard.joyent.us | / | | / F | quot;Mrs. Robinson, you're trying | / | to seduce me. Aren't you?quot; | / / |_____________________________________| /___________) (___________ [girard:~] mikewest$ http://www.flickr.com/photos/hi-phi/36854889/
  • 31. Connectivity SSH Keys are much better http://www.flickr.com/photos/hi-phi/36854889/
  • 32. Connectivity SSH Keys are much friendlier and are trivial to create and use. http://www.flickr.com/photos/hi-phi/36854889/
  • 33. Connectivity Just run `ssh-keygen` mikewest:~ westm$ ssh-keygen -t rsa -b 2048 Generating public/private rsa key pair. Enter file in which to save the key (/Users/westm/.ssh/ id_rsa): /Users/westm/.ssh/test_rsa Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /Users/westm/.ssh/ test_rsa. Your public key has been saved in /Users/westm/.ssh/ test_rsa.pub. The key fingerprint is: 8f:0b:e7:ea:17:61:69:6a:11:06:f5:56:ac:70:c4:69 westm@mikewest.munich.corp.yahoo.com http://www.flickr.com/photos/hi-phi/36854889/
  • 34. Connectivity Upload to the server, and append to ~/.ssh/authorized_keys mikewest:~ westm$ scp /Users/westm/.ssh/test_rsa.pub mikewest@mikewest.org:~/.ssh/authorized_keys http://www.flickr.com/photos/hi-phi/36854889/
  • 35. Connectivity Of course, you will create passphrased keys, because anything else is idiocy. http://www.flickr.com/photos/hi-phi/36854889/
  • 36. Connectivity SSH Agent http://www.flickr.com/photos/hi-phi/36854889/
  • 37. Connectivity SSH Agent is Easy mikewest:~ westm$ eval `ssh-agent` Agent pid 80094 mikewest:~ westm$ ssh-add Enter passphrase for /Users/westm/.ssh/id_rsa: Identity added: /Users/westm/.ssh/id_rsa (/Users/ westm/.ssh/id_rsa) mikewest:~ westm$ http://www.flickr.com/photos/hi-phi/36854889/
  • 38. Connectivity SSH Agent + Screen http://www.flickr.com/photos/hi-phi/36854889/
  • 39. Connectivity Demo go herquot; http://www.flickr.com/photos/hi-phi/36854889/
  • 41. Scripting Elimination of mindless repetition from your daily life is essential to your continued sanity. http://www.flickr.com/photos/mortimer/221051561/ http://www.flickr.com/photos/hi-phi/36854889/
  • 42. Scripting Uploading SSH Keys, for instance. #!/bin/bash KEY=quot;$HOME/.ssh/id_rsa.pubquot; if [ -z $1 ];then echo quot;Usage: `upload_keys username@host`quot; else echo quot;Putting your key on $1... quot; ssh -q $1 - HEREDOC umask 0077; mkdir -p ~/.ssh; echo quot;`cat $KEY`quot; ~/.ssh/authorized_keys echo quot;done!quot; HEREDOC fi http://www.flickr.com/photos/mortimer/221051561/ http://www.flickr.com/photos/hi-phi/36854889/
  • 43. Scripting Aliases mikewest:~ westm$ ll -/bin/bash: ll: command not found mikewest:~ westm$ alias ll=’ls -lah’ mikewest:~ westm$ ll magically insert result of `ls -lah` here mikewest:~ westm$ http://www.flickr.com/photos/mortimer/221051561/ http://www.flickr.com/photos/hi-phi/36854889/
  • 44. Scripting Functions mikewest:~ westm$ httpload() { echo quot;http://$1quot; /var/tmp/$1.http_load_temp_file http_load -parallel $2 -seconds $3 /var/tmp/ $1.http_load_temp_file rm -f /var/tmp/$1.http_load_temp_file } mikewest:~ westm$ httpload mikewest.org 1000 1000000 magically insert my crashing, burning website here mikewest:~ westm$ http://www.flickr.com/photos/mortimer/221051561/ http://www.flickr.com/photos/hi-phi/36854889/
  • 45. Scripting You can put frequently used functions or aliases into `~/.bash_login` so they’re available immediately. http://www.flickr.com/photos/mortimer/221051561/ http://www.flickr.com/photos/hi-phi/36854889/
  • 46. Questions? Mike West mike@mikewest.org http://mikewest.org/