Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 10-19-2013, 07:51 AM   #1
Registered: Oct 2013
Posts: 37

Rep: Reputation: Disabled
Permissions in shell script.

Hello, guys!
I'm using Debian Wheezy 7.1 and i'm writting a simple shellscript to do some initial configurations in my system when i will install it, but i'm having a problem. Some configurations i have to do as superuser and some not. I don't want to make two shellscripts, so i would like to know how can i make my script do some things as superuser and some things as normal user.
I dont want to use sudo, by the way.
In Google i found some tutorials but all they use sudo!
I've tried this:

echo 'Starting.'
echo 'Im super user'
echo 'Im a normal user.'
Thank You.

Last edited by robgeek; 10-24-2013 at 03:14 PM.
Old 10-19-2013, 09:16 AM   #2
Senior Member
Registered: Aug 2009
Distribution: CentOS
Posts: 3,399

Rep: Reputation: 1486Reputation: 1486Reputation: 1486Reputation: 1486Reputation: 1486Reputation: 1486Reputation: 1486Reputation: 1486Reputation: 1486Reputation: 1486
There are several reasons why that way is not going to work. It would be much easier to start the script as super user. Then you can easily use su to run some commands as another user without needing a password:

su - otheruser -c "pwd  #this runs as otheruser"

If you want to run commands as "otheruser" but still in root's environment (current directory, exported variables, ...), just use "su otheruser ..." in place of "su - otheruser ..."
1 members found this post helpful.


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
[SOLVED] bash shell script -checking permissions ? connect2janu Programming 5 04-04-2012 02:28 AM
Executing a Shell script with 654 permissions inside another shell script. changusee2k Linux - Newbie 2 06-07-2011 07:58 PM
file permissions in bourne shell script bujecas Linux - General 2 07-12-2006 11:46 AM
How can I write a shell script to transfer files and keep permissions? LancerNZ Linux - Wireless Networking 0 02-24-2005 12:19 AM
Listing permissions with shell script Ollir Programming 1 10-18-2004 06:50 AM

All times are GMT -5. The time now is 09:07 AM.

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