LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   first batch of linux questios (https://www.linuxquestions.org/questions/linux-newbie-8/first-batch-of-linux-questios-37771/)

windowsrefugee 12-09-2002 05:44 PM

first batch of linux questios
 
Hey.

I'm a recent linux convert, and loving it. But I have a couple of very basic questions, if anyone could help me out... (I programmed on Solaris a couple of years ago but have forgotten most of it!)

firstly setting PATH is flummoxing me. I've read that in bash you:
export PATH=$PATH:/other/paths

but this isn't working for me. if I have this in a file called setpath and then
# ./setpath

my PATH is unchanged afterwards, but if I directly
# export PATH=$PATH:/other/paths

then it is set correctly. Why doesn't it work in a file. I've tried putting in that comment directive (what's it properly called) i.e.
#!/bin/bash

but I guess this is what the shell would use anyway. I've also explicitly
#bash ./setpath

which doesn't work. What am i doing wrong?

Also I have a Speedtouch USB modem, which to connect requires execution of programs in /sbin. I would like to be able to execute this for normal users (at the moment I briefly log in as root, execute a script, and logout to connect). How can I either safely programmatically aquire root priveliges, or allow non-priveliged users to call some programs in /sbin, or /usr/sbin and so on?

Sorry this is so long.

Thymox 12-09-2002 05:50 PM

Welcome to LQ.

2: Why don't you change the properties of the program (file) to be executed? man chmod should detail some useful stuff.

HTH

unSpawn 12-09-2002 05:55 PM

1. but this isn't working for me. if I have this in a file called setpath and then
# ./setpath

my PATH is unchanged afterwards, but if I directly
# export PATH=$PATH:/other/paths


That's because the "./sh" part means executing another shell (child) to do export. Child variables aren't inherited by it's parent.
If it's for yourself, place the export with the others in ~/.bash_profile, if it's going to be system-wide it goes in /etc/profile.

windowsrefugee 12-09-2002 05:59 PM

I've already used chmod to set the owner rights to rwx.

I guess a different way of phrasing the first question is - what does the shell do when it's given just a filename? Does it treat that in the same way as input on the command line (then why can't I set PATH)? Does it spawn another instance of bash? (In which case are environment vars like PATH shared between all running instances of bash?) Is there any difference between
#./setpath
and
# bash ./setpath

Thanks

windowsrefugee 12-09-2002 06:02 PM

Thanks unSpawn. You answered my revised questions before i'd finished typing them.

windowsrefugee 12-09-2002 06:03 PM

can anyone help on the superuser rights issue?....

Azrael 12-10-2002 12:17 PM

Have a look at sudo, it's written to allow executing programs as other users, in your case as root.

NSKL 12-10-2002 12:38 PM

If you already set correct permissionon /sbin and /sbin/programs-you-need make sure /sbin is in user's PATH as well, since by default it is not. But a much more secure solution would be using SUDO.
If you want more info about bash, check http://www.digitaltoad.net/docs/guid...ell/index.html
HTH
-NSKL

mhearn 12-10-2002 12:41 PM

windowsrefugee:

1) when you create a script file, ie:

#!/bin/sh
export PATH=$PATH:/some/other/path

and run it, this will not affect the path because a new shell is spawned, the PATH is set then the shell quits and the changes to the environment are lost. To run commands as if they had been typed in, run

source ./myscript .... or
. ./myscript ..... which is the same thing but shorter

2) Are you sure the programs actually require root? /sbin/programname as user will tell you this. If they do require root, then you can setup sudo to make things convenient for you, you can type:

sudo command

and it'll execute as root (once you've authenticated)

Learn to use vi, then run visudo as root. Add these lines:

Defaults timestamp_timeout=-1
root ALL=(ALL) ALL

Don't bother reading the manpage for sudo, it's truly stunningly awful, those lines should do the trick (make sure there's a tab between the first column and the others).

mhearn 12-10-2002 12:43 PM

Ooop, that should of course be:

mike ALL=(ALL) ALL

replace mike with your username. Place those two lines *after* the root ALL=(ALL) ALL line.

The Defaults line will stop sudo forgetting that you've given it a password after 5 minutes. Less security, more convenience. You decide.


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