Create a Custom Linux Command using "alias"


Aliases in Unix and Linux operating systems are cool. They let you define your own commands, or command shortcuts, so you can customize the command line, and make it work the way you want it to work. The alias command can be useful if you want to create a 'shortcut' to a command.
The format is alias name='command'
>alias web=' cd /home/lab/web '
This will create an alias called web which will put you in the /home/lab/web directory whenever you type web at the command prompt. Before creating an alias command make sure that you don't use the an alias name which resembles any bash command.
You can alias any command you want, and include options for the command.
>alias list='ls -la'
This will create an alias called list, which will use the ls command to print a long-style listing of all files in the current directory (the -l gives a long-style list, and the -a shows all files - including hidden files).

To see a list of aliases set up on your linux , just type alias at the prompt.
>alias
image

To remove any alias, use " unalias " command
AjSmart Tehnology geek

Sole blogger :(

No comments:

Post a Comment