I want to login as a different user in Gnome and not to run a single program only, but I don't know the users password, I don't want to know it and I don't want to change it, but I'm sudoer.

Is there any way to do so?

The best thing I could think, was to change the user's password but to keep the old shadow file. But this seems to me very ugly and also uncomfortable. I'm also not sure if it's a good idea to change the shadow file on a running machine (but I suppose so, otherwise vipw -s would kind of useless).

Is there an alternative?

The reason I want to achieve this, is that I'd like to test things or to configure programs for users who aren't able to do on their own. Yeah of course I could do everything on the shell als root or as the specific user (and acutally this is what I'm doing until now), but there are things that you definitly don't want to do on the shell. Did any of you ever try to change the position of the gnome-panel on the shell instead of just selecting "bottom"? :)

I don't think gksudo, sudo or su would help me. I want to have the whole gnome session.



Create a ghost user, with the same UID:

target: user1 (change to suit)

cat /etc/passwd | grep user1
user1:x:1001:1001:User1 Q Lastname:/home/user1:/bin/bash

add your ghost

sudo useradd -d /home/user1 -f -1 -u 1001 -g 1001 -M -o ghost1 -s /bin/bash -p MySecret

cat /etc/passwd | grep user1
user1:x:1001:1001:User1 Q Lastname:/home/user1:/bin/bash

su ghost1

NOTE: You can delete, with 'sudo userdel ghost1', but NOT when either account is logged in. Failsafe method: delete the new line in '/etc/passwd' file.

  • Yeah, this is great! :) Might be conseridered as dirty hack too but not so ugly - actually I find this quite beautiful and creative... So I could store permanently a user ghost and then I'd have to adjust only UID and home directory to login. But can I be sure that there are no possible conflicts if UID (or the home directory?) is not unique? Also there is the danger that some programs might use the user name of the logged in user to store things or so. This could mess up config files horrible... Actually when thinking through it, I'm afraid... – lumbric Dec 21 '11 at 15:43
  1. Become root

    sudo -i
  2. As root, sudo to the other user

    su other_user

If you want to run X applications, take a look at xhost

  • How can I change the gnome-panel's position by using su or sudo? (without grawling around gconf or any xml files) – lumbric Dec 20 '11 at 20:24

I'm not sure if this is the best way, but here's an option I've just tested, and works on natty although I don't have an extra user set up so I'm not totally sure:

sudo Xorg :1

(in another terminal)

sudo -i
su - username
x-session-manager --display :1

Then Ctrl-Alt-F8 and you should find the new session. It might not be exactly same as logging in normally, but I'm pretty sure it'll let you rearrange panels as much as you like.

Use Ctrl-Alt-F7 to return to your original session. If those F-keys don't work for you, try others.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.