Server Fault is a question and answer site for system and network administrators. 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

I was just wondering, i recently installed ack (ack-grep in ubuntu), and i can't figure out how to just type in ack to get ack-grep (for some reason ack is taken up by a kanji translator thing).

Is there a better way than just aliasing the thing in the shell (it is not global that way, and cannot evoke it in vim for example).

Thanks a lot!

share|improve this question
up vote 16 down vote accepted

You link or copy ack-grep to /usr/local/bin so that it gets prioritary in the PATH:

sudo ln -sf /usr/bin/ack-grep /usr/local/bin/ack

Or, like davey suggested, get rid of ack if you don't need it:

sudo apt-get remove ack

Another solution would involve using dpkg-divert to tell dpkg that you want all packages to have their /usr/bin/ack renamed locally and then link ack-grep to ack in the path.

share|improve this answer

In Ubuntu/Debian you can "divert" ack-grep:

sudo dpkg-divert --local --divert /usr/bin/ack --rename --add /usr/bin/ack-grep
share|improve this answer

The easiest thing to do is install ack via cpan. It will get installed in /usr/local/bin, which has precedence over /usr/bin. Just run:

sudo cpan App::Ack

or if you don't have the cpan client:

curl -L | perl - --sudo App::Ack
share|improve this answer
Didn't work for me on Ubuntu 10.04 LTS. Error message: "Don't be silly, you can't install daniel bosold". But sudo cpan -i App::Ack does. – geekQ Oct 10 '11 at 8:48
Thanks. Fixed now. – Naveed Oct 17 '11 at 2:51
Am I the only one who thinks this is not secure? – SaveTheRbtz Apr 22 '13 at 21:56

Least obtrusive:

alias ack=ack-grep

share|improve this answer
The question asks for something other than alias, correctly noting that this solution is pretty limited and can't help with shelling out from Vim or bash scripts. – Ian Greenleaf Young Dec 29 '14 at 21:33
@IanGreenleaf wow, you're right - embarrassing to see that 4 years later! Oops :/ – broady Jan 12 '15 at 6:02

Use the Debian Alternatives system.

$ update-alternatives --install /usr/bin/ack ack /usr/bin/ack-grep 100 \
--slave /usr/share/man/man1/ack.1p.gz ack.1p.gz /usr/share/man/man1/ack-grep.1p.gz

The command is tricky to get right, but the solution is superior to dpkg-divert for the following reasons:

  1. Does not force or override package installation
  2. Enables setting a slave link for the manpage

More info on Debian Alternatives here:

Installing the alternative enables invoking ack-grep as ack and reading the manpage using man ack.

share|improve this answer
This is the best answer IMHO! – Renaud May 6 '14 at 22:27
This is the "right" Debian/Ubuntu way to do this. – tgies May 7 '14 at 13:54

Assuming that the kanji translator is not already /usr/bin/ack and that its location is later in your path than /usr/bin, then you can probably do this:

sudo ln -sib /usr/bin/ack-grep /usr/bin/ack

This will prompt you to confirm the operation if the destination exists and creates a backup if you select yes.

share|improve this answer
Unfortunately the kanji ack lives in /usr/bin so if you can live without it: sudo apt-get remove ack – davey Dec 25 '09 at 8:23

i'd go with the symlink option as it saves the danger of transferring that alias to another machine if you copy your bash file.

go with this, works fine on my build of ubuntu 12.04

sudo apt-get install ack-grep
sudo ln -sf /usr/bin/ack-grep /usr/local/bin/ack
share|improve this answer

My solution is not so clean because it write in /bin/ but as long as /usr/bin/ack is a binary and not a symlink, was easier for me to fix this way.

sudo update-alternatives --install /bin/ack ack /usr/bin/ack 100
sudo update-alternatives --install /bin/ack ack /usr/bin/ack-grep 102

To choose which one to use

sudo update-alternatives --config ack
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.