Thursday, February 22, 2018

Alias command in Ubuntu 16,linux Teacher Sourav,Kolkata 09748184075

aliases can be any name other than reserved word ,it can even be same name as a command with different options,aliases can be applied on global basis or per user basis


for global basis we have to modify the file
called /etc/bashrc

for user basis the file is 
/home/username/.bashrc

let's create a custom command


the alias command will show you the already set aliases

set a alias

alias ls='ls -l'

now using the alias command you will see 
the new alias set

when we use ls using the alias it will run 
ls -l

we can perform the same thing 

by changing df to df -h

alias df='df -h'

h is for human readable format,the output of df will be shown in human readable format by default from now instead of block sizes



now let's create a command which does not exist


alias delete='rm -i'

by defining the alias delete will be available to bash will also help in tab complition when typing delete

these aliases are also going to available to shell scripts

to remove the alias

unalias delete

to make these aliases permanenet we have to aliases to the /etc/bashrc(for parmanent) or /home/username/.bashrc for just the user

No comments:

Post a Comment