LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 12-09-2002, 06:44 PM   #1
windowsrefugee
LQ Newbie
 
Registered: Dec 2002
Posts: 4

Rep: Reputation: 0
Question 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.
 
Old 12-09-2002, 06:50 PM   #2
Thymox
Senior Member
 
Registered: Apr 2001
Location: Plymouth, England.
Distribution: Debian + Ubuntu
Posts: 4,358

Rep: Reputation: 57
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
 
Old 12-09-2002, 06:55 PM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,361
Blog Entries: 55

Rep: Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547
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.
 
Old 12-09-2002, 06:59 PM   #4
windowsrefugee
LQ Newbie
 
Registered: Dec 2002
Posts: 4

Original Poster
Rep: Reputation: 0
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
 
Old 12-09-2002, 07:02 PM   #5
windowsrefugee
LQ Newbie
 
Registered: Dec 2002
Posts: 4

Original Poster
Rep: Reputation: 0
Thanks unSpawn. You answered my revised questions before i'd finished typing them.
 
Old 12-09-2002, 07:03 PM   #6
windowsrefugee
LQ Newbie
 
Registered: Dec 2002
Posts: 4

Original Poster
Rep: Reputation: 0
can anyone help on the superuser rights issue?....
 
Old 12-10-2002, 01:17 PM   #7
Azrael
Member
 
Registered: Sep 2002
Location: Germany
Distribution: SuSE 8.0
Posts: 96

Rep: Reputation: 15
Have a look at sudo, it's written to allow executing programs as other users, in your case as root.
 
Old 12-10-2002, 01:38 PM   #8
NSKL
Senior Member
 
Registered: Jan 2002
Location: Rome, Italy ; Novi Sad, Srbija; Brisbane, Australia
Distribution: Ubuntu / ITOS2008
Posts: 1,207

Rep: Reputation: 46
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
 
Old 12-10-2002, 01:41 PM   #9
mhearn
LQ Guru
 
Registered: Nov 2002
Location: Durham, England
Distribution: Fedora Core 4
Posts: 1,565

Rep: Reputation: 47
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).
 
Old 12-10-2002, 01:43 PM   #10
mhearn
LQ Guru
 
Registered: Nov 2002
Location: Durham, England
Distribution: Fedora Core 4
Posts: 1,565

Rep: Reputation: 47
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.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
2 questios.... ftp and antivirus kuplo Linux - Newbie 4 11-28-2005 11:48 PM
script batch linux cetoute14 Linux - General 5 09-02-2005 08:37 PM
questios about isp116x_tango ustc_embedded Linux - Hardware 0 08-04-2004 12:16 PM
the questios begin:battery icon bearbigears Linux - Laptop and Netbook 6 05-14-2004 02:24 PM
Linux Batch Files sfnitro230 Slackware 13 03-09-2004 03:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:25 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration