Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then 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.
Alright guys; I need help. I cannot run any scripts unless su. What could be the problem. The error I get is command not found. I do not think it is a permission problem; I set ifconfig to 777 and still no go.
Distribution: tried a lot of 'em, now using kubuntu
Posts: 180
Rep:
If you are talking about scripts that are not in your PATH statement, then you must preceed them with either the full path name , OR, change into the directory where they are located, then preceed it with a ./
For instance, I run Debian. My scripts are located in "/etc/init.d" If I want to start my Apache webserver, I can do it two ways
OK that was the problem, thanks! Now what do I do to run these scripts so that I do not have to navigate to the root directory every time? Would copying to my home ~ directory work? Or is this a bad idea for some reason. Is there some reasoning behind the file hierarchy being structured as such?
When you su - (don't forget the " -" or this won't work) it adds /sbin to your PATH environment variable. That's why you are suddenly able to execute the scripts from root without going to the actual directory.
When you make a script, some distributions will save it either as root or as a user. Sometimes the permission or the ownership of the directory will also stick with files underneath the directory. If you want to run scripts as a user, you need to change the ownership of the file. Assuming that file is set to be a script. First su. Then chown user_namescript_file_name.
You could add ~/bin in to the PATH of .bashrc for every user or thier .bashrc. This will give them a directory that they can store scripts. You need to create the directory first.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.