Create aliases for frequent commands Print

  • 0

For DevOps and System Engineers it is convenient to create aliases for frequent commands like updates or checks.

It is also fun to make your own alias commands.

How to create a alias command:

alias search=grep

Now you can type search instead of grep via your terminal:

search 'Host' Apache.conf

Some alias commands that will save your time:

alias update='yum update'
alias show-da-updates='cd /usr/local/directadmin/custombuild/ && ./build update && ./build versions 
 alias da-updates='cd /usr/local/dirctadmin/custombuild/ && ./build update && ./build versions && ./build update_versions 

Extra BASH documentation:

If you have used UNIX for a while, you will know that there are many commands available and that some of them have very cryptic names and/or can be invoked with a truckload of options and arguments. So, it would be nice to have a feature allowing you to rename these commands or type something simple instead of a list of options. Bash provides such a feature : the alias .
Aliasses can be defined on the command line, in .bash_profile, or in .bashrc, using this form :
This means that name is an alias for command. Whenever name is typed as a command, Bash will substitute command in its place. Note that there are no spaces on either side of the equal sign. Quotes around command are necessary if the string being aliassed consists of more than one word. A few examples :
The first example ensures that ls always uses color if available, that dotfiles are listed as well,that directories are marked with a / and executables with a *. To make ls do the same on FreeBSD, the alias would become :
To see what aliasses are currently active, simply type alias at the command prompt and all active aliasses will be listed. To "disable" an alias type unalias followed by the alias name.

Was dit antwoord nuttig?

« Terug