linux-cheatsheet

A cheatsheet with common linux commands and tools

View on GitHub

Basics

Learn the basics.

The prompt

The prompt will usually look something like this username@hostname: ~$ or this [username@hostname ~]$ . You can type commands after the prompt.

If you’re in sudo mode, # will be displayed instead of $. ~ is your current working directory.

Output redirect

You can redirect the output of a command to a file or something else with appending >PATH. You can redirect errors with 2>PATH.

Chaining commands

Useful shortcuts

General Commands

Getting help

System

Variables

Common variables

Shell variables

Environment variables

Both var types

Persistent env vars

To make environment variables persistent, their export statements have to be saved in files.

User-specific vars can be stored in ~/.bashrc (accessable in non-login bash shells), ~/.bash_profile (acessible only by Bash) or ~/.profile (accessible in any Bourne shell).

System-wide vars can be stored in /etc/environment (accessible by every shell) or /etc/profile and the files in /etc/profile.d/ (accessible by bash login shells; using files in the folder is recommended).

More



This cheatsheet was created by Rafael Urben. Found a mistake? Feel free to create a PR or open an issue on GitHub!