This cheat sheet is available in 25+ languages. Visit github.com/github/training-kit to access translations.
Install Bash
Bash is typically a native application on Linux/Unix based machines; however, if installation is necessary you can find links to downloads below.Bash for Windows
Because bash isn’t native to Windows, an application like Cygwin would be necessary to gain the same features readily available in linux/macOS. https://www.cygwin.comBash for macOS and Linux
Bash is natively installed on Linux/Unix based machines.Configure Shell
Configuring bash aliases can save time and make common commands easier to use.Working with Directories
Navigate, create, and delete directory folders and files.| Command | Description |
|---|---|
pwd | Display path of current working directory |
cd [directory] | Change working directory to [directory] |
cd .. | Navigate to the parent directory |
ls | List directory contents |
ls -la | List detailed directory contents, including hidden files |
mkdir [directory] | Create a new directory named [directory] |
Handling Output
Control the flow of data from a file.Display file contents
Display file contents
Redirect output
Redirect output
Clear screen
Clear screen
Working with Files
Moving, renaming, creating and deleting files.| Command | Description |
|---|---|
rm [file] | Delete [file] |
rm -r [directory] | Delete [directory] |
rm -f [file] | Force-delete [file] (add -r to force-delete a directory) |
mv [file-old] [file-new] | Rename [file-old] to [file-new] |
cp [file] [directory] | Copy [file] to [directory] (possibly overwriting an existing file) |
cp -r [src-directory] [dest-directory] | Copy [src-directory] and its contents to [dest-directory] (possibly overwriting files in an existing directory) |
touch [file] | Update file access and modification time (and create [file] if it does not exist) |
File and Folder Permissions
Change read, write, and execute permissions on files and folders.chmod - Change permissions
chmod - Change permissions
Octal representation of permissions are groups of permissions for User (u), Group (g) and Others (o) with values that are sum of read (4), write (2) and execute (1) permissions. For example, 755 is:
- Owner = 7; read (4) + write (2) + execute (1)
- Group = 5; read (4) + execute (1)
- Others = 5; read (4) + execute (1)
chown - Change ownership
chown - Change ownership
Networking and Internet
Commands for network operations, file transfers, and remote connections.| Command | Description |
|---|---|
ping [ip/host] | Ping the [ip/host] and displays time, among other things |
curl -O [url] | Downloads [url] to current working directory |
ssh [user]@[ip/host] | Starts an SSH connection to [host] using [user] |
ssh-copy-id [user]@[host] | Adds your SSH key to the host file for [user] to enable a keyed or passwordless login |
scp [file] [user]@[ip/host]:/path/to/file | Securely copies [file] to a remote [host] |
wget [file] | Downloads [file] to your current working directory |
System Tasks
Find important information related to your currently running system.Process management
Process management
Disk usage
Disk usage