---
title: Command line stuff
+layout: 2017/sheet
---
## List (ls)
+{: .-three-column}
+
+### Usage
ls [options] [paths]
|---
| `-F` | Add / after directories |
| `-G` | Color |
-{:.shortcuts}
### Options
| `-R` | Recurse |
| `-a` | Include hidden (dotfiles) |
| `-A` | Include hidden (but not . and ..) |
-{:.shortcuts}
### Sorting
| `-c` | sort by time status was changed |
|---
| `-h` | Human-readable size (3k) |
-{:.shortcuts}
-
-<br>
## Tail
+{: .-three-column}
+
+### Usage
tail [-F | -f | -r] [-bN | -cN | -nN] [file ...]
| `-f` | follow |
| `-F` | follow by filename (accounts for log rotation) |
| `-r` | Reverse order |
-{:.shortcuts}
### Options
| `-cN` | N bytes |
| `-nN` | N lines |
| `+N` | Start from line N |
-{:.shortcuts}
<br>
## Sudo
+{: .-three-column}
+
+### Usage
```
sudo [options] <command>
### Listing
| `-l` | List allowed commands |
-{:.shortcuts}
### Options
| `-n` | Don't prompt for password |
| `-P` | Preserve group vector |
| `-S` | Read password from stdin |
-{:.shortcuts}
### File descriptors
| `-C fd` | Close all open file descriptors |
-{:.shortcuts}
### Prompt
| `-p prompt` | Custom prompt (-p "%p password:") |
-{:.shortcuts}
### Interactive
|----
| `-u user` | run as this user |
| `-g group` | run as this group |
-{:.shortcuts}
### Timestamp
| `-v` | revalidate timestamp for 5 mins |
| `-k` | invalidate timestamp |
| `-K` | just like -k |
-{:.shortcuts}
-
-<br>
## wc (Word count)
+{: .-three-column}
+
+### wc
```
... | wc [options]
```
+### Options
+
| `-c` | Bytes |
| `-l` | Lines |
| `-m` | Characters (incl multi-byte) |
| `-w` | Words |
-{:.shortcuts}
-
-<br>
-
-## Search-and-replace in all files
-
- perl -p -i -e 's/hello/HELLO/g' **/*
-
-<br>
## Grep
+{: .-three-column}
+
+### Usage
```
grep [options] [pattern] [file ...]
| `-r, -R` | --recursive |
| `-v` | --invert-match |
| `-i` | --ignore-case |
-{:.shortcuts}
### Synonyms
egrep => grep -E
fgrep => grep -F
+
+## Other recipes
+{: .-three-column}
+
+### Search-and-replace in all files
+
+ perl -p -i -e 's/hello/HELLO/g' **/*