Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Yes, the way Linux manages executables is much different than in MS-DOS (I'm assuming that this is where you're coming from). In Linux, you can only execute commands that are in certain directories, such as /bin, /sbin, /usr/bin. These directories are contained in the PATH variable. You can see this list by typing:
$ echo $PATH
This makes it very easy to execute commands from wherever you are in the directory tree without having to cd to the directory that contains the executable, or having to type out the whole path name. If you want to execute a command that is not in one of these designated directories, you have to type the absolute path name (eg /usr/program/myprogram or ./myprogram, if you are in /usr/program already). While this might seem like an inconvenience, it prevents you from accidentally executing files in the current directory when you really wanted to execute a generic system command. For example, it prevents someone from creating a trojan named "ls" which would be run whenever you wanted to use the ls command. It also prevents commands from behaving differently depending on which directory you are in.
Thanks so much for the answer! I've been reading about Symbolic Links, which is another new topic that seems related.
For example, when I installed firefox I put it in /usr/firefox. To run the firefox program, rather than adjusting the PATH variable to add /usr/firefox or having to cd /usr/firefox and then run ./firefox, I could create a symbolic link in /usr/bin for firefox?
You could edit your user .bashrc or .bashrc_profile (different distros have different names for it) to add an alias. Such as: alias firefox="/usr/firefox". Then, everytime you boot up, the command is available to you by simply typing firefox and pressing enter.
To make such an alias available to all users, edit the /etc/bashrc to add the alias there. Be adivsed that, on upgrading your distro, the system bashrc may be overwritten, in which case you could loose all of your aliases. In other words, keep a backup copy, which you can then cut and paste your aliases into a changed bashrc.
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088
Rep:
You can always change your PATH variable though. For example, if you wanted to have a bin directory in your home, you would add the following line to .bash_profile:
Code:
export PATH=$PATH:/home/iball/bin
If you want to be able to execute programs in the current directory, (NOT generally a good idea, ,particularly for root), add the following line to .bash_profile
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.