SuperUser Login


8 posts
by claire1642 » Fri Jun 22, 2012 6:05 pm
I am using debian 2.6.32 i think?

I am trying to do this hello world thing i found on a beginners forum but i cant write to the file i made as i cant log in as superuser. i type su and no password and it says authentication failure. Iv tried many other combinations too but no joy.

whats the UN and Password for SU?

(I just did a weeks course on suse but its not helped me at all!!)

Thanks
Claire
Posts: 3
Joined: Sat Jun 02, 2012 8:53 pm
by andyl » Fri Jun 22, 2012 10:15 pm
claire1642 wrote:I am using debian 2.6.32 i think?

I am trying to do this hello world thing i found on a beginners forum but i cant write to the file i made as i cant log in as superuser. i type su and no password and it says authentication failure. Iv tried many other combinations too but no joy.

whats the UN and Password for SU?

(I just did a weeks course on suse but its not helped me at all!!)


For most beginner programming tutorials (unless you are messing with GPIO at the moment) you will not need to be superuser.

I would login using the normal pi/raspberry

I would then type the following* to the command line
Code: Select all
mkdir ~/src
cd ~/src

to create ourself a src subdirectory off of our home directory and change into it. If you want you can then go and create a subdirectory for HelloWorld (mkdir HelloWorld) if you want and change into that. If you are using some kind of file manager in a GUI you should be able to do this too. Your home directory should be /home/pi

Edit you source file - I don't know what language or editor you are using but it should be OK.
If you are using the command line you can do that by typing nano HelloWorld.py (or .c or whatever the extension is you are trying to do). Type the code in and save it.

If you are using the GUI, run the appropriate editor, type the code in and make sure you save it to the directory you are have previously specified.

Now try running or compiling (as appropriate) your file.

* putting things in to appropriate sub-directories makes things easier to find. Imagine if you have been using the pi for 6 months and you have 100s of files all cluttering up one directory.
Posts: 265
Joined: Tue Jan 10, 2012 11:05 am
by ping » Sat Jun 23, 2012 4:54 am
In most unix/Linux systems, the user code for the superuser is "root".

su is a command-line tool that "switches user" (by default to root).

However, most (if not all) Debian systems do not provide a root user at all. Due to the dangers of running as root, the preferred method is to use sudo to run the specific commands you need to run as root.
Posts: 1
Joined: Fri Jun 22, 2012 9:35 am
Location: Wellington, New Zealand
by geep999 » Sat Jun 23, 2012 10:57 am
Code: Select all
pi@raspberrypi ~ $ uname -a
Linux raspberrypi 3.1.9+ #125 PREEMPT Sun Jun 17 16:09:36 BST 2012 armv6l GNU/Linux
pi@raspberrypi ~ $ whoami
pi
pi@raspberrypi ~ $ sudo su
root@raspberrypi:/home/pi# whoami 
root

Cheers,
Peter
User avatar
Posts: 28
Joined: Fri May 18, 2012 10:20 pm
Location: East Herts, UK
by andyl » Sat Jun 23, 2012 12:19 pm
geep999 wrote:
Code: Select all
pi@raspberrypi ~ $ uname -a
Linux raspberrypi 3.1.9+ #125 PREEMPT Sun Jun 17 16:09:36 BST 2012 armv6l GNU/Linux
pi@raspberrypi ~ $ whoami
pi
pi@raspberrypi ~ $ sudo su
root@raspberrypi:/home/pi# whoami 
root



Yes but you shouldn't do this for normal stuff like writing and compiling simple programming examples.

On a multi-user system that would be a security issue, but even on a single user system like the pi you can still damage the system inadvertently.

The real problem the OP has is why the pi user cannot save files and do the sample beginner examples. That is most likely due to trying to save them in a directory to which the pi user doesn't have rights. The answer would be to save in a directory where they do have rights, not give yourself root access.
Posts: 265
Joined: Tue Jan 10, 2012 11:05 am
by claire1642 » Sat Jun 23, 2012 12:25 pm
Thanks to everyone for the replies, my problem is that I cannot create any directories as the pi account does not have permission, and if I use sudo to create one I am then not able to mod it. I also tried changing the permission to the directory which is not allowed either. Only want to write my first practice!! Also tried to use sudo to create my own account, which I am also unable to mod permissions on. ?? Confused.
Posts: 3
Joined: Sat Jun 02, 2012 8:53 pm
by dom » Sat Jun 23, 2012 1:00 pm
The permissions should be set correctly.
Perhaps use the Debian Wheezy image, where I'm sure they are. (http://www.raspberrypi.org/archives/1435).

I would have thought that typing:
sudo chown -R pi:pi /opt/vc/src

will fix the permissions so you can edit/build files as user pi.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4032
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge
by andyl » Sat Jun 23, 2012 3:21 pm
claire1642 wrote:Thanks to everyone for the replies, my problem is that I cannot create any directories as the pi account does not have permission, and if I use sudo to create one I am then not able to mod it. I also tried changing the permission to the directory which is not allowed either. Only want to write my first practice!! Also tried to use sudo to create my own account, which I am also unable to mod permissions on. ?? Confused.


What distro?

I've just tried on a stock Debian squeeze image.

I logged in as the standard user (pi) and the standard password.

Then did the following
Code: Select all
cd /opt/vc/src/hello_pi/hello_world
make
./hello_world.bin


The code compiled OK and printed out the expected message.

So we need to get a bit of information.

What distribution are you using?
What directory are you in? (type pwd to the prompt to tell you)
Can you also do ls -al and post that here?
Posts: 265
Joined: Tue Jan 10, 2012 11:05 am