Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Let's say I have an alias like this:

alias findip='wget -q -O -|sed -e 's/.*Current IP Address: //' -e 's/<.*$//''

the output would look like this:

matthew@ubuntu:~$ findip

So pretty simple, it finds my ip address by connecting to the website and looking for my IP address. Now, if i were to run:

tsocks wget -q -O -|sed -e 's/.*Current IP Address://' -e 's/<.*$//'

I would get an output like this:

matthew@ubuntu:~$ tsocks wget -q -O -|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'

You will notice that the IP addresses are different. This is because I routed the command through tsocks, which I have configured to use tor. But if I were to run:

tsocks findip

My output would be this:

matthew@ubuntu:~$ tsocks findip
exec: 87: findip: not found

My output

How do I configure my system so that the aliases created apply when I am running through tsocks?

share|improve this question
up vote 2 down vote accepted

Alias a command to itself, and end the alias with a space:

alias exec="exec "
alias sudo="sudo "
alias tsocks="tsocks "

With this, bash will automatically expand tsocks findiptsocks wget -q ...

As seen in bash's documentation:

$ help alias
alias: alias [-p] [name[=value] ... ]
    A trailing space in VALUE causes the next word to be checked for
    alias substitution when the alias is expanded.

This, however, is not related to being root (unless you were talking about sudo usage), and cannot be done at exec() syscall level (aliases are entirely internal to bash).

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .