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
3 years ago
This would work if sudo were part of the default install – but it isn’t.
4 years ago
How do I give the pi user root access