LinuxMoz

Linux Stuff && Coffee

Bash Alias Example

| Comments

A Bash alias is often used for commands with a long option list that you use regularly and want to save yourself some time typing or reading the man file each time you wish to run the command.

A good example of this (for me) would be nmap, I often run nmap scans against boxes, and I have memorised the options I use, to save myself some time I might create the following bash alias:

Bash Alias Example

I would normally run a scan using:

1
nmap -sS -sV -P0 host

So I could create the following Bash alias:

1
alias nmap1='nmap -sS -sV -P0'

Now I can use the command:

1
nmap1 hostname

The above will run a scan on a host and it will execute nmap -sS -sV -P0.

Aliases are limited to a simple textual shortcut, if you need more power use a bash function instead.

Comments