After logging in as user pi, using this command give you root user privileges:

sudo su

Exiting root user mode

Use the exit command:

exit

or su username:

su pi

sudo In GUI

If you are developing programs which use the IO pin from the GUI you do not have to use "sudo startx" to launch the GUI. Using "sudo ./myprogram.a" in a LX Terminal window works fine.

Running a command as another user

If you are running as the root user (e.g. say within an app called with sudo because you are using the IO pins) you may want to make command lines calls as the standard pi user.  You can change to a different user using su – USERNAME -c before the command and surrounding it with quotes.


su - pi -c \"fetchmail > /dev/null\"

Enabling The Root Account

By default the root account is disabled, but you can enable it by using this command and giving it a password


sudo passwd root

Now you can log into your pi as the root user.  Whilst this opens up security concerns its sometimes very useful, for instance when developing with netbeans and remotely running applicaiotn that access the IO pins.

If it doesn't work check the ssh config


sudo nano /etc/ssh/sshd_config

Search for PermitRootLogin and change it to yes

You can undo logging in as root again using this command


sudo passwd -l root

 

 





USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.

Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.