anishh2003
Posts: 9
Joined: Thu Aug 09, 2012 9:40 am

how to switch to user

Tue Dec 11, 2012 2:01 pm

Hi
I have my raspberry pi teminal at
[email protected] pi:/home/pi#

would someone tell me how to change it to
[email protected]~$


An

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5856
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: how to switch to user

Tue Dec 11, 2012 2:04 pm

You can 'exit' to get back to the login screen, or you can run 'su pi' to switch to the user pi, I think. I would 'exit' since it's the more secure option.

SkyRise
Posts: 179
Joined: Tue Jan 24, 2012 1:20 pm

Re: how to switch to user

Tue Dec 11, 2012 2:06 pm

You're logged in as user 'root' and have navigated to /home/pi

To switch to the 'pi' user, use:

Code: Select all

su pi
This will stay in the same directory as it maintains the current environment

Code: Select all

su - pi
will switch user to 'pi' but will re-read the users environment (and will automatically go to the users home directory)

Apologies, I know that makes hard reading...

W. H. Heydt
Posts: 10749
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: how to switch to user

Tue Dec 11, 2012 7:18 pm

Since I don't know how you got to be logged in as root, I want to add a bit to the previous posters advice...

If you logged in directly as root, then you can logout and log back in as pi. Or you can use "su - pi".

If you initially logged in as pi then used su (or, possibly, sudo su) to change to root, then you can simply log out from root and you'll revert to pi.

anishh2003
Posts: 9
Joined: Thu Aug 09, 2012 9:40 am

Re: how to switch to user

Wed Dec 12, 2012 3:01 pm

Hi
Thanks for the replies .
I did log in intially as pi user , and then used sudo .
However I am experiencing this error when I give startx in pi user :
xauth :timeout in locking authority file /home/pi/.Xauthority

but am able to run startx in root .

Please tell me how to fix this problem
I have tried these 2 commands as well :
sudo apt-get update
sudo apt-get upgrade

User avatar
terrycarlin
Posts: 70
Joined: Thu Jun 14, 2012 10:42 pm

Re: how to switch to user

Wed Dec 12, 2012 4:38 pm

I am guessing you did a startx as root (sudo) in your pi home directory. /home/pi.
The startx command probably created some files in your pi home directory. If so, when you do a startx as pi, it cant use those files as they are owned by root.

log in as pi, make sure you are in /home/pi and try this command:
<DANGER> If you do this command somewhere other than /home/pi you could really screw up your RPi's OS. </DANGER>

Code: Select all

sudo chown -R pi *
This should make pi the owner of all files in that directory tree.

A slightly safer thing to do would be to do a

Code: Select all

ls -l
in the pi home directory and change the ownership of any file owned by root to pi. ie:

Code: Select all

sudo chown pi .Xauthority
You have to use sudo in this case as some of the files could be owned by root.
Remember, when running as root or doing a sudo command there are no safety checks.
It assumes that you know what you are doing.
If it ain't broke, take it apart and see how it works.

Return to “General discussion”