LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 07-18-2003, 07:19 AM   #1
odious1
Member
 
Registered: Jun 2003
Location: Virginia, USA
Distribution: Slackware
Posts: 252

Rep: Reputation: 30
cannot run scripts unless su


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.

Ideas??

Thanks!
 
Old 07-18-2003, 07:34 AM   #2
peeples
Member
 
Registered: Sep 2002
Location: Wichita Falls, TX
Distribution: tried a lot of 'em, now using kubuntu
Posts: 180

Rep: Reputation: 30
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

/etc/init.d/apache

OR


cd /etc/init.d
./apache


HTH

Last edited by peeples; 07-18-2003 at 07:35 AM.
 
Old 07-18-2003, 07:59 AM   #3
odious1
Member
 
Registered: Jun 2003
Location: Virginia, USA
Distribution: Slackware
Posts: 252

Original Poster
Rep: Reputation: 30
that was the problem

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?

Tom
 
Old 07-18-2003, 08:01 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,568

Rep: Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865
The users path does not include /sbin. So you can run ifconfig using its full path i.e. /sbin/ifconfig.

You can modify your users path. Just edit your .bash_profile

FYI:
To see your path:
echo $PATH

linux is different from windows in that when you type in a command it doesn't search the current directory just the path.
 
Old 07-18-2003, 01:59 PM   #5
Rumblefish
Member
 
Registered: Jun 2003
Location: Delaware
Distribution: Redhat 7.0, 7.2, 8.0, 9.0, FreeBSD 4.6.2
Posts: 51

Rep: Reputation: 15
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.
 
Old 07-19-2003, 12:25 AM   #6
Electro
LQ Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
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_name script_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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
new scripts won't run new2me Linux - Newbie 4 06-09-2005 09:14 AM
How to? Run Shell scripts jmr0311 Mandriva 2 07-14-2004 09:24 PM
How to run .sh scripts piggysmile Linux - Software 2 06-24-2004 06:18 AM
How do i get scripts to run? jihadcman Fedora 3 06-06-2004 10:15 AM
how do you run scripts toejam Linux - General 5 05-24-2004 08:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration