8

I can' t use the command route:

route
bash: route: command not found

Why is it not found? (I'm using debian 9).

I tried to run it as root but it still does not work. However it is supposed to work also without root.

Additional diagnostics:

whereis route
route:

which route (empty output).

export PATH=$PATH:/sbin (no output) and nothing changes.

I already have iproute2 installed, to be sure I ran:
apt --reinstall install iproute2

21
  • Do you see it if you do sudo -i instead? Nov 2, 2018 at 11:34
  • 3
    The fact that you have two very different answers already is indicating that this question is far too broad. This amounts to an "It doesn't work!" question, and such questions are poor. Really, people cannot tell why things are happening as they are without pertinent information about what your account is, what your PATH is, and why you think that you even have a route command in the first place on a package-based operating system. None of that is in the question as it stands.
    – JdeBP
    Nov 2, 2018 at 11:38
  • I ran it as root
    – Scorpion
    Nov 2, 2018 at 11:38
  • 1
    /sbin/ is not always in path for normal user, but is for root. If you'd shown the value of your $PATH variable, that would have avoided the irrelevant answers.
    – JigglyNaga
    Nov 2, 2018 at 12:04
  • 1
    Notice that the differences from that to yours are the very ones that I mentioned. That question gave people the value of PATH and what user account was being used right from the start, in the question.
    – JdeBP
    Nov 2, 2018 at 14:14

3 Answers 3

17

The "command not found" error means you don't have the command installed.

Using Debian's "search the contents of packages" page brings up:

...
/sbin/route     net-tools [not powerpc]
....

So (providing your CPU isn't PowerPC) you should install the net-tools package.

3
  • 2
    How can this answer be correct, when root can run the command? Nov 3, 2018 at 11:18
  • @ctrl-alt-delor The OP wasn't very clear -- by "I ran it as root", I believe they meant "I entered route as root, and still got the same error", not "it runs when I try it as root".
    – JigglyNaga
    Nov 3, 2018 at 11:41
  • @JigglyNaga "I ran it as as root" means I ran route as a root user, pretty simple. Because one told me to run it as root (sudo -i).
    – Scorpion
    Nov 4, 2018 at 14:25
12

You need install package net-tools.

0
3

The /sbin isn't in your PATH, use:

$ /sbin/route

or :

$ export PATH=$PATH:/sbin
$ route

You can add the above command to your .bashrc:

echo "export PATH=$PATH:/sbin" >> .bashrc
source .bashrc

The net-tools provide the route command. Reading the output of route command doesn't require a special right.

5
  • How can i check? If i use /sbin/route i get: bash: /sbin/route: No such file or directory.
    – Scorpion
    Nov 2, 2018 at 11:37
  • 1
    And also export PATH=$PATH:/sbin didn't work.
    – Scorpion
    Nov 2, 2018 at 11:37
  • First nothing, second route:
    – Scorpion
    Nov 2, 2018 at 11:42
  • Are you using the same machine, for all your your tests?: First it is installed, then it is not, then it is already installed, then not. Nov 3, 2018 at 11:20
  • @ctrl-alt-delor yes same machine, the package already installed is another.
    – Scorpion
    Nov 4, 2018 at 14:29

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