Skip to content

Instantly share code, notes, and snippets.

@themainframe
Forked from anonymous/buds_guide.md
Last active June 1, 2016 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save themainframe/3288f1490465f5abdf3c to your computer and use it in GitHub Desktop.
Save themainframe/3288f1490465f5abdf3c to your computer and use it in GitHub Desktop.
Bud's Guide

Bud's UNIX/Linux Guide

Remember you can get help with any UNIX command with man <command>.

Shell Tips & Shortcuts

Most Linuxes ship with the bash shell.

Files

  • ~ is your home directory (E.g. /home/bud)
  • .. is the directory above the current one
  • . is the current directory
  • * is every file in the current directory

You can combine these, for example ../* is every file in the directory above this one.

You can use this to perform bulk actions on files, for example to move everything in this directory into the one below: mv * ../

Speedups

  • Pressing TAB will try to autocomplete the command, path or filename you are typing.
  • Pressing ^C (Ctrl + C) will clear the current command you are typing.
  • Pressing ^D will log out of the shell.
  • Pressing ^L will clear the shell scrollback.
  • Pressing ^Z will put the current command in the background and...
  • ...Typing %1 and pressing enter will bring the first backgrounded command to the foreground again.

Programs

Linuxes ship with a bunch of useful programs in the /bin, /usr/bin, /sbin and /usr/sbin directories. Here are a few useful ones.

Files, Directories and General Shell

  • ls <path> - List contents of current (or specified) directory
  • cd <path> - Move to the specified directory
  • nano <path> - Edits a file
  • cp <source> - Copies a file
  • mv <source> - Moves a file
  • rm <path> - Removes a file
  • cat <path> - Show the contents of a file
  • pwd - Show me where I am right now
  • stat <path> - Show the properties (permissions, etc) of a file
  • du <path> - Show the disk space consumed by a file

Getting Help

  • apropos <something> - Search manual pages, describe what something is, does or means
  • man <command> - Show the manual page for a command
  • which <binary> - Search your $PATH directories for a binary, telling you where it is

Network & Internet

  • ping <ip/domain> - Sends ICMP packets and awaits replies, displays statistics
  • traceroute <ip/domain> - Shows the route to a target IP or domain
  • dig <domain> - Performs a DNS lookup for the specified domain
  • ifconfig - Displays the configuration of the machine's network interfaces
  • wget <URL> - Downloads the specified URL and saves it as a file in the current directory
  • ssh <user>@<ip/domain> - Open a Secure Shell session as a user at an IP or domain

Processes

Every program running on a Linux system is a process. You can control processes by sending them signals.

  • ps aux - Shows a list of all processes, including their usernames, including ones that are background processes (x).
  • kill -9 <processid> - Sends the SIGKILL (9) signal to processid.
  • killall -9 <processname> - Sends the SIGKILL (9) signal to all processes named processname.
  • free (memory_pressure on Mac OS X) - Shows the current memory usage.

Administrative

Have a look at the manual pages before using!

  • sudo <command> - Super User DO Run a command as the superuser, with root's privileges
  • su - Become the superuser
  • shutdown - Shuts the system down
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment