Handy Ubuntu Shortcuts

This page is intended to be updated as and when we come across handy Ubuntu commands useful for general Linux usage.

Process Management

$ ps ax | grep pastehunter
$ pkill -9 -f pastehunter.py

Retrieve WAN address

$ curl icanhazip.com


$ grep -rnw . -e 

Unzip multiple files into folders named the same as the zip file:

$ find -name '*.zip' -exec sh -c 'unzip -d "${1%.*}" "$1"' _ {} \;

Password reset procedure

  • Restart VM/machine while holding down shift
  • Select option with … (recovery mode)
  • Select root option
  • Hit Enter again
  • Run these commands:
    • mount -n -o remount,rw /
    • passwd [username]
  • Enter new password when prompted, restart

Making Bash Script Exectuable from Terminal

Create new file in text editor:

$ nano whatismyip

Add the following:

curl icanhazip.com

The second line will be the command you want to execute. In this case, it will run “curl icanhazip.com”

Change permissions of file to make it executable

$ chmod u+x whatismyip 

Move to your local bin directory

$ sudo mv whatismyip /usr/local/bin/.

Try your cmd

$ whatismyip

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s