Skip to content

Instantly share code, notes, and snippets.

@MIvanchev
Last active September 19, 2023 12:24
Show Gist options
  • Save MIvanchev/3fe2728cf007ab6f340692108c765329 to your computer and use it in GitHub Desktop.
Save MIvanchev/3fe2728cf007ab6f340692108c765329 to your computer and use it in GitHub Desktop.
Random Linux snippets
# Get the amount of data written so far to the SSD /dev/sda (assumes a sector size of 512 byteas)
#
sudo smartctl -a /dev/sda | grep Total_LBAs_Written | sed 's/.*[ \t]\([0-9]*\)$/\1 * 512/' | bc | numfmt --to=iec --suffix=B
# Proper turn off procedure for the HDD /dev/sdb
#
sudo udisksctl unmount -b /dev/sdb
sudo udisksctl power-off -b /dev/sdb
# 7-Zip a folder and password protect files and file names.
#
7z a /media/backup/stuff.7z ~/stuff/ -mhe=on -p
# Open a TrueCrypt volume (creates a new device in /dev/mapper for normal mounting)
#
sudo cryptsetup --type tcrypt open /dev/sdb1 sdb1
# Create a PNG screenshot of X11 (including Xvfb)
#
DISPLAY=:1 xwd -root -silent | convert xwd:- png:~/Pictures/screenshot.png
# Copy a file from a Docker image to host
#
docker cp $(docker create --name foo <tag>):<file> <host-file> && docker rm foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment