wiki-grav/pages/04.other/useful-commands/default.en.md

62 lines
1.5 KiB
Markdown
Raw Normal View History

---
title: "Useful Commands"
visible: true
---
[toc]
2023-02-19 11:02:44 +01:00
## Imagemagick
2023-02-19 11:02:44 +01:00
### Splitting PDF files
2023-02-19 11:02:44 +01:00
```sh
convert -density 600 {INPUT.PDF} -crop 50x100% +repage {OUT.PDF}
2023-02-19 11:02:44 +01:00
```
```
-density: adjusts the quality of the resulting pdf. Higher values look better, but take longer to process
-crop 50x100%: this splits the pdf into "left" and "right". 100x50% would split into "top" and "bottom"
```
## Find
2023-02-19 11:02:44 +01:00
### Change filtered permissions
2023-02-19 11:02:44 +01:00
Using find with its `exec` switch one can set different permissions based on the usual find filters.
2023-02-19 11:02:44 +01:00
One example would be only changing file or directory permissions.
```sh
find (directory) -type f -exec chmod 744 {} +
2023-02-19 11:02:44 +01:00
```
Replacing `-type f` with `-type d` would execute the `chmod` for directories instead.
2022-10-18 20:43:26 +02:00
## Various
2023-02-19 11:02:44 +01:00
2022-10-18 20:43:26 +02:00
### Overwrite disk with pseudorandom data
2023-02-19 11:02:44 +01:00
2022-10-18 20:43:26 +02:00
Using openssl on CPUs with AES acceleration one can create pseudorandom data with high speeds.
2023-02-19 11:02:44 +01:00
Much faster than `/dev/urandom` at least
```sh
openssl enc -aes-128-ctr -md sha512 -pbkdf2 -nosalt -pass file:/dev/urandom < /dev/zero | pv > {TARGET DISK}
2023-02-19 11:02:44 +01:00
```
Around 2GiB/s on my Ryzen 7 1700x if output to `/dev/null`
2022-10-18 20:43:26 +02:00
2022-10-23 20:44:13 +02:00
### Formatted csv in terminal
2022-10-23 20:51:00 +02:00
2023-02-19 11:02:44 +01:00
> [From Pretty CSV viewing on the Command Line](https://www.stefaanlippens.net/pretty-csv.html)
```sh
column -t -s, < {FILE.CSV}
2023-02-19 11:02:44 +01:00
```
### Download directory from webdav
Using `wget`, it's possible to download directories recursively from WebDAV.
```sh
wget -r -nH -np --cut-dirs=1 --user={USERNAME} --password={PASSWORD} https://WEBDAVHOST/DIR/DIR
2023-02-19 11:02:44 +01:00
```