Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: To set up command aliases (permanently)  (Read 1352 times)

0 Members and 1 Guest are viewing this topic.

jamesj

  • Guest
To set up command aliases (permanently)
« 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

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





« Last Edit: July 05, 2017, 09:09:24 pm by jamesj »