---
myst:
html_meta:
description: Quick reference sheet for common Ubuntu command-line commands.
---
(command-line-cheat-sheet)=
# Command-line cheat sheet
This page lists the most common commands in the Ubuntu command line.
For full details on any command, run `man ` in your terminal.
## Navigation
| Command | Description |
|---------|-------------|
| `pwd` | Print the current working directory |
| `ls` | List all files and directories in the current directory |
| `ls -l` | Long list, with permissions, owner, size, and date |
| `ls -a` | List all, including hidden files (file names starting with `.`) |
| `ls -la` | Long listing including hidden files |
| `ls -ld ` | Show the directory entry itself, not its contents, for directory `` |
| `ls -l ` | Show file type, permissions, owner, and size for `` |
| `cd ` | Change to the specified directory |
| `cd ..` | Move up to the parent directory |
| `cd ~` | Return to the home directory |
| `cd -` | Return to the previous directory |
| `cd /` | Move to the root directory |
| `cd ../../` | Move up two levels at once |
## Working with the filesystem
| Command | Description |
|---------|-------------|
| `mkdir ` | Create a new directory |
| `rmdir ` | Remove an empty directory |
| `tree` | Display directory structure as a tree |
| `tree -L ` | Display tree to depth `n` |
## Working with files
| Command | Description |
|---------|-------------|
| `touch ` | Create a new (empty) file, or update the timestamp of an existing file |
| `cp ` | Copy a file from a source (`src`) to a new destination (`dest`) |
| `cp -a ` | Copy a directory recursively, preserving permissions |
| `mv ` | Move or rename a file or directory |
| `rm ` | Remove a file |
| `cat ` | Print the contents of `` to the screen |
| `less ` | View file contents one page at a time |
| `head ` | Print the first 10 lines of a file |
| `tail ` | Print the last 10 lines of a file |
## Users, groups, and permissions
| Command | Description |
|---------|-------------|
| `chmod ` | Change file permissions (symbolic or numeric notation) |
| `chown : ` | Change file owner and group |
| `umask` | Show or set the default permissions mask |
| `sudo ` | Run a command with administrator privileges |
| `grep /etc/passwd` | Look up a user account |
| `grep /etc/group` | Look up group membership |
## Searching
| Command | Description |
|---------|-------------|
| `grep ` | Search for lines matching a pattern in a file |
| `find -name ` | Search for files matching a name pattern |
| `which ` | Show the full path to an executable command |
| `file ` | Determine the type of a file |
## Getting help
| Command | Description |
|---------|-------------|
| `man ` | Open the manual page for a command |
| `man man` | Open the manual page for `man` itself |
| `man -k ` | Search man page descriptions for a keyword |
| ` --help` | Print a brief help summary for a command |