Do Not

    The command Line  |   

Tanner Moushey, @tannermoushey

  Where to Find Me  


  Freelancing under the alias of iWitness Design  

Why Learn the Command Line?

You do not need to be a Wiz to use the 

command line

I fear:

  • Bash scripts
  • Provisioning servers
  • Hackers
  • Apache
  • MySQL
  • And much, much more

Simple Tools for Simple Tasks

  • cd ........ Change Directory
  • ls .......... List Contents of Directory
  • cp ......... Copy File or Directory
  • mv ........ Move File or Directory
  • rm ........ Delete File or Directory
  • vim ...... Edit a File
  • sudo ..... Run Command as Admin
  • man .... Manual for commands

Change Directory - CD

    tannermoushey$  cd   /var/www/my_site/wp-content    

Tab Autocomplete

    tannermoushey$ cd /var/www/my     - [tab]

Back Up

    tannermoushey$ cd ..     - one directory

    tannermoushey$ cd ../../     - multiple directories

Relative Path

    tannermoushey$ cd wp-content/themes/     - notice we did not begin with a "/"

List Items In Current Directory - LS

    tannermoushey$ ls    

List File attributes

    tannermoushey$ ls -l    

List All Files (Including hidden files)

    tannermoushey$ ls -a    
    tannermoushey$ ls -la     - all files and their attributes

List Files and Their Sizes

    tannermoushey$ ls -lh    

Copy FIles or Directories - CP

    tannermoushey$ cp <file_to_copy> <destination>    

Copy a File

    tannermoushey$ cp wp-config-sample.php wp-config.php    


    tannermoushey$ cp -R directory directory-2    - The "-R" flag stands for recursive and is required for directories.

Move File or Directory - MV

    tannermoushey$ mv <filetomove> <destination>    

Move a File

    tannermoushey$ mv wp-config-sample.php wp-config.php    

Move a Directory

    tannermoushey$ mv directory directory-2    

Delete File or Directory - rm

    tannermoushey$ rm <file_to_be_deleted>    

Delete File

    tannermoushey$ rm wp-config-sample.php    

Delete Directory

    tannermoushey$ rm -r directory-2     - Again the "r" stands for recursive and is required for directories

Edit a File - vim

    tannermoushey$ vim wp-config.php    

Vim command keys:
i - Insert
:w - save
:q - quit

Press ESC before typing any command keys

Run a Command as Admin - sudo

    tannermoushey$ sudo vim /etc/hosts    

Manual for Commands - Man

    tannermoushey$  man ls     

Further Study

    ping  <address>    - test communication with a server

    ssh <user@address>     - remote access to a server

    sftp <user@address>     - transfer files between your computer and a server

    tar -zcvf <destination> <target>     - compress a directory

Best way to learn the Command Line...