How to: alternative: seq -w 5 10
for i in {1..10} ; do echo $i ; done
```

###### Simple Bash filewatching

```bash
unset MAIL; export MAILCHECK=1; export MAILPATH='$FILE_TO_WATCH?$MESSAGE'
```

---

##### Tool: [busybox](https://www.busybox.net/)

###### Static HTTP web server

```bash
busybox httpd -p $PORT -h $HOME [-c httpd.conf]
```

___

##### Tool: [mount](https://en.wikipedia.org/wiki/Mount_(Unix))

###### Mount a temporary ram partition

```bash
mount -t tmpfs tmpfs /mnt -o size=64M
```

  * `-t` - filesystem type
  * `-o` - mount options

###### Remount a filesystem as read/write

```bash
mount -o remount,rw /
```

___

##### Tool: [fuser](https://en.wikipedia.org/wiki/Fuser_(Unix))

###### Show which processes use the files/directories

```bash
fuser /var/log/daemon.log
fuser -v /home/supervisor
```

###### Kills a process that is locking a file

```bash
fuser -ki filename
```

  * `-i` - interactive option

###### Kills a process that is locking a file with specific signal

```bash
fuser -k -HUP filename
```

  * `--list-signals` - list available signal names

###### Show what PID is listening on specific port

```bash
fuser -v 53/udp
```

###### Show all processes using the named filesystems or block device

```bash
fuser -mv /var/www
```

___

##### Tool: [lsof](https://en.wikipedia.org/wiki/Lsof)

###### Show process that use internet connection at the moment

```bash
lsof -P -i -n
```

###### Show process that use specific port number

```bash
lsof -i tcp:443
```

###### Lists all listening ports together with the PID of the associated process

```bash
lsof -Pan -i tcp -i udp
```

###### List all open ports and their owning executables

```bash
lsof -i -P | grep -i "listen"
```

###### Show all open ports

```bash
lsof -Pnl -i
```

###### Show open ports (LISTEN)

```bash
lsof -Pni4 | grep LISTEN | column -t
```

###### List all files opened by a particular command

```bash
lsof -c "process"
```

###### View user activity per directory

```bash
lsof -u username -a +D /etc
```

###### Show 10 largest open files

```bash
lsof / | \
awk '{ if($7 > 1048576) print $7/1048576 "MB" " " $9 " " $1 }' | \
sort -n -u | tail | column -t
```

###### Show current working directory of a process

```bash
lsof -p
| grep cwd
```

___

##### Tool: [ps](https://en.wikipedia.org/wiki/Ps_(Unix))

###### Show a 4-way scrollable process tree with full details

```bash
ps awwfux | less -S
```

###### Processes per user counter

```bash
ps hax -o user | sort | uniq -c | sort -r
```

###### Show all processes by name with main header

```bash
ps -lfC nginx
```

___

##### Tool: [find](https://en.wikipedia.org/wiki/Find_(Unix))

###### Find files that have been modified on your system in the past 60 minutes

```bash
find / -mmin 60 -type f
```

###### Find all files larger than 20M

```bash
find / -type f -size +20M
```

###### Find duplicate files (based on MD5 hash)

```bash
find -type f -exec md5sum '{}' ';' | sort | uniq --all-repeated=separate -w 33
```

###### Change permission only for files

```bash
cd /var/www/site && find . -type f -exec chmod 766 {} \;
cd /var/www/site && find . -type f -exec chmod 664 {} +
```

###### Change permission only for directories

```bash
cd /var/www/site && find . -type d -exec chmod g+x {} \;
cd /var/www/site && find . -type d -exec chmod g+rwx {} +
```

###### Find files and directories for specific user/group

```bash