*NIX Commands Corner

Currently as WIP, but enjoy :)

Contents


1. Shell commands

Hide user prompt in CLI (and revert it)

export PS1="$ "

To revert the change you can simply execute the shell variable, e.g. for Bash:

exec "$BASH"

(reference)

Show binary output of a file's hexdump

xxd file.png | xxd -r

(reference)

Get contents from within xml tag

grep -oP '(?<=<essid).*?(?=</essid>)' out-01.kismet.netxml | grep -oP '(?=>).*' | cut -c2- | sort -u

Replace recursively with sed

grep -rl oldtext /path/to/the/files | xargs sed -i 's/oldtext/newtext/g'

(reference)


2. Download files

Simple wget command to download a webpage and it's subpages

wget -r --level 2 --random-wait --no-clobber --page-requisites --execute robots=off --html-extension --convert-links --no-parent https://acrid-vein.neocities.org

(reference)

Download audio files with youtube-dl

youtube-dl --extract-audio --audio-format best -o "%(title)s.%(ext)s" -i dQw4w9WgXcQ

It also works with playlists, bear in mind you can insert video id or the URL.

(reference)

3. Miscellaneous

Find patterns with grep (without piping command)

grep "div" $(find /var/www/html -name "*.html")

(reference)

Mount Veracrypt encrypted device

veracrypt -t -k "" --pim=0 --protect-hidden=no /dev/sdX /media/veracrypt -v

(reference)