1

Is it bad to have at all times (one) terminal logged in as root? If so, why?

(I leave the window with root terminal usually opened because it's much more comfortable than writing sudo before everything what needs root.)

Just to clarify that this isn't a duplicate question as suggested by system, I'm not talking about running the whole account as root, just one terminal window.

Thank you.

P.S.: sorry for the non-descriptive heading, I for love nor money couldn't think off sth that made more sense.

P.P.S.: This does not mean I'm performing the usual tasks (copying, running normal programs...) as root.

Ok, the main question came up later after posting this - what is the technical difference between executing command as $ sudo command and executing it as # command ? To clarify: I wanted to write into file /sys/devices/platform/asus-nb-wmi/leds/asus::kbd_backlight/brightness directly. It containes only a number with level of KB backlight.

This failes:

edison23@edison23-N56VM:/sys/devices/platform/asus-nb-wmi/leds/asus::kbd_backlight$ sudo echo 3 > brightness 
bash: brightness: Permission denied

This succeeds

root@edison23-N56VM:/sys/devices/platform/asus-nb-wmi/leds/asus::kbd_backlight# echo 3 > brightness 

Why?

Thanks

edison23
  • 927
  • 7
  • 16

2 Answers2

4

Is it bad to have at all times (one) terminal logged in as root? If so, why?

Yes. Well. The idea of logging out your root terminal is due to the fact that Linux is a multi-user system. So other users could walk to your terminal and issue commands you do not want them to issue. With the introduction of desktops (that are often single user) this is less of an issue.

The 2nd issue is that some files depend on the user being the owner of files. If you touch those as root they will be saved for the user root and you can lock yourself out of the desktop. We have several questions about that on Ask Ubuntu.

But besides that: Ubuntu does not use root. We use "sudo" and (by default) you have to supply the "sudo" password every 15 minutes. So there is no need for "root". No need at all. Learn to live with the way Ubuntu does it. It has proven it works over the past decade or so.

But... It is your system. It is your data. If you believe you need "root" go for it. Most of us will not. When you mess up it is on your head (but that is also doable using "sudo" ;) ).

Make regular backups. Check that you can restore backups. And you should always be able to restore your system.

Rinzwind
  • 299,756
  • ok, so having root logged in a terminal (on desktop one-user PC) doesn't pose threat in a way that some malicious program could use the terminal to do evil stuff, right? (a/w i'll try to learn to use sudo not going into root window) – edison23 Mar 20 '15 at 10:24
  • @edison23 someone would need physical access or have had to have physical access to install something to be able to abuse your sesssion. – Rinzwind Mar 20 '15 at 10:34
2

Is it bad to have at all times (one) terminal logged in as root? If so, why?

I can only say that I worked the same way as you, until I made a huge mistake... most of the time I forgot to add sudo in front of my commands to get the privilege for systemuser. Then on one day I executed as root the command

rm -rf / var/www/filenotneeded.html

... as you may see there is a space after the / which means it deletes / and all subfolders until rm itself is removed. If I had used sudo maybe I had checked it twice because I still forget sudo today. Since I use sudo the error rate was getting down and and I feel a bit more secure then before. I dont say you will do the same error... I just want to warn that with root you destroy the system in microseconds and sudo tells me that I should check the command before I execute it.

A.B.
  • 90,397
snapo
  • 216
  • You might want to check out https://launchpad.net/safe-rm that helps to prevent inadvertent rm deletions that hit important files - doesn't obviate the need for backups in anyway but can keep the system up against some "attacks". – pbhj Apr 04 '15 at 16:11
  • @pbhj thanks for the information.... im always up to learn something new. But the initial question was referred to why using sudo and i just gave my 5 cents to it. – snapo Apr 07 '15 at 10:57