Below are lists of various commands for niche areas. This information is harder to find on the internet, and thus it is compiled here. This information applies mostly to Linux, but additionally to some UNIX systems.
Miscilaneous
- Generate random strings from
/dev/urandom
tr -dc 'A-Za-z0-9!"#$%&'\''()*+,-./:;<=>?@[]^_{|}~' </dev/urandom | head -c 13 ; echo
- Write output to file and stdout
<command> | tee <out>
- Run command for a certain ammount of time –
x
is time in secondstimout <x> <command>
- Wrire file to clipboard
xclip -sel c < <file>
- Write stdout to clipboard
<command> | xclip -sel c
Shell Shortcuts
Shortcut | Action |
---|---|
!! |
Access last item in history |
!n |
Access n item in history |
!:n |
Access command run n commands ago |
!* |
Reuse arguments from last command |
!:n* |
Reuse arguments from command n commands ago |
!$ |
Access last argument from last command |
!:n$ |
Access last argument from n commands ago |
!:s/search/replace/ |
Run last command w/ search and replace |
File Conversion
- Extract pages of pdf
qpdf <in>.pdf --pages . <start>-<stop> -- <out>.pdf
- Page range syntax can be either
a,b,c
ora-c
for pages a, b, and c.
- Page range syntax can be either
- Example
qpdf bio.pdf --pages . 24-38 -- bio-ch1.pdf
- Concatenate
qpdf <in>.pdf --pages . <in2>.pdf <in3>.pdf <...> -- <out>.pdf
- Example
qpdf bio-ch1.pdf --pages . bio-ch2.pdf bio-ch3.pdf -- bio-section1.pdf
- Convert from image to pdf
convert <in> <out>.pdf
- Example
convert scan.jpg scan1.pdf
Images
- Resize image
convert <in> -resize <width>x<height> <out>
- Example
convert galaxy.jpg -resize 1280x720 galaxy-small.jpg