6.Â Creating a user
Now you are starting to get to know your Pi, you’ll want to start making it feel more like home.Â Unless your name is “Pi” you will want to add yourself as a user.Â Type this:
Do I really need to explain that you should replace “naich” with your name?Â If you’ve already guessed that and typed it in with your name, you will probably be slightly worried at this point because it will have replied “adduser: Only root may add a user or group to the system.”
“Root” is the name of the account that has full access to the Linux system.Â There are many things that only Root can do, and it’s just as well really; one of the things that only root can do is permanently delete the entire filesystem with one command that doesn’t even bring up an “Are you sure?” type question.Â As an ordinary user, you can only screw up your own stuff that you put on there, but as root you are a god that can break everything for everyone forever.Â This is why we try to avoid being root as much as possible.Â Luckily the root password does not actually exist, so you can never log on as root!Â Problem solved, except that sometimes we do want to be able to do rooty stuff, like add users.Â There is a way to temporarily become root and that way is sudo.Â You might remember typing it in earlier.Â Sudo executes a command with root privileges and you simply add “sudo” in front of the command you want to run like this: sudo adduser naich:
naich@raspberrypi ~ $ sudo adduser naich Adding user `naich' ... Adding new group `naich' (1000) ... Adding new user `naich' (1000) with group `naich' ... Creating home directory `/home/naich' ... Copying files from `/etc/skel' ... Enter new UNIX password:
Choose a good password for your username but one you will remember.Â Write it down if you have to. Â Fill in the rest of the details or leave them blank if you want. Â You also need to add your new user to the list of people who can use sudo, so type sudo visudo and you should see this:
# # This file MUST be edited with the 'visudo' command as root. # # Please consider adding local content in /etc/sudoers.d/ instead of # directly modifying this file. # # See the man page for details on how to write a sudoers file. # DefaultsÂ Â Â Â Â Â Â env_reset DefaultsÂ Â Â Â Â Â Â mail_badpass DefaultsÂ Â Â Â Â Â Â secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:$ ... and so on ...
“visudo” is the command that allows you to modify the list, “sudo” means you are temporarily granted root’s super powers in order to do so. Â What visudo actually does is load a text file into an editor called “nano”. Â Once nano has loaded the sudoers list, move the cursor down to where it says
pi Â ALL=ALL(ALL) NOPASSWD: ALL
and change “pi” to your new username. Â This means “pi” will no longer be able to sudo, but that doesn’t matter because we are going to delete him soon anyway. Â To save the changes and exit nano, press CTRL-X. Â If you want to exit without saving your changes press N at the prompt, otherwise press Y and then hit return to save it with the suggested name.Â You’ll be using nano a bit, as most configuration is done with plain text files.
Once you have got back to the “pi@raspberrypi:~$” prompt, type exit to log out and log back in again as you.
6.1 A Windows diversion
Windows users: this is the part where we sort out the static IP stuff.Â Linux users can skip this bit and go to section 6.2.
You now need to edit two files – the /etc/network/interfaces file that you couldn’t edit earlier, and the /boot/cmdline.txt file to take out the stuff you put in earlier.Â Type sudo nano /etc/network/interfaces and use the text editor (in the same manner as you did to edit the sudoers file) to edit the file as described in section 3 (click to open in a new window/tab).Â Save it with CTRL-X, [Y]es, Enter and then type sudo nano /boot/cmdline.txt and remove all the text after “rootwait” that you put in earlier.Â Make sure the text is still all on one line and that there is still a newline at the end of the line.Â Save the file.Â Your Pi is now properly configured with a static IP.
6.2 Back to our scheduled programming
Now let’s kill off “pi”.Â If you add users with the command “adduser”, you might think you delete them with “deluser”, right?Â Nope, it’s userdel.Â No idea why.Â As a general rule, if you don’t know what command to use, a good place to start is Google – “linux delete user”, returns 205 million pages telling you how to do it.Â Anyway, have a go at deleting pi.Â I’m not going to tell you how to do it.Â See if you can guess.
Done it? Â It was sudo userdel pi, by the way. Â Do you like the way it didn’t ask if you really wanted to do that?Â Linux assumes you know what you are doing and doesn’t treat you like an idiot by asking you if you really want to do something. Â Successful operations for simple things (like copying, moving and deleting files, for example), generally won’t produce any output unless you tell them to.
If you don’t know how to navigate the Linux filesystem, now is the time to check out Appendix B and learn all about it.Â Got it?Â Go to the home directory – cd /homeÂ and have a look – ls :
naich@raspberrypi ~ $ cd /home naich@raspberrypi /home $ ls naichÂ pi naich@raspberrypi /home $
As well as your new user’s directory, there is also one called “pi”.Â Although you deleted the user pi you didn’t delete his stuff.Â You don’t need or want it, so get rid of it.Â Type sudo rm -r pi (“rm is short for “remove”),… and it’s gone.Â As before, there are no prompts, no “are you sure?”s; it’s gone forever.Â If this doesn’t make you a little uneasy, then you might not have grasped how devastating a mistake could be and will probably discover this the hard way at some point!
Before you go any further, please consider expanding your knowledge about commandsÂ a bit by reading appendix C.Â You don’t have to but it might help you understand what’s going on a bit more. Â See if you can find out what the “-r” does when you types sudo rm -r pi earlier.