Let's say I want to create an alias called ss
for the command sudo -s
. But ss
is already an existing command, so I want to create another alias called sst
for the command ss
.
If using just the normal command names, this is not possible, since aliases:
- Are not set in a way that respects the order, and
- Reference other aliases, instead of only referencing commands
So if I try the following:
alias sst='ss'
alias ss='sudo -s'
Running the command sst
results in running sudo -s
, which is not my intention.
How can this be done?
For the above to work, you need to reference the absolute path of the command you want to run.
The can be done with the following:
However, one can't always be sure
ss
is at that location, so a more solid approach would be:Now the above works as expected, where
ss
runssudo -s
andsst
runs the commandss
.