My cheat sheet for commands I have trouble remembering.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3.4 KiB

cheat-sheet

My cheat sheet for commands I have trouble remembering.

Converting Emails

EML to MBOX using eml2mbox (email2mbox-git on AUR)

cd /path/to/eml/files
eml2mbox

This creates .archive.mbox.

MBOX to HTML Threads using Mhonarc (mhonarc on AUR)

cd /path/to/.archive.mbox/file
mhonarc .archive.mbox

This creates threads.html and extracts all information into the directory.

Find and copy files by extension recursively

find . -name '*.pdf' -exec cp -r {} /home/jpickard/pdffiles \;

7-Zip compression (p7zip)

7z a archivename.7z thingtobearchived

Recursively unzip

while [ "`find . -type f -name '*.zip' | wc -l`" -gt 0 ]; do find -type f -name "*.zip" -exec unzip -- '{}' \; -exec rm -- '{}' \;; done

Merge PDF files

Ghostscript

gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=mergedfile.pdf -dBATCH file1.pdf file2.pdf

ImageMagick

convert file1.pdf[0-1] file2.pdf mergedfile.pdf

Convert webp to JPG/PNG

dwebp mycat.webp -o mycat.png

ExifTool

List metadata of image

exiftool image.jpg

Remove metadata of image

exiftool -all= image.jpg /or/ exiftool -all= *.jpg

Recursively, overwriting the files

exiftool -overwrite_original -recurse -all= *.jpg

UFW

Examples

ufw status numbered
ufw delete 2
ufw allow from 192.168.1.10 to any port 22 proto tcp
ufw allow in on tailscal0 to interfaceip port 22 from otherdeviceip
ufw reset

List ports Linux is listening on

sudo lsof -nP -iTCP -sTCP:LISTEN

List alive IPs on Network (nmap)

sudo nmap -n -sn 192.168.56.0/24 -oG - | awk '/Up$/{print $2}' | sort -V

Mount NFS Share (nfs-common or nfs-utils)

sudo mount -t nfs 10.10.0.10:/backups /var/backups

/etc/fstab

# <file system>     <dir>       <type>   <options>   <dump>	<pass>
10.10.0.10:/backups /var/backups  nfs      defaults    0       0

Merge video files with ffmpeg

$ cat files.txt
file 'file 1.mkv'
file 'file 2.mkv'
file 'file 3.mkv'
file 'file 4.mkv'

ffmpeg -f concat -safe 0 -i files.txt -c copy output.mkv

Windows

List usernames on machine

net user

Change user password

net user username newpassword

Disconnect from network drives/directories

net use * /del (Then restart service Workstation and check Credential Manager)

Create Directory and hide it

mkdir Pickard
attrib +s +h Pickard

List Printers from CMD

wmic printer list brief

Data Recovery

ddrescue

Take an image of a drive and log:

sudo ddrescue /dev/sdb path/to/image.dd path/to/log.txt

Clone Disk A to Disk B:

sudo ddrescue --force --no-scrape /dev/sdA /dev/sdB path/to/log.txt