--- title: "Useful Commands" visible: true --- [toc] ## Imagemagick ### Splitting PDF files ```sh convert -density 600 {INPUT.PDF} -crop 50x100% +repage {OUT.PDF} ``` ``` -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 ### Change filtered permissions Using find with its `exec` switch one can set different permissions based on the usual find filters. One example would be only changing file or directory permissions. ```sh find (directory) -type f -exec chmod 744 {} + ``` Replacing `-type f` with `-type d` would execute the `chmod` for directories instead. ## Various ### Overwrite disk with pseudorandom data Using openssl on CPUs with AES acceleration one can create pseudorandom data with high speeds. 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} ``` Around 2GiB/s on my Ryzen 7 1700x if output to `/dev/null` ### Formatted csv in terminal > [From Pretty CSV viewing on the Command Line](https://www.stefaanlippens.net/pretty-csv.html) ```sh column -t -s, < {FILE.CSV} ``` ### 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 ``` ### Find USB speed in use First, the USB device you want to check has to be selected [shuser] ```sh lsusb Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 003 Device 003: ID 0c45:652f Microdia Backlit Gaming Keyboard Bus 003 Device 002: ID 046d:c084 Logitech, Inc. G203 Gaming Mouse Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 002: ID 0781:55a3 SanDisk Corp. SanDisk 3.2Gen1 Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 002: ID 2972:0047 FiiO Electronics Technology FiiO BTR5 Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub ``` [/shuser] Now, using the ID, the USB class used can be determined [shuser] ```sh lsusb -d 0781:55a3 -v | grep bcdUSB bcdUSB 3.20 ``` [/shuser]