Ubuntu: Find a symbolic link or a record in “~/.bashrc” for a file



Question:

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.


Solution:1

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  


Solution:2

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.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »