Linux terminal cheat sheet
  • Open terminal: Ctrl+Alt+T
  • Tab completion: tab, tab X 2
  • Switch windows: Alt+Tab
  • Switch languages: Sup+Space
  • Previous commands: up arrow
  • Recent commands: Ctrl+R
  • Stop the current command: Ctrl+C
  • Exit session: Ctrl+D
  • Copy: Ctrl+Shift+C
  • Clear the terminal: Ctrl+L
  • Repeat last command: !!
  • Stop the current command: Ctrl+Z
  • Paste: Ctrl+Shift+V
  • Clear: $ clear
  • Detailed list: $ ls -l
  • Including hidden: $ ls -a
  • List by time: $ ls -t
  • Compress to gzip: $ tar -zcvf archive.tar.gz dir_to_compress
  • Uncompress tar: $ tar -tf archive.tar
  • Uncompress gzip: $ gzip -d archive.gz
  • Uncompress tar gzip: $ tar -ztf archive.tar.gz
  • Uncompress bzip2: $ bzip2 -jtf archive.tar.bz2
  • Start Apache:$ service apache2 start
  • Restart Apache:$ service apache2 restart
  • Set privileges recursively: $ chmod -R 755 dir
  • Set privileges on a file: $ chmod 644 file
  • Set ownership on a file: $ chown username file
  • Set ownership recursively: $ chown -R username directory
  • Download file to dir: $ wget http://example.com/file-name dir-name
  • Open directory in the file manager: $ gnome-open dir-name/
  • Create a file: $ touch file_name
  • Create a directory: $ mkdir dir_name
  • Copy file to directory: $ cp file to_folder
  • Copy directory A to directory B: $ cp -r from_folder to_folder
  • Move file to directory: $ mv file to_folder
  • Rename: $ mv original_name new_name
  • Remove recursively: $ rm -rf folder
  • Read a file: $ cat file-name
  • Read a file with arrow navigation: $ less file-name
  • Show the first 15 lines: $ head -n 15 file-name
  • Show the last 15 lines: $ tail -n 15 file-name
  • Save file : w
  • Quit if no changes were made : q
  • Quit file without saving : q!
  • Save file and quit : wq
  • Connect a remote server: $ ssh -l domain-user example.com
  • Find file by name: $ find /~ -name "file_name"
  • Find file by type: $ find /~ -name "*.txt"
  • Install software: $ sudo apt-get install software_name
  • Ping a domain: $ ping ip-address
  • Current date and time: $ date
  • Show command info: $ man command-name
  • Show the latest commands: $ history
  • Import database: $ mysql -u user_name -p -h localhost db_name < file_name.sql