GIDForums  

Go Back   GIDForums > Computer Forums > Computer Software Forum - Linux
User Name
Password
Register FAQ Members List Calendar Today's Posts
 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 18-Jun-2003, 10:29
Allowee's Avatar
Allowee Allowee is offline
Regular Member
 
Join Date: May 2003
Location: The Netherlands
Posts: 339
Allowee has a spectacular aura about

[Linux] How to run a program under another username


normally I use KDE under the user 'Allowee'

but I've setup a username called 'pmsys-cvs' for my PMS Project

I want to edit the scripts in KDE so I need to run my editor as 'pmsys-cvs'
how am i going todo that?

I guess i need to use 'sudo' for that and put 'pmsys-cvs' in my sudoers list.

I always whatch out when I want todo something with permissions...
__________________
Pastebin
PHP Documentation Site
Allowee's Blog http://allowee.net
  #2  
Old 18-Jun-2003, 10:35
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,370
JdS will become famous soon enough
You know this is exactly what I plan to do next... figure out CVS. I know this doesn't help you much but when you have the time, could you perhaps post a little tutorial on using CVS?

Then we can exchange notes someday... Meanwhile, I hope someone has an answer for you.
__________________
J de Silva

GIDApp | GIDBlog | GIDForums | GIDNetwork | Learning Journal
  #3  
Old 18-Jun-2003, 12:53
Div's Avatar
Div Div is offline
Moderator
 
Join Date: May 2002
Posts: 997
Div has a spectacular aura aboutDiv has a spectacular aura about
Try,

su pmsys-cvs
__________________
Web Hosting Tips | Career Advice
  #4  
Old 19-Jun-2003, 07:26
Allowee's Avatar
Allowee Allowee is offline
Regular Member
 
Join Date: May 2003
Location: The Netherlands
Posts: 339
Allowee has a spectacular aura about
Quote:
Originally posted by Div
Try,

su pmsys-cvs

hmm, can't get that to work....

I created a shortcut and put 'pmsys-cvs' in the user box...
then it prompts for my password...

i've put the pmsys-cvs user in the sudoers file with 'NOPASSWD' but it still doesn't work without a password
__________________
Pastebin
PHP Documentation Site
Allowee's Blog http://allowee.net
  #5  
Old 23-Jan-2004, 09:09
dsmith's Avatar
dsmith dsmith is offline
Senior Member
 
Join Date: Jan 2004
Location: Utah, USA
Posts: 1,351
dsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of lightdsmith is a glorious beacon of light
First off, unless I am mistaken it is not possible to have a user without a password (I thought the password limit was at least 5 characters), but I may be mistaken.

Second a few comments on the use of su. Most of the times, you will want to call su with a -. This will bring the environment settings for this user along.

Code:
su - username

Note: to su as root, no username is needed.

su will always prompt for a password, unless you are root. However, running as root is not recommended.

Another switch of su that I find handy is the -c switch. This will run a program/application as that user. For instance:

Code:
su -c make install

will run the make install script as root and then return to the calling user when done.

Finally, to call X applications after doing an su to another user needs some other settings. First you need to make your X server accept connections from another machine. You will need to do this even if you are making a connection as another user to the same machine.

Code:
xhost client_name

client_name can be a name or an ip address. Likely entries for a local machine can be localhost or 127.0.0.1. If you are going to do this alot, you may want to put this into a startup script, as every time that your computer is started, this needs to be redone.

Finally, you need to give instructions to the client to send its output to the designated X server. I have a script file that I store under /usr/local/bin/term that does this. (/usr/local/bin is in the search path, therefore scripts stored under here can be called from anywhere.)

Code:
export DISPLAY=$1:0.0 /opt/kde/bin/konsole -caption $2 --ls &

This would be called after doing an su - with two parameters. The first being the location of the X server and the second being the name of the konsole window.

Code:
term localhost name@localhost

This will bring up a konsole dialog shell with the caption of "name@localhost" I like to put a name on there, so I can identify these in my X session. Now if you type in an X command at this shell, ie "kwrite file", it will pull up right there.

The coolest thing about all this, is that this can be done from machine to machine as well. For example, I have 3 Linux boxes at my work. I can sit at the same machine with X server and run all three of them. The processing, applications and everything are being done on the other machines, but the display is all exported to the machine at my desk.

Therefore, to run a remote machine as root on my local X server, I would issue these commands from my local X server.

Code:
xhost client_name ssh client_name su - {type in password} term client_name root@client_name

Note, that the term script needs to be in the client machines /usr/local/bin or somewhere else in its search path.
 



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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Linux] Finding a runaway or locked program JdS Computer Software Forum - Linux 2 21-Jan-2004 16:00
Help with calendar program mike3340 C++ Forum 0 18-Nov-2003 21:25
error during program rjd72285 C++ Forum 0 11-Nov-2003 19:49
How to write simple program like ........? laputa9000 C++ Forum 3 29-Oct-2003 13:09
one program access another? dgoulston C++ Forum 1 07-Oct-2003 11:26

Network Sites: GIDNetwork · GIDApp · GIDBlog · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 06:40.


vBulletin, Copyright © 2000 - 2018, Jelsoft Enterprises Ltd.

Warning: mysql_real_escape_string(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /gidstuff/other/BadBot.inc.php on line 403

Warning: mysql_real_escape_string(): A link to the server could not be established in /gidstuff/other/BadBot.inc.php on line 403

Warning: mysql_real_escape_string(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /gidstuff/other/BadBot.inc.php on line 416

Warning: mysql_real_escape_string(): A link to the server could not be established in /gidstuff/other/BadBot.inc.php on line 416

Warning: mysql_real_escape_string(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /gidstuff/other/BadBot.inc.php on line 421

Warning: mysql_real_escape_string(): A link to the server could not be established in /gidstuff/other/BadBot.inc.php on line 421