# Linux Cheats
## General (tested in Debian)
Create directory recursivly: `mkdir -p these/folders/doesnt/exist`
> -p for "parent"
List directory sorted by file-size: `ls -lhS /path`
> -S sorts them. -lh gives a list with "human-readable" file-sizes.
Find the size of each item in a folder: `du -sm *`
You can sort them by adding: `du -sm * | sort -nr`
> You can add `-h`, but it won't sort correctly
To find the largest 20 files in a directory:
> `du -ah ./ | sort -rh | head -20`
Find the total size of a folder: `du -hs /foldername`
### Set script as startup
If, for some reason, apache isn't startup:
> `sudo update-rc.d apache2 defaults`
### Check a package version/info
> `dpkg -l matrix-synapse`
### See logs for services:
> `sudo journalctl -e -u matrix-synapse`
> (`-f` instead of `-e` to keep it running)
### Installing from tar.gz
Pure binaries:
> `sudo tar --directory=/opt -xvf .tar.[bz2|gz]`
> add the directory to your path: `export PATH=$PATH:/opt/[package_name]/bin`
#### More:
+ [Creating custom services](https://wiki.debian.org/systemd/Services)
## SSH
Copy files to/from an SSH connection: (SSH format: `user@host:/path` )
> `scp