Useful terminal commands in Ubuntu

Read More
INSTALL COMMAND-LINE INTERFACE (CLI) SOFTWARESome of the commands listed below are not available in Ubuntu or Debian by default.

To install the remaining CLI software, download the installation script install-additional-cli-software.sh, open your terminal, and execute it: bash install-cli-software.sh.

1. ESSENTIAL COMMANDS

  • Navigation: pwd, ls, cd folder (folders are case sensitive!), cd ...
  • File manipulation: cat, cp, ln, mkdir, mv, rm, rmdir, touch.
  • Help: man terminal_command .
  • Permissions: chgrp, chmod, chown, su, sudo.
  • Search: find.
  • Text editors: ed, nano, vi, vim.
  • Text file visualization: head, less, more, tail.
  • Install a package: sudo apt-get install package.
  • Uninstall a package: sudo apt-get purge package.
  • Remove packages that are no longer needed: sudo apt-get autoremove.

2. BASH SHORTCUTS

  • Autocomplete files, folders, commands, packages, etc.: Tab.
  • List all available files, folders, commands, packages, etc.: Tab + Tab.
  • Go to previous command: , or Ctrl + P.
  • Go to next command: , or Ctrl + N.
  • Search through previously used commands: Ctrl + R.
  • Interrupt whatever you are running: Ctrl + C.

2. BASIC COMMANDS

  • Compare files line by line: colordiff, diff, vimdiff, wdiff.
  • List files in databases that match a pattern: locate, sudo updatedb.
  • Network interface: ifconfig.
  • Report disk space usage: df -H, du -hs folder.
  • OpenSSH SSH client with X11 forwarding: ssh user@server -X.
  • Print lines matching a pattern from a text file: grep.
  • Print newline, word, and byte counts for each file: wc.
  • Secure copy (remote file copy program): scp.
  • Show current processes: htop, ps, top.

3. SCREEN COMMANDS

  • Create a screen session: screen.
  • Detach from the current screen session: Ctrl + A then D.
  • List the screen session identification strings: screen -ls.
  • Reattach to a screen session: screen -r session_id_string.
  • Terminate the current screen session: exit, or Ctrl + A then :quit.
  • Scroll up/down during session: Ctrl + A then Esc then //PgUp/PgDn.

4. OTHER COMMANDS

  • Extract an ISO file: 7z x filename.iso.
  • Report faked system time to programs: faketime.
  • Retrieves files from the web: wget.
  • Print shared library dependencies: ldd executable_filename.
  • Make symbolic links: ln -s input_filename output_link_name.
  • List block devices: lsblk.
  • Format USB stick as VFAT: sudo mkfs.vfat -I /dev/sdx -n NAME && sync.
  • Restore disk from image: sudo dd bs=1M if=im.iso of=/dev/sdx && sync.

5. FFMPEG COMMANDS

  • Convert image to 5 sec. video: ffmpeg -loop 1 -i 01.png -t 5 out.mp4.
  • 15 images to 30 Hz 5 sec. video: ffmpeg -r 3 -i %03d.png -r 30 out.mp4.
  • Resize video to 720p: ffmpeg -i input.webm -s 1280x720 output.webm.
  • Fade in the first 25 frames and fade out the last 25 frames of a 1000-frame video: ffmpeg -i in.mp4 -vf "fade=in:0:25, fade=out:975:25" out.mp4.
  • Concatenate videos: ffmpeg -f concat -i mylist.txt -c copy out.mp4.

6. SVN COMMANDS

  • Create new repository: svnadmin create repository_name.
  • Checkout: svn co svn+ssh://user@server/path/to/repository.
  • Update working copy: svn update.
  • Get status of current copy: svn status.
  • Add all items recursively: svn add *.
  • Add an item (if folder, adds recursively): svn add item_name.
  • Delete an item (if folder, deletes recursively): svn delete item_name.
  • Commit with log message: svn commit -m 'message'.

7. FIND EXAMPLES

  • Run files recursively in current dir.: find . -type f -exec file '{}' \;.
  • Delete all .svn folders: find . -iname .svn -prune -exec rm -r '{}' \;.
  • Copy all png files to png: find ./ -name *.png -exec cp '{}' ./png \;.

8. PDFTK EXAMPLES

  • Join all PDF files into a new PDF file: pdftk *.pdf cat output out.pdf.
  • Join 3 PDF files: pdftk in1.pdf in2.pdf in3.pdf cat output out.pdf.
  • Extract pages from a PDF: pdftk in.pdf cat 1 25-35 end output out.pdf.

http://milq.github.io/useful-terminal-commands-ubuntu-debian

Manuel Ignacio López Quintero