Linux Commands Cheatsheet

Linux Commands Cheatsheet

Base64 encode

echo -ne "Text to encode" | base64

Base64 decode

echo VGV4dCB0byBlbmNvZGU= | base64 -d


echo VGV4dCB0byBlbmNvZGU= | base64 --decode

Bruteforce Form without Login

hydra -l '' -P /media/ravindra/Files/Computer_Science/GitHub/SecLists/Passwords/Leaked-Databases/rockyou-75.txt http-post-form "/:username=^USER^&password=^PASS^:Invalid password" -s 35805

Remove Empty Lines

sed '/^:space:*$/d'

Find and replace in one file.

sed -i -e 's/foo/bar/g'

Find and replace in many file.

cd /path/to/your/folder
sed -i 's/foo/bar/g' *

Find Commands Examples.

Optimize all jpeg files in current folder and subfolers

find . -type f -name "*.jp*g" -exec jpegoptim {} \;
find . -iname "*.jp*g"
  • .:current directory
  • -iname:name case-insensitive
find . -type d
  • -type:d= direcotory, f=files
find . -type f -perm 777
  • -perm:octal permission

MySQL login without root

Access MySQL Shell:sudo mysql -u root

drop user 'root'@'localhost';
create user 'root'@'%' identified by 'password';
grant all privileges on *.* to 'root'@'%' with grant option;
flush privileges;

Some Bash Stuff

Using #

  • As character counter
    myname="Ravindra Sisodia"
    echo "$myname is ${#myname} characters long"
  • In base conversion
    echo $(( 2#100 ))		# 4
    echo $(( 8#100 ))		# 64		
    echo $(( 10#100 ))		# 100
    echo $(( 16#100 ))		# 256

Using ,

  • For case conversion
    echo ${foo,}	# oNEtwo
    echo ${foo,,}	# onetwo


youtubel-dl <youtube-link>			# Download max quality.
youtubel-dl -F <youtube-link>		# List all available qualities.
youtubel-dl -f 22 <youtube-link>	# Select one from the list.

Swap related stuff

Check Swappiness

cat /proc/sys/vm/swappiness

Change Temporary

sudo sysctl vm.swappiness=10

Change Permanent

sudo vim /etc/sysctl.conf

Add this line in the end


Load changes from file

sudo sysctl --load=/etc/sysctl.conf

Change file watcher limit

sudo vim /etc/sysctl.conf
# Add following line
fs.inotify.max_user_watches = 524288

Turn of Swap

sudo swapoff -a

Turn on swap

sudo swapon -a

Original: Updated: