0

I have some command I can run directly from the terminal:

my_command

and it runs well. However, I want to disable it to run this way. I know where it's located:

which my_command

and it gives me the location of the file of my_command. However, how do I figure out where is a symbolic link pointing to it and letting it run vai terminal without specifying the full path? Or a record in a file like ~/.bashrc. where else do I look for it?

I looked for a link or a record for my_command in /usr/bin and ~/.bashrc but didn't find anything. But it might also mean that I just couldn't find it.

1
  • which or whereis?? – Sukupa91 Nov 26 '13 at 8:55
4

I think you may be looking at the wrong way. The bash shell doesn't only look at /usr/bin but a entire set of directories:

echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/braiam/.rvm/bin

Your command either should be on one of the directories, or have a function/alias that calls it. For those cases you might prefer type:

$ type ls
ls is aliased to `ls --color=auto'
$ type jobs
jobs is a shell builtin
$ type apt-get
apt-get is /usr/bin/apt-get
2
  • I found the full path of my_command in echo $PATH. It's like some_custome_path/my_command. How do I remove it from there? – Oskar K. Nov 26 '13 at 8:45
  • @Grienders you better edit your question and include those details. Also, don't remove binaries of the PATH nor parts of the PATH, you don't know what might happen. Edit your question and include what my_command is, and where it's found. – Braiam Nov 26 '13 at 8:49
1

There are more directories than just /usr/bin getting searched for commands to run. The full list is saved in the $PATH variable. To see its contents, run echo $PATH.

Your script (or a symlink to it) should be in one of those directories.

UPDATE: Unfortunately, the $PATH variable can be set in any file sourced by the shell. Good places to start looking would be /etc/environment, /etc/profile, /etc/bashrc, ~/.bashrc and ~/.bash_profile. Also, some people recommend setting $PATH in /etc/X11/xsession.d/90environment, so checking there might help, too.

1
  • how do I edit $PATH once it found it there? – Oskar K. Nov 26 '13 at 8:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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