Command List
Here is a cheat sheet of important Linux commands.
Directories
| Command | Examples | Description |
|---|---|---|
| cd | cd cd PATH | Change the working directory |
| ls | ls -l ll -h | List the contents of the working directory |
| mkdir | mkdir DIRECTORY mkdir -p DIRECTORY | Create, i.e. make, a directory |
| pwd | pwd | Print the path to the current working directory |
Files
| Command | Examples | Description |
|---|---|---|
| mv | mv SOURCE DESTINATION | Move a file or directory |
| cp | cp SOURCE DESTINATION | Copy a file or directory |
| rm | rm FILE rm -r DIRECTORY | Remove/delete a file or directory |
Permissions
| Command | Examples | Description |
|---|---|---|
| chmod | chmod ugo+rwx FILE chmod -R ugo+rwx DIRECTORY | Change the permission on a file or directory |
| chown | chown USER FILE chown -R USER DIRECTORY | Change the owner of a file or directory |
| chgrp | chgrp GROUP FILE chgrp -R GROUP DIRECTORY | Change the group of a file or directory |
Display Data
| Command | Examples | Description |
|---|---|---|
| echo | echo "text to print" | Echo, i.e., print, the provided text |
| cat | cat FILE | Print the contents of a file or stream |
| head | head -n 10 FILE | Print the first lines of a file or stream |
| tail | tail -n 10 FILE | Print the last lines of a file or stream |
Find and Filter
| Command | Examples | Description |
|---|---|---|
| find | find . -name *.txt | Find files that match a pattern (and much more) |
| grep | grep PATTERN FILE | Filter for lines of a file that match a pattern |
Disks
| Command | Examples | Description |
|---|---|---|
| df | df -h . | Report the amount of free disk space on one or all drives |
| du | du -h -max-depth 2 | Report the amount of disk space used in a directory and its contents |
System Processes
| Command | Examples | Description |
|---|---|---|
| top | top top -u USER | Report the memory and CPU usage of all, or some, system processes |
| htop | htop htop -u USER | Like top, with a bit more information and formatting |
File Compression
| Command | Examples | Description |
|---|---|---|
| gzip | gzip FILE gzip -c > FILE gunzip FILE zcat FILE | Compress a file, or reverse the process |
| tar | tar -czf ARCHIVE_FILE tar -xzf ARCHIVE_FILE | Archive (and compress) one or more files, or reverse the process |