Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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

In Ubuntu 11.04 or 10.04, how can I make the apt-get, apt-cache all in one myapt so that I can simply use one only, like in Fedora?

For example:

myapt search yum   # same as apt-cache search
myapt remove yum   # same as apt-get remove
myapt install yum  # same as apt-get install

Any idea how to do alias for this?

share|improve this question
up vote 9 down vote accepted

You could create a script with the following content


command="$1"; shift

case $command in
    apt-cache "$command" "$@"
    apt-get "$command" "$@"

Suppose you call it myapt. Then, to still having the benefit of bash completion, you need to add the following lines to ~/.bashrc:

_myapt() {
  return 0
} &&
complete -F _myapt $filenames myapt

Unfortunately $command should precede any options, but seems that bash completion do not works for options that follow command.

share|improve this answer

I'm not sure you can use alias for that, but you could use bash to create a script.
Now I'm no bash scripter, so I wouldn't be able to tell you the exact code for accomplish that, but what you could do is something like (this is just pseudocode, sort of, so don't expect it to work!!!):

var action
var input
get action, input
  if action == search
    then do apt-cache search input
  if action == remove
    then do apt-get remove input
  if action == install
    then do apt-get install input

Keep in mind you can write the script (or even a compiled application) in what ever language you are comfortable with, such as python or ruby for example, it does not have to be bash.

Again, remember my example is just pseudocode.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.