Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # vim: ft=markdown
- # Read randomly generated CLI tips wget -qO - http://www.commandlinefu.com/commands/random/plaintext | sed -n '1d; /./p'
- # get all bookmarks from all profiles from firefox
- `"SELECT strftime('%d.%m.%Y %H:%M:%S', dateAdded/1000000, 'unixepoch', 'localtime'),url FROM moz_places, moz_bookmarks WHERE moz_places.id = moz_bookmarks.fk ORDER BY dateAdded;"; done`
- # Encrypt your file using RC4 encryption
- `hashkey=`echo -ne <your-secret> | xxd -p`; openssl rc4 -e -nosalt -nopad -K $hashkey -in myfile.txt -out myfile.enc.txt`
- # Block an IP address from connecting to a server
- `iptables -A INPUT -s 222.35.138.25/32 -j DROP`
- # View details of network activity, malicious or otherwise within a port range.
- `lsof -i :555-7000`
- # Rename files in batch
- `rename 's/^hospital\.php\?loc=(\d{4})$/hospital_$1/' hospital.php*`
- # oneliner to transfer a directory using ssh and tar
- `tar cvzf - dir | ssh my_server 'tar xzf -'`
- # Mac OS X (laptops ??) only : control hibernation state more easily from Terminal.app
- `sudo pmset -a hibernatemode 1`
- # Inverted cowsay
- `echo Which way up? | flip.pl | cowsay | tac | sed -e "s,/,+,g" -e "s,\\\,/,g" -e "s,+,\\\,g" -e "s,_,-,g" -e "s,\^,v,g"`
- # Compare directories (using cmp to compare files byte by byte) to find files of the same name that differ
- ```bash
- find . -maxdepth 1 -mindepth 1 -print0 | xargs -0 -n 1 -I % cmp % /DUPDIR/% 2>/dev/null
- ```
- # Downloads files (through wget) from a list of URLs using a stored cookie
- `wget --load-cookies <cookie-file> -c -i <list-of-urls>`
- # Adding Prefix to File name
- `rename 's/^/CS749__/' *.pdf`
- # Merge only certain pdfs in a directory
- `gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=merged.pdf -dBATCH `ls | grep foo``
- # Use md5 to generate a pretty hard to crack password
- `echo "A great password" | md5sum`
- # list files recursively by size
- `stat -c'%s %n' **/* | sort -n`
- # Show amicable path
- `alias path='echo $PATH | tr ":" "\n"'`
- # Tool for generating system resource statistic
- `dstat`
- # Create a tar of directory structure only
- `tar -cf ~/out.tar --no-recursion --files-from <(find . -type d)`
- # Debug pytest failures in the terminal
- `pytest --pdbcls pudb.debugger:Debugger --pdb --capture=no`
- # Extract raw URLs from a file
- `egrep -ie "<*HREF=(.*?)>" index.html | awk -F\" '{print $2}' | grep ://`
- # Display the top ten running processes - sorted by memory usage
- top -b -o +%MEM |head -17
- # Snmpwalk a hosts's entire OID tree with SNMP V3 with SHA Authentication and with Privacy
- snmpwalk -v3 -On -u <user> -l AuthPriv -a SHA -A <auth_password> -X <encryption_password> -m ALL <HOST_IP> .
- # Human readable docker stats output
- docker stats --no-stream $( docker ps -q ) | sed -e "$( docker ps --format "{{.ID}} {{.Names}}" | sed -e "s/\(.*\) \(.*\)/s\/\1\/\2\t\/g;/" )"
- # Realtime delay effect
- arecord -D plughw:1,0 | play -d echos 0.3 0.2 700 0.25 800 0.3
- # Rename files in batch
- rename 's/^hospital\.php\?loc=(\d{4})$/hospital_$1/' hospital.php*
- # list size and directies in curretn folder
- du -sh ./*/
- # PulseAudio: set the volume via command line
- pactl set-sink-mute 0 false ; pactl set-sink-volume 0 +5%
- # Android PNG screenshot
- adb exec-out screencap -p > screenshot.png
- # Find a CommandlineFu users average command rating
- curl -s www.commandlinefu.com/commands/by/PhillipNordwall | awk -F\> '/num-votes/{S+=$2; I++}END{print S/I}'
- # transpose a file
- awk '{ for (f = 1; f <= NF; f++) a[NR, f] = $f } NF > nf { nf = NF } END { for (f = 1; f <= nf; f++) for (r = 1; r <= NR; r++) printf a[r, f] (r==NR ? RS : FS) }'
- # list all directory sizes and sort by size
- du -ks * | sort -nr | cut -f2 | xargs -d '\n' du -sh
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement