Show Menu
Cheatography

PM Linux Command Cheat Sheet by

Useful Linux Commands for Webdevelopers

Directory / Files

cd Direct­­or­yname
Change Directory
ls
List Items in Current Directory
ls -lha
List Items with extra Info in Current Directory
mkdir Direct­­or­yname
Make Directory in Current Directory
mv Filename (new Location or Filename)
Move or Rename File or Folder
mv -R Filename (new Location or Filename)
Move or Rename File or Folder including subdir­­ec­torys
cp Filename (Copied Filename)
Copy an File
cp -R Direct­­or­yname (Copied Direct­­or­y­name)
Copy an Directory

Backups

tar -czvf Backup­­nam­e.tgz .
Backup complete Content from Current Directory
tar -czvf --ex­c­lu­­de=­­"­E­xcl­­ud­e­Dat­a­" Backup­­nam­e.tgz .
Backup Content from Current Directory with Excludes
tar -xzvf Backup­­nam­e.tgz
Extract Backup in Current Directory
mysq­ldump -u User -p­Pas­sword DBName -h Host > Backup­­nam­e.sql
Backu­­p/E­­xport Database to Current Directory
mysql -u User -p­Pas­sword DBName -h Host < Backup­­nam­e.sql
Import Backup from Current Directory to Database

Shared SSH Window

User1: screen -l
to start screen
User2: screen -ls
to check wich screens we have
User2: screen -x
to connect
With this technique you can work together without screen­share via Putty, etc. and both people can actively do something
 

VI / VIM Editor

vim Filename
creat­­e/edit File
vi Filename
creat­­e/edit File
In Editor Command Mode
:w
To Save the File
:q
To Close the Editor
:wq or :x
To Save and Close the Editor
? Word
To Search in the File
Press i
To switch to Insert Mode
In Editor Insert Mode
Press ESC
To exit the Insert Mode and go to Command Mode
Impo­rtant Don't use Stuff like CTRL + S this will crash Putty

Expert User Stuff

grep -rnw -e "­S­ear­­ch­w­ord­" *
Search in Current Directory
scp -C ssh-us­­er­n­ame­s­sh-­­hos­t­:­/pa­t­h/­­to/file .
Download File over SSH from an Server
wget url
Download File over http/h­­ttps
alias new-co­­mm­a­n­dn­­ame­­=­­"­­C­­omm­­an­d­"
Create an Alias for the Current Session
clear
Clears the Terminal
hist­ory
Shows the History of Commands
ctrl + r
to search in the History
Impo­rtant If you want an Alias working every time you loging in you need to add it in the .bas­hrc file

Varnish Related Stuff

varnis­hhist
Show a histogram chart of the last 1,000 requests
varnishlog
See what Varnish is currently processing
varnis­hstat
Show various inform­ation about varnish
netstat -tulpn | grep LISTEN
Shows you all LISTEN Ports with the Service
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Linux Command Line Cheat Sheet
          Ubuntu Unity Cheat Sheet
          Windows Terminal Cheat Sheet