Skip to content

Instantly share code, notes, and snippets.

@defvol
Last active January 23, 2018 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save defvol/ecddd5643743c1e0f0e336e9e38558f2 to your computer and use it in GitHub Desktop.
Save defvol/ecddd5643743c1e0f0e336e9e38558f2 to your computer and use it in GitHub Desktop.
List of useful commands
# handy linux commands
# get video card specs
lshw -C video
lspci | grep -i vga
# distro specs
uname -m && cat /etc/*release
# distro name
% lsb_release -cs
xenial
# packages (drivers) installed
dpkg -l | grep nvidia
# mounted partitions
df -h
# summary of disk space used by directories
du -hs *
# most recent sys messages
dmesg | tail
# connected devices
lsusb
lsusb -d vendorId:productId -v
# nyancat
nc -v nyancat.dakko.us 23
# watch memory every 5s
watch -n 5 free -m
# make a GIF from a screencast
ffmpeg -i mem-01.ogv frames/ffout%03d.png
convert -loop 0 frames/ffout* mem-01.gif
convert mem-01.gif -fuzz 10% -layers Optimize optimized.gif
# gif to mp4 and viceversa
ffmpeg -f gif -i infile.gif outfile.mp4
# ogv to mp4
ffmpeg -i out.ogv -strict -2 out.mp4
# from png to pdf
convert grid.png -gravity center grid.pdf
# clip video
ffmpeg -i take-3.mp4 -ss 00:00:03 -t 00:02:04 output.mp4
# crop a video
ffmpeg -i in.mp4 -filter:v "crop=out_w:out_h:x:y" out.mp4
# speed up a video
ffmpeg -i take-4.mp4 -filter:v "setpts=0.5*PTS" take-4-faster.mp4
# timelapse a video
ffmpeg -i input.mp4 -r 1 -f image2 frames/%05d.png
ffmpeg -i frames/%05d.png timelapse.mp4
# resize video
ffmpeg -i larger.mp4 -filter:v scale=720:-1 -c:a copy smaller.mp4
# resize image
convert IMG_2000.jpg -resize 1024x IMG_2000_resized.jpg
# remove audio from video
ffmpeg -i loud.mp4 -c copy -an muted.mp4
# pull video metadata
exiftool take.mp4
# extract audio from a youtube URL
youtube-dl https://www.youtube.com/watch?v=tN12Tg5ttpk -f mp4
ffmpeg -i ytcracker\ -\ meganerd-tN12Tg5ttpk.mp4 meganerd.mp3
# play mp3 from the cli
ffplay ~/Music/meganerd.mp3
mplayer ~/Music/meganerd.mp3
# Sort ‘ps’ output by memory (RAM), from high to low
ps aux --sort -rss
# connect to VPN from the cli
nmcli con up id sub.kewlvpn.lol
# check avail networks
nmcli con
# incognito
firefox --private-window
chromium-browser --incognito &
# record action
cnee --record -o automate-this.xnr --mouse --events-to-record 1000 --time 2
cnee --replay -f automate-this.xnr --time 2
# adding password to PDF
pdftk [mydoc].pdf output [mydoc.128].pdf owner_pw [foo] user_pw [baz]
# docker (remove/stop all containers)
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
# docker (remove all images)
docker rmi $(docker images -q)
# compress directory
tar -zcvf archive-name.tar.gz directory-name
# encryption
gpg -c filename
aescrypt -e "File"
zip --encrypt file.zip.enc file # prompt for password
# git - updating author
git rebase -i -p <commit-to-start-from>
git commit --amend --author="John Snow <jsnow@thewall.com>"
# git - get latest commit id
echo $(git log --format="%h" -n 1)
# delete all containers named mongo
docker rm $(docker ps -a | grep mongo | cut -f 1 -d' ')
# delete all node_module directories recursively
find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +
# rotate a screen
# https://askubuntu.com/questions/95812/how-can-i-rotate-my-display-in-the-most-easy-way
xrandr --output HDMI-1 --rotate inverted
# delete old files
rm $(ls -lh *csv | grep "Dec 18" | cut -d' ' -f11)
# find process running on a port
ss -lptn 'sport = :3000'
@defvol
Copy link
Author

defvol commented Nov 26, 2017

Removing vbox disks
VBoxManage closemedium disk 633a54a5-c3c0-4330-b371-9d448ae28c4c
VBoxManage closemedium disk 7ef3723f-e960-4e68-9b8c-ef8d65b1474b
https://myshittycode.com/2013/11/23/virtualbox-failed-to-delete-the-storage-unit-of-the-hard-disk-pathhard-disk-vdi-cannot-close-medium-pathhard-disk-vdi-because-it-has-n-child-media/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment