2

Why have a product an software that's so tricky to grasp when it's meant to be educational.

I'm trying to experiment with the gertboard an simply run Python 2.7 ( I'm using 2.7 because any other version comes up with syntax errors ) and then I try to open and run leds-rg.py which is in /home/pi/GB_Python

For a complete noob this is a nightmare. Yes I know I need to run as root but can someone please precisely explain exactly how.

lenik
  • 11,533
  • 2
  • 32
  • 37
Newbie
  • 23
  • 1
  • 3

4 Answers4

5

Why have a product an software that's so tricky to grasp when it's meant to be educational.

To be glib: if it were easy, there wouldn't be much to learn, would there? By analogy, if you want to learn to cook but all you've ever done is stick frozen meals in a microwave, it may be challenging at first.

However, it's not intentionally difficult just to frustrate you. *nix systems are the way they are on purpose. Like everything, they make more sense once you learn to use them. Going back to my analogy, it may seem stupid that you don't just chop up food, put it in the pan, and then turn on the heat. You have to take the trouble to heat the pan up first -- eventually the reason becomes clear.

For a complete noob this is a nightmare.

No doubt. I'm totally comfortable with linux and prefer it to anything else regardless of context (desktop, server, whatever). However, to be new to both it and the pi at the same time is, I am sure, quite a challenge.

Linux was not chosen because it is easy to use -- I agree it is not. It was chosen in part because it is open source and can thus be easily adapted to any architecture. It is also very flexible/adaptable, hence widely used in real world embedded contexts (you probably have some other linux based devices in your home, e.g. routers and set top DVR boxes), which the pi can model. In other words, it's the operating system of choice for this kind of thing, and if that's what you are interested in, you pretty much have to get used to it -- it's not coincidental or some silly mistake.

Although a lot of attempts are made at making it more user friendly for the general public, it is really geared more toward expert use; once you are skilled with it, you'll probably appreciate it for what it is, but getting there takes some time and dedication.

I know I need to run as root but can someone please precisely explain exactly how.

In addition to sudo, suggested by joan, you can switch over to root completely, if necessary, with su. No messing around with the finer points and gotchas of sudo. You'll need root's password, but after that, until you exit, you're root (in case that's not clear: you need to call exit to get out of the root session). Note if you are in a GUI terminal, you won't be able to start other GUI apps. su stands for "switch user" and it is by default to root unless you specify something else (e.g. su bob). It does not apply to anything else on your desktop, etc., just the command line where you switched.

Part of the caveat about not using root is to minimize the number of applications run that way. Thus, unless you need to, don't start an entire GUI desktop as root, then run a web browser, etc. Any security hole in the browser or DE now has root access.

However, as long as you pay attention, using su, or logging in as root via ssh, is fine. Again: just don't use it for anything when it is not necessary. The biggest danger is really just that you do something stupid, but if you intended to do what you did and you needed to be root to do it, then the latter fact is besides the point.

To be honest, I've been cavalierly logging in as root since I started with linux in the late nineties, and it has never caused me any grief that didn't have to do with me doing something incorrectly. As long as you are careful, pay attention to documentation, make an effort to keep the system secure, and generally use your head, it is reasonably safe.

goldilocks
  • 60,325
  • 17
  • 117
  • 234
3

The root is the system administrator on *nix systems, so running as root means running with system administration privileges.

The normal way is to precede commands which need privileges with sudo.

E.g.

sudo python script.py

or

sudo ./script.py

etc.

joan
  • 71,852
  • 5
  • 76
  • 108
1

Unfortunately, I cannot comment on the above answers because StackExchange requires 50 reputation to do that. So instead, I'll just say that this answer should be considered an addendum to some of the answers above.

An interesting way to switch to root if you're using a Debian or Ubuntu system, where you might not know root's password (Ubuntu does this) is to do:

sudo su

Yep. Here's the long-winded explanation:

Here, su is the argument to sudo, meaning that sudo will run su as root after you enter your own account's password for sudo. If sudo successfully authenticates as root, then su will be run as root. Since running su as root with no other username as an argument means that root is trying to "switch user" to root, it succeeds without requiring root to enter root's password. Congratulations. You are now logged in as root. Remember to use the

exit

command when you're done with your session as root so you don't accidentally bork your system. I did that, long ago. It's no fun. ALWAYS remember to exit from a root session!

user80311
  • 11
  • 1
0

The Gertboard is a complex peripheral. If you download the Gertboard manual, and read through it it will explain all this. I suggest you work through the well documented examples.

It will not teach you Linux, you need to get a suitable book.

PS I wouldn't worry too much about the warnings of running as root. The worst that can happen is you may totally break the OS - and need to re-image the SD card.

Milliways
  • 62,573
  • 32
  • 113
  • 225