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
Copy A DIRECTORY
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
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