Admin-Ahead Community

Linux => General Linux => Topic started by: jamesj on July 05, 2017, 09:06:57 pm

Title: To set up command aliases (permanently)
Post by: jamesj on July 05, 2017, 09:06:57 pm
Alias name for command can be set up using .bashrc file
.bashrc file is located in your user directory

For example if it is user who want change it, then it would be under
/home/user/.bashrc

For root user it would be
/home/root/.bashrc


Here’s the basic format
alias aliasname='commands'

Add the following to .bashrc file


alias ll='ls -lah'
alias p='pwd'
alias g='ping google.com'

No space should be made before and after the equal-to(=)sign

save and quit.

Log out and log in back to check if the alias is working or not.
You can also do source ~/.bashrc to have an immediate effect on the alias used

 # source ~/.bashrc

------------------------------------------------------------------------------------------------------------------------------------

# g
PING google.com (172.217.26.206) 56(84) bytes of data.
64 bytes from maa03s23-in-f14.1e100.net (172.217.26.206): icmp_seq=1 ttl=56 time=16.4 ms
64 bytes from maa03s23-in-f14.1e100.net (172.217.26.206): icmp_seq=2 ttl=56 time=15.4 ms

#p
/home/user

------------------------------------------------------------------------------------------------------------------------------------