Long sophisticated instructions are usually not solely tough to recollect but in addition take a lot of time to be typed. When it’s a must to use them on day by day foundation, you turn into annoyed when typing them repeatedly and again… So, ‘alias’ are extra appropriate for lengthy and complex commands.
Let’s think about an example.
To find the top 10 largest files in your system, you can set the next ‘alias’:
alias top10files=”find . -type f -exec ls -sh {} \; | sort -n -r | head -10”
You can even combine different instructions with ‘alias’. As an illustration, if you happen to often use ‘tail’ and direct its output to file to later view that file, you may set a very simple ‘alias’ to do this cumbersome operation in 1 word:
alias Tail=”tail /var/log/messages > hello.txt;cat hello.txt”
Now just enter ‘Tail’ and voila! All is done at once.
You need to use any file with tail and direct its output and you’ll even use ‘nano’ or ‘vi’ to view/edit its output.
Here’s one other example… ‘alias’ to connect to a remote server:
alias any_name=”ssh -l -p ”
You possibly can even create ‘alias’ on your bash scripts, like:
alias clc=”sh /home/user/myscripts/calc.sh”
Now that you have set a number of totally different ‘alias’ you may want to test that which ‘alias’ are set in your system. To do that, simply difficulty the next command:
alias
and it will list all the set ‘alias’ you have.
To remove an ‘alias’, just issue the ‘unalias’ command, like:
unalias Google
and now typing Google in Terminal will do nothing (as it was set with lynx).
To remove all the ‘alias’, issue the following command and all the ‘alias’ are gone:
unalias -a
We have mentioned the way in which of setting the ‘alias’ for different sorts of commands. However setting ‘alias’ in this approach be temporary. While you reboot you PC, all the ‘alias’ which you will have set will probably be gone. This does not mean that it’s a must to set all of the ‘alias’ each time you boot your PC. You probably have set an ‘alias’ and you favored it a lot that you really want it to completely reside in you PC, simply add this alias in ‘.bashrc’ file in you dwelling directory. For example, if you would like ‘alias’:
Set up <software_name>
to permanently reside in your PC then user your favorite text editor and add the following line in your ‘~/.bashrc’ file:
alias Install=”sudo apt-get install”
Now this ‘alias’ will not vanish into thin air when you reboot your PC. Only those ‘alias’ which are listed in ‘~/.bashrc’ file will be permanent.
This information is just a preview about ‘alias’. It’s just about primary ways of using ‘alias’ to make your life simpler. ‘GNU alias’ is a instrument which can simplify your life immensely. But sadly this device isn’t given the attention it deserves. Briefly, it is such a strong tool that when you give it proper time, it could possibly make you overlook typing.

Like this:
Like Loading...