Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Command line
- ------------
- # Get the first argument of the previous command. This is a readline thing.
- [Ctrl]+[Alt]+Y
- File
- -----
- Count the number of commas (,) in a text file: .tr -cd , < file.txt | wc -m #
- grep -n "search term" -r . | cut -d ":" -f 1 # extract the paths of a grep output and use them further...
- find . -name '*.pdf' -exec pdftotext {} - \; | grep "search term" # grep multiple pdf files
- file .* * # List all files in the current directory, and describe their contents.
- mkdir ". " && cd ". " && touch FILE # put as many spaces as you want after dot. Hiding files in Linux
- Encryption
- ----------
- echo "Uryyb jbeyq" | tr '[A-Za-z]' '[N-ZA-Mn-za-m]' # Perform ROT13 on a string.
- Password
- --------
- dd if=/dev/random bs=16 count=1 2>/dev/null | base64 | sed 's/=//g' # Generate a secure password with 128 bits of entropy.
- Edit file
- ---------
- sed '/^\#/d' in_file > out_file # get rid of lines starting with # (aka comments)
- Networking
- ----------
- tar -cz folder | ssh username@destinationhostname "cat >output.tgz" | Archive 'folder' onto a different computer.
- Web
- ---
- Curl
- ----
- # see where a URL shortener points
- curl -s -D - -o /dev/null http://bit.ly/frXy3V | grep -i ^location:
- curl -s "http://download.finance.yahoo.com/d/quotes.csv?s=aapl&f=l1 …" # View current stock price for AAPL
- curl -LIN "$URL" # See HTTP response headers and any redirects for $URL
- Wget
- ----
- wget -O /dev/null http://speedtest.wdc01.softlayer\.com/downloads/test10.zip # Check broadband speed
- wget -r -l 1 -A pdf ftp://ftpserver/pub/documents/ # download all .pdf files from an ftp server
- Desktop
- -------
- # site shot from command line. By
- xvfb-run --server-args="-screen 0, 1024x768x24" cutycapt --url=http://url --out=image.png
- Networking
- ----------
- # Show the network calls of the ping command.
- strace -s 200 -e trace=network -f ping -c1 4.2.2.2
- # route port 80 to default or custom port
- ltunnel(){ port=3000; sudo ssh -L 80:localhost:${1-$port} $(whoami)@localhost }
- Netcat
- ------
- nc -z example\.com 22 # Check if port 22 is listening on http://example.com
- Logfiles
- --------
- tail error_log continuously and add extra newline. May help with readability when lines are long.
- tail -f error_log |awk '{print $0 "\n"}'
- # sort and rank who is using sudo
- egrep -o "sudo:\s+\S+\s+:" /var/log/secure | sort | uniq -c | sort -g
- OpenSSL
- -------
- openssl enc -aes-256-cbc -salt -in yourfile -out yourfile.enc # Encrypt yourfile with a password without the need for gpg.
- Apache
- -------
- # Only view the active configuration in a heavily commented httpd.conf file.
- egrep -v "(^#|^\ *$)" httpd.conf | less
Advertisement
Add Comment
Please, Sign In to add comment