Sponsored Content
Top Forums Shell Programming and Scripting switching between root and a normal user Post 302115102 by srikanthus2002 on Saturday 21st of April 2007 07:02:19 AM
Old 04-21-2007
If you have sudo facility in your system

you can do like this

Code:
sudo "command"    #executed as root

"command"           #executed as normal user (if you log in as normal user)

"command"

sudo "command"    # again executed as root

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Other than root user .Normal user is unable to create files

Hi all, I am using Sun Solaris 9 .In this system normal users unable to create files from the command line.I added these users in bin,adm and even root group i found them unable to create a file. (1 Reply)
Discussion started by: mallesh
1 Replies

2. Shell Programming and Scripting

switching user from root to ordinary user

Good day Guys!!! I am currently making a script in AIX, the script runs a SAS job, the owner of the script is the root, but the SAS jobs cannot be run by the root, as it should be run by a user 'sasia'. But inside the script, root creates a logfile, so what I need is just to su to sasia for the... (3 Replies)
Discussion started by: sasia
3 Replies

3. Shell Programming and Scripting

su root from normal user

Got a cron to run everyday under my user. this cronjob runs a script from my /home/jack/scripts/run.sh clear # # su to root and run a script, return with result # su - # passwd # run /getfile.sh # return with result # the result will copy 2 files from /prod/app/logs/ and... (0 Replies)
Discussion started by: karthikn7974
0 Replies

4. Shell Programming and Scripting

How a normal user run a script including root privileaged commands

Dear all Ihave written a script in Hpux9.0, the ecript is working fine if I run it from root command prompt But when I am running it thru /etc/profile or /user/.profile and login as a normal user, the owner of the process running the script is the normal user & hence cant run a root privileaged... (7 Replies)
Discussion started by: initin
7 Replies

5. Shell Programming and Scripting

root user command in shell script execute as normal user

Hi All I have written one shell script for GPRS route add is given below named GPRSRouteSet.sh URL="www.google.com" VBURL="10.5.2.211" echo "Setting route for $URL for GPRS" URL_Address=`nslookup $URL|grep Address:|grep -v "#"|awk -F " " '{print $2}'|head -1` echo "Executing ... (3 Replies)
Discussion started by: mnmonu
3 Replies

6. Shell Programming and Scripting

Execute Root command as Normal user

Hi, We need to execute a root commmand to change the expiry period of a user but we are getting error as permission denied Q How can we execute a root command by a normal user ? :mad: any thing or suggestion will be good .... :b: (3 Replies)
Discussion started by: abhishek1979
3 Replies

7. Solaris

java version mismatch for normal user and root user

:confused: I installed latest version of java ( jre 1.6) on Solaris Machine ......when I run java -version as root, shows the latest version but when I run java -version as normal user, shows the old / previous version What should I do to fix this ...should show the latest version... (3 Replies)
Discussion started by: frintocf
3 Replies

8. UNIX for Dummies Questions & Answers

Execute a command as root from normal user

Hi , I am trying to stop and start a process using the below code. I have sudo access on my machine ## PID = process id echo "$PASSWD" | sudo -S kill -9 <PID> echo "$PASSWD" | sudo -S /opt/abc/startserver /opt/abc/startserver: error while loading shared libraries: librts.so: cannot open... (6 Replies)
Discussion started by: rakeshkumar
6 Replies

9. UNIX for Dummies Questions & Answers

Switching from root to normal user takes me to user's home dir

Whenever i switch from root to another user, by doing su - user, it takes me to home directory of user. This is very annoying as i want to be in same dir to run different commands as root sometimes and sometimes as normal user. How to fix this? (1 Reply)
Discussion started by: syncmaster
1 Replies

10. Shell Programming and Scripting

Will Chkconfig works for normal user apart from root user

Hi, I am trying to schedule a script that starts on reboot.I came across chkconfig utility to schedule scripts on reboot. Problem here is can i how to use this chkconfig to schedule a script that runs a s normal user. Or if there is any other function to schedule on reboot as normal user... (4 Replies)
Discussion started by: praveena kotapa
4 Replies
NFSTEST.HOST(1) 						nfstest.host 1.0.1						   NFSTEST.HOST(1)

NAME
nfstest.host - Host module DESCRIPTION
Provides a set of tools for running commands on the local host or a remote host, including a mechanism for running commands in the back- ground. It provides methods for mounting and unmounting from an NFS server and a mechanism to simulate a network partition via the use of 'iptables'. Currently, there is no mechanism to restore the iptables rules to their original state. CLASSES
class Host(baseobj.BaseObj) Host object Host() -> New Host object Usage: from nfstest.host import Host # Create host object for local host x = Host() # Create host object for remote host y = Host(host='192.168.0.11') # Run command to the local host x.run_cmd("ls -l") # Send command to the remote host and run it as root y.run_cmd("ls -l", sudo=True) # Run command in the background x.run_cmd("tcpdump", sudo=True, wait=False) .... .... # Stop command running in the background x.stop_cmd() # Mount volume using default options x.mount() # Unmount volume x.umount() Methods defined here: --------------------- __init__(self, **kwargs) Constructor Initialize object's private data. host: Hostname or IP address [default: localhost] user: User to log in to host [default: ''] server: NFS server name or IP address [default: None] nfsversion: NFS version [default: 4] minorversion: NFS minor version [default: 1] port: NFS server port [default: 2049] export: Exported file system to mount [default: '/'] mtpoint: Mount point [default: '/mnt/t'] datadir: Data directory where files are created [default: ''] mtopts: Mount options [default: 'hard,rsize=4096,wsize=4096'] interface: Network device interface [default: 'eth0'] nomount: Debug option so the server is not actually mounted [default: False] iptables: Iptables command [default: '/usr/sbin/iptables'] sudo: Sudo command [default: '/usr/bin/sudo'] mount(self, **kwargs) Mount the file system on the given mount point. server: NFS server name or IP address [default: self.server] nfsversion: NFS version [default: self.nfsversion] minorversion: NFS minor version [default: self.minorversion] port: NFS server port [default: self.port] export: Exported file system to mount [default: self.export] mtpoint: Mount point [default: self.mtpoint] datadir: Data directory where files are created [default: self.datadir] mtopts: Mount options [default: self.mtopts] Return the mount point. network_drop(self, ipaddr, port) Simulate a network drop by dropping all tcp packets going to the given ipaddr and port using the iptables commands. network_reset(self) Reset the network by flushing all the chains in the table using the iptables command. run_cmd(self, cmd, sudo=False, dlevel='DBG1', msg='', wait=True) Run the command to the remote machine using ssh. There is no user authentication, so remote host must allow ssh connection without any passwords for the user. For a localhost the command is just executed and ssh is not used. The object for the process of the command is stored in object attribute 'self.process' to be used by methods wait_cmd() and stop_cmd(). The standard output of the command is also stored in the object attribute 'self.pstdout' while the standard error output of the command is stored in 'self.pstderr'. cmd: Command to execute sudo: Run command using sudo if option is True dlevel: Debug level for displaying the command to the user msg: Prefix this message to the debug message to be displayed wait: Wait for command to complete before returning Return the standard output of the command and the return code or exit status is stored in the object attribute 'self.returncode'. stop_cmd(self, process=None, dlevel=None, msg='') Terminate command started by run_cmd() by calling wait_cmd() with the 'terminate' option set to True. process: The object for the process of the command to terminate, or terminate all commands started by run_cmd() if this option is not given dlevel: Debug level for displaying the command to the user, default is the level given by run_cmd() msg: Prefix this message to the debug message to be displayed Return the exit status of the last command sudo_cmd(self, cmd) Prefix the SUDO command if effective user is not root. umount(self) Unmount the file system. wait_cmd(self, process=None, terminate=False, dlevel=None, msg='') Wait for command started by run_cmd() to finish. process: The object for the process of the command to wait for, or wait for all commands started by run_cmd() if this option is not given terminate: If True, send a signal to terminate the command or commands and then wait for all commands to finish dlevel: Debug level for displaying the command to the user, default is the level given by run_cmd() msg: Prefix this message to the debug message to be displayed Return the exit status of the last command Static methods defined here: ---------------------------- get_ip_address(host='', ipv6=False) Get IP address associated with the given host name. This could be run as an instance or class method. SEE ALSO
baseobj(1) BUGS
No known bugs. AUTHOR
Jorge Mora (mora@netapp.com) NFStest 1.0.2 10 April 2013 NFSTEST.HOST(1)
All times are GMT -4. The time now is 02:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy