[SOLVED] Executing commands in local directory without directory path
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.
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150
Rep:
The current working directory is not normally part of the search path for comands, try
Code:
echo $PATH
To see what directorys get searched, if you want to run a command in the current directory without changing the PATH variable use "./" which is a releative path to the current directory so use
Glad to have been of service. As a service to others please mark this thread as [SOLVED]. You can use the Thread Tools menu located above your first post in this thread (see the attachment).
jdk
There is a very good reason why there is no current directory (.) in your $PATH
It is a potential security risk - although it would, of course, be comforting for people coming from windows to see that they could f**k up their system in a way that they were used to.
Back in the eighties it was common (normal?) to prepend $PATH with current directory. However this creates a security hole in that an executable file, in your home directory, with the same name as a system program could do all manner of nasty things. So we moved to putting the current directory at the end of the $PATH.
Then it was realised that there could still be problems, so for the past 20 - 25 years the advice has always been not to include current (or home) directory in $PATH - but to use ./ to reinforce that you consciously wish to use a local file.
Nothing wrong with having a bin directory within your home directory - in fact it's a good idea - but put it at the end of your $PATH
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.