|
|
# Bash Cheat Sheet
|
|
|
|
|
|
These are a list of commands that work in any bash shell.
|
|
|
They will also work in any UNIX or UNIX-like environment (e.g. a OSX terminal, a Linux terminal).
|
|
|
|
|
|
## Cheat Sheet
|
|
|
|
|
|
| **Command** | **Description** | **Invocation** |
|
|
|
| ----------------- | --- | --- |
|
|
|
| `pwd` | Outputs your current directory. | `pwd` |
|
... | ... | @@ -8,4 +13,22 @@ |
|
|
| | Lists the contents of a directory. | `ls /path/to/dir` |
|
|
|
| `rm` | Deletes a file. | `rm /path/to/file` |
|
|
|
| | Deletes a directory. | `rm -rf /path/to/directory` |
|
|
|
| `cp` | Copys a file. | `cp /path/to/src /path/to/dst` |
|
|
|
| | Copys a directory. | `cp -r /path/to/src /path/to/dst` |
|
|
|
| `mv` | Moves a file or directory. | `mv /path/to/src /path/to/dst` |
|
|
|
| `mkdir` | Creates a directory. | `mkdir /path/to/dir` |
|
|
|
| `touch` | Creates a file. | `touch /path/to/file` |
|
|
|
|
|
|
## On `~`, `.`, and `..`
|
|
|
|
|
|
In a UNIX environment, there are a few symbols that carry specific meanings.
|
|
|
The first is `~` which signifies your *home* directory.
|
|
|
For example, if you run `ls ~` you will list the contents of your home directory.
|
|
|
The second is `.` which represents the current directory.
|
|
|
Running `cp ~/HelloWorld.java .` will copy `HelloWorld.java` from your home directory into the current directory.
|
|
|
The third is `..` which represents the directory above the current directory.
|
|
|
To move into the directory above the current directory, we run `cd ..`.
|
|
|
|
|
|
[Return to Cheat Sheet index](index)
|
|
|
|
|
|
[Return to Bash and Git index](../home) |