82

If I understand the Linux philosophy correctly, sudo should be used sparingly, and most operations should be performed as an under-privileged user. But that doesn't seem to make sense, since I'm always having to input sudo, whether I'm managing packages, editing config files, installing a program from source, or what have you. These are not even technical stuff, just anything a regular user does.

It reminds me very much of Window's UAC, which people either disable, or configure to not require a password (just a click). Furthermore, many people's Windows users are administrator accounts as well.

Also, I've seen some people display commands that require sudo privileges without sudo. Do they have their system configured in such a way that sudo is not required?

  • 26
    You need to use sudo to do anything involving changing the system, if you're just operating on your own files/desktop you aren't affecting anyone else so don't need elevated privileges. If you're executing privileged commands without sudo, you're probably already a super user (i.e., root) and that's usually less advisable than using sudo for the specific system-wide tasks – Eric Renouf Oct 19 '15 at 19:20
  • 1
    Those latter people might have added an exception to sudoers to allow them to execute those commands under a 'normal'/implied privilege token. – underscore_d Oct 19 '15 at 19:51
  • 76
    "installing a program from source . . . anything a regular user does" --- I think you've overestimated the technical skills of regular users. – Jonathan Cast Oct 19 '15 at 21:56
  • There is nothing saying sudo shouldn't be used often in Unix/Linux. – DisplayName Oct 19 '15 at 22:38
  • 7
    Are you using sudo when you shouldn't? A normal Unix user's commands should consist mostly of cd, ls, moving, copying, removing, and editing files they have access to. If your usual commands don't consist of this, you probably aren't a regular Unix user. – user530873 Oct 20 '15 at 06:41
  • 4
    Side note: it is often possible to install a package from source using a custom prefix; rather than installing it in /usr/local, you could install it somewhere in your home directory, say. If you do that, then you don't need to be root and hence wouldn't need to use sudo. This is often useful when you need to use something on someone else's system and it's not installed system-wide. – Wouter Verhelst Oct 20 '15 at 09:13
  • 21
    Small tip: If you do something that requires sudo but forgot to put sudo in your command, you can use sudo !! to re-run the last command you typed with sudo in front. – asfallows Oct 20 '15 at 17:54
  • 4
    sudo su - <- quick way to get a root prompt. – Criggie Oct 20 '15 at 22:12
  • 6
    Do you not spend most of your time using the software you have installed? That shouldn't involve sudo. If not, why are you installing it? – OrangeDog Oct 20 '15 at 22:37
  • 3
    "managing packages, editing config files, installing a program from source" are not ordinary user tasks - they are system administration tasks that have the potential to affect all users. – Toby Speight Oct 21 '15 at 12:37
  • 3
    @Criggie A few characters shorter: sudo -s. I don't know how many version of sudo support that, but Debian's does, at least. – Joshua Taylor Oct 21 '15 at 12:42
  • @OrangeDog - 99% of things I install on my server are basically "Fire and Forget" - ie I install them in Linux, then use them via the web/network. So I think the OP's point is that they seem to be using sudo a lot when in SSH. The thing they seem to miss is that they are doing a lot of non-admin things all the time... just not via command line. – Jon Story Oct 21 '15 at 14:48
  • If you want to disable password on specific commands that you run a lot, without disabling password entirely, you can add a line like <username> ALL=NOPASSWD: /bin/command1, /bin/command2 and so on to the sudoers file. – Alex Oct 22 '15 at 07:27
  • 1
    You can compile and install (most) programs from source locally without using sudo. Use ./configure --prefix=$HOME/opt before make and (not sudo) make install. If you are installing the programs to /usr/bin instead, then you are performing a system action and should be using sudo. – John Gowers Oct 22 '15 at 10:51
  • 2
    As for "I've seen some people display commands that require sudo privileges without sudo": as others explained, those commands require administrator (or "root" in *nix lingo) privileges, not sudo per se. In writing (especially on the internet) it is common to prepend with $ commands that can be executed by a normal user and with # commands that require root privileges. Those symbols mimic the command prompt you get in a shell as a normal user or as root, respectively. – A.P. Oct 22 '15 at 13:02
  • 1
    Obligatory XKCD: https://xkcd.com/149/ – Cort Ammon Oct 23 '15 at 01:17
  • 1
    The bias here is that most people only use the command line for advanced things, and that usually calls for root permissions. It's (for some) less common to do normal tasks in the command line because you can do all of that through the file browser, etc. – krs013 Oct 23 '15 at 03:52
  • installing from source does not require sudo if you install for your current user only/ – njzk2 Oct 24 '15 at 13:59
  • "I'm managing packages, editing config files, installing a program from source, or what have you. These are not even technical stuff, just anything a regular user does." Eh?! No, it's not. Do you spend your entire time administering this system, or do you ever actually use it? lol – Lightness Races in Orbit Oct 24 '15 at 20:58
  • 1
    Once you have installed ubutnu on any machine, the virginity of being a regular user is lost :) – Bikash Gyawali Sep 11 '20 at 13:50
  • @EricRenouf, you wrote: "If you're executing privileged commands without sudo, you're probably already a super user (i.e., root)". Who else apart of root doesn't need sudo typing? I thought, root is user is one and single of a kind. – Andrew Anderson Apr 28 '22 at 18:01
  • 1
    @AndrewAnderson of course, i.e. means "that is" and is not someone given as an example. That said, there are other ways to let someone execute things as root without using sudo (e.g., setuid), and sudo can be used to run things as users other than root – Eric Renouf Apr 28 '22 at 22:44

12 Answers12

77

You mentioned these system adminstration functions

managing packages, editing config files, installing a program from source

as things that

anything a regular user does

In a typical multiuser system these are not ordinary user actions; a systems administrator would worry about this. Ordinary users (not "under privileged") can then use the system without worrying about its upkeep.

On a home system, yes, you end up having to administer the system as well as using it.

Is it really such a hardship to use sudo? Remember that if it's just your system there's no reason why you can't either pop into a root shell (sudo -s - see this post for an overview of various means of getting a root shell) and/or configure sudo not to prompt for a password.

Chris Davies
  • 116,213
  • 16
  • 160
  • 287
  • 49
    there's no reason why you can't [...] configure sudo not to prompt for a password. I would not recommend that, if you launch a malicious script it will be able to act as root on your system. – A.L Oct 20 '15 at 00:35
  • 7
    If entering the sudo password annoys you so much that you basically auto-pilot the password entry then it won't help either. You need to balance sanity with security. I've auto-pilot sudo deleted major chunks of the OS at least once. – Nelson Oct 20 '15 at 01:14
  • 2
    @A.L I wouldn't do so on a production system either. But for a non-essential VM running on my laptop it has many advantages. That's what I like about sudo - it's customisable so some command cab run passwordless but others require the safety check. – Chris Davies Oct 20 '15 at 07:02
  • 35
    Personally i love sudo - it's like a sanity check. – Max Williams Oct 20 '15 at 08:30
  • 1
    @A.L If you launch a malicious script via sudo (instead of as root), don't you expose your system to the same risks? – landroni Oct 20 '15 at 09:11
  • 1
    @Iandroni it depends, if the script uses sudo without announcing it, you will have a prompt in order to enter your password. If sudo is disabled you won't have this warning. – A.L Oct 20 '15 at 09:44
  • 7
    @MaxWilliams, yeah exactly, it's that little clear plastic flip cover over the big red button that asks, uh, are you sure you know what you're doing? – KlaymenDK Oct 20 '15 at 16:12
  • 2
    @KlaymenDK: Agreed. For me, typing "sudo" (not entering the password) is the little clear plastic flip cover over the big red button. I set sudo to NOPASSWD for myself on my personal desktop. – jrw32982 Oct 20 '15 at 21:04
  • 15
    @A.L: If I'm going to run an unknown script, it had better not be malicious or I'm screwed whether or not it runs sudo. On my personal desktop, it's my own (non-root) data that's important, not the (root) configuration of the machine per se. – jrw32982 Oct 20 '15 at 21:06
  • 2
    @jrw that's why you have off-disk backups though, isn't it...? – Chris Davies Oct 20 '15 at 21:22
  • @A.L When running scripts from unknown source you are at their mercy anyway. All it does is ask for password, and user would provide it. If it prompted that this script will wipe out your disk, then yeah disabling sudo is a threat. – GoodSp33d Oct 21 '15 at 11:16
  • 2
    @klaymenDK - and sudo su - is the "I have no idea what I'm doing, leave me alone anyway" button. Although I agree with @jrw32982... at the end of the day most of us just do sudo !! when prompted anyway and don't check the script contents. Is it really protecting us in that circumstance? We were probably compromised when we decided to run the script at all. – Jon Story Oct 21 '15 at 14:50
  • 2
    @jrw32982: there will be some attacks, like installing a keylogger, where it makes a difference whether the malicious script gets sudo or not. But this is a difference between losing badly and losing atrociously: like you say if sudo is your line of defence then you've certainly lost. Requiring a password might affect how much you lose by. – Steve Jessop Oct 22 '15 at 10:26
  • 1
    @roaima Well I definitely have off-disk backups, but I don't have them so I can run unknown scripts capriciously! My point is that whether or not a script gets root with or without a password is a non issue when I run someone else's script. The only security hurdle is getting me to run the script in the first place. Once I do that, it's game over if the script is malicious. There are plenty of things owned by me under my home directory that are much, much more sensitive and important than getting root on my machine. I have to be vigilant before running an unknown script. – jrw32982 Oct 22 '15 at 14:59
  • 1
    The concern is not the hardship of having to type sudo, the concern is allowing any old script root level access. It's called the principle of least privilege. The truth is, unless you have something you want to share system wide, many tools can be configured, built and run on a user level. – Peter Oct 22 '15 at 22:24
  • sudo bash and done! Also, sudo whoami tells you you're root so just sudo bash away, once and for all! – TheSola10 Oct 23 '15 at 12:28
  • @Thesola10 yes, this is much the same as just sudo -s (or sudo -i if you want a login shell) – Chris Davies Oct 23 '15 at 13:11
  • @jrw32982 I am trying to understand how your personal files are somehow better secured than access by a root user? I wonder if you are thinking that root can only modify system files and forget that all user files are a SUBSET of system files and trivial to delete etc. – KalleMP Oct 24 '15 at 19:10
  • @KalleMP if I have understood correctly the point is that the machine is a vehicle for the data. And the data belongs to the user who's logged in. So regardless of root access the data can still be compromised. – Chris Davies Oct 24 '15 at 19:23
  • @roaima My comment was not a critique on your question, just on the possible misunderstanding (repeatedly) that the other commenter (jrw) had about user space security. You are correct, with root access everything is vulnerable. When using sudo and normal accounts, root access is minimised, this is a good thing; changing the default behaviour should be done with care. – KalleMP Oct 24 '15 at 20:19
  • sudo -s doesn't reset some variables, sudo -i should be preferred. – muru Oct 24 '15 at 20:57
  • @muru that surely depends whether or not one wants those variables reset? – Chris Davies Oct 24 '15 at 21:09
  • 1
    @roaima only if you know enough. Which most users don't. And while you maybe one of those, a user who asks "why do I need sudo" is not one of those. – muru Oct 24 '15 at 21:12
  • 3
    @KalleMP I'm not saying that; I'm saying that on my personal desktop, my own files are more important than the system itself (root-secured files). If I run an untrustworthy script, I have potentially already lost the game (my data), whether or not the script can gain root access by using sudo without having to use a password. Therefore, in my scenario using a NOPASSWD sudo configuration is a big gain in convenience for me with no loss of security. – jrw32982 Oct 24 '15 at 22:29
  • 1
    @roaima The loss of my personal data is not just about whether or not I can recover it (which can be handled by backups as you suggest) but also about the exposure of that data to a potential identity thief. – jrw32982 Oct 24 '15 at 22:33
  • @jrw32982 I think I understand your point now on your single user desktop. Your point seems to be that a non-root evil script is just as dangerous to your personal data. It may seem that way but an evil-script that wants to hide until later may be able to do this much easier with root access. Testing unknown-script on a guest account first can mitigate the risk to personal data but is more of a hassle obviously. – KalleMP Oct 25 '15 at 16:07
  • I finally found an example of remote script launched locally with Docker. This script uses sudo which ask for the user's password. – A.L Nov 17 '15 at 13:26
  • @Wildcard Exactly! I should have thought of linking to that xkcd comic; it's right on the money. – jrw32982 Dec 04 '16 at 03:31
33

Sudo/Root is used whenever you are doing something that a standard user should not have the capability of doing for risk of damaging/changing the system configuration in a way that the Administrator of the system would not normally allow.

whether I'm managing packages, editing config files, installing a program from source, or what have you.

All of those are technically admin functions, and can drastically damage your system if something incorrect is done. In a corporate environment, as a Sysadmin, they are things I would NOT let my user do without my express knowledge, hence sudo.

For example, if a package/config file could be modified without elevated privileges, then it would be extremely simple for an outside source to simply execute remote code that could break/compromise your system. By forcing those actions to require root access, it forces you as the user to make the decision on whether or not those actions take place.

It is very similar to UAC with windows, it is actually where windows got the idea for UAC.

The quote you receive the first time you use sudo is very fitting, and very important:

We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things:

#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

Especially #2, Think before you type. That is an important reason sudo exists, when you type a command and it kicks back "must be root to perform this action" it forces you to stop and THINK about what you are actually doing.

terdon
  • 242,166
Gravy
  • 1,562
21

Also, I've seen some people display commands that require sudo privileges without sudo. Do they have their system configured in such a way that sudo is not required?

You have to execute those commands as superuser, but you don't have to execute them using sudo. You could for example instead use su or doas (OpenBSDs replacement for sudo), or you could simply login as root.

So if they display their commands here without sudo than they assume that the reader will just use his favorite way of executing those commands as superuser.
It most certainly doesn't mean that they can execute those commands as a normal user.

  • 4
    you can also use sudo -i or similar to get a root shell and then start running your root commands without needing to preface each of them with sudo – cas Oct 20 '15 at 00:53
  • 2
    Usually steps that need to be run as root is shown with a root prompt e.g. # vi /etc/hosts instead of a unprivileged prompt $ vi /etc/hosts (Bash will follow the convention if you use \$ in PS1) – Gert van den Berg Oct 23 '15 at 07:09
18

One security feature offered by sudo is that you can have a system without a root password, so that root user cannot login directly. This offers additional protection for users who pick weak passwords - the attacker trying to brute-force the password (via SSH or otherwise) will have to figure a valid username first.

Another aspect is a more fine-grained privilege management. Think about make; sudo make install vs doing make; make install as root. Lots of things can go wrong during make. A badly configured tool may try to overwrite an important system file, "clean" the /lib instead of the current directory, consume all available RAM and hang the system, etc. make install is a small simple action with much less probability for a fatal error.

  • 1
    And even if a root password is configured, it allows you to give a user access to commands requiring root priviledges without giving them the root password, which means that if it is a company server and they get fired, you only need to disable their user, without having to change the root password. – Gert van den Berg Oct 23 '15 at 07:11
  • It's not offered by sudo; the presence or absence of a valid root password is a completely independent feature – Chris Davies Jan 09 '22 at 20:48
  • @roaima The feature offered by sudo is not the presence or absence of a valid root password, but the ability to maintain a system which has no root password. Of course, you can remove the root password on a system without sudo, but how do you maintain it afterwards? – Dmitry Grigoryev Jan 10 '22 at 10:56
16

The point is that historically a system is really intended to be shared by multiple users who just log on, do some stuffs and then log off. Thus the distinction between admin and normal user. Such systems still exist in university labs and you can feel the difference sharply if you use such computers. Home PC where you are the sole user and also happens to have to act as the admin is really a much later development.

xji
  • 757
  • 6
    "Still exist in university labs"...yes, and every technology-centered corporation on the planet, and most of the non-technical ones also. Still, +1 for giving the exact distinction that the OP is obviously missing, and that most other answerers failed to emphasize. – Wildcard Oct 21 '15 at 15:06
  • @Wildcard Lol sure. Just put the example that immediately jumped out in my head I guess. – xji Oct 21 '15 at 15:43
13

A computer is a tool. Let's try an analogy with another tool, let's say a frying pan. Sometimes, you have to take care of your frying pan. For example, you have to clean it with dish soap. Would you say that dish soap is a required ingredient of any recipe you use the frying pan for? You'll never see "dish soap" listed as an ingredient in cooking books. It is needed, but the preparation of the tool is another matter, so the cooking books don't mention it. The frying pan has to be cleaned, but it's not what it is made for.

It's kind of the same for your computer. It has to be configured and taken care of, but it's not what it is made for. You take care of it, you configure it, so it can work properly. Once this is done, you can use it, not as a system administrator, but as a user. That's what it's made for. When you're a user, you don't need sudo anymore. Just use the tool that you prepared beforehand. Of course, from time to time, you'll need to use root privileges, just as you have to clean your frying pan as often as you use it to cook.

So without exaggerating too much, we could say that you never need sudo (or the root password) to use your computer. Only to prepare your computer.

Geoffroy
  • 191
  • 2
    Great analogy, but sometimes you need that soap to get out some nasty charred remains from your pan before you fry your scrambled eggs, i.e. both things connect pretty easily. With a computer you own, you can "wash"/"fry" it almost immediately with sudo or you just go master chef and do a su. – Armfoot Oct 23 '15 at 12:22
  • Seems like you should need root access for cooking, as its more dangerous. – deltaray Aug 12 '16 at 15:17
7

I bet it's because you use GUI software for everything except system administrative tasks, or you're talking about Linux servers, in which case most access will naturally be system administration. Therefore it might feel like doing anything at all in the shell requires sudo.

It's also possible to use the shell for your everyday tasks. Managing your personal files in ~, editing files, chatting on IRC, compiling code, browsing the web, all of that is doable in a shell. I even use bc as my go-to calculator. Some things are easier to do via a GUI, some things are easier to do via the shell - even if you prefer to use the GUI the shell will often excel in batch operations and automation (think shell scripts). Personally I use whichever is best for the task at hand.

In some cases it's a good idea to set up your system so that you don't need to use sudo every time for operations that by default require root but are unlikely to cause problems. One example is that I work with hardware which involves using serial ports, and I've set up udev rules to give access to the devices as my regular user without having to be root.

I don't think it's a good idea to configure sudo to not require a password. It makes it too easy to mess up your entire system with one mistyped command or malicious script.

If you need to do tasks that absolutely require root all the time, why not leave a persistent sudo -s root shell running in a terminal window? Then it'll be available without having to type in the password, and it isn't as easy to use accidentally. I've even set up my shell prompt to be bright red when in a root shell.

6

[...] But that doesn't seem to make sense, since I'm always having to input sudo, whether I'm managing packages, editing config files, installing a program from source, or what have you. [...]

The implied adjective related to all these is that they are system-wide or global changes. You must consider the origins of Unix as a multi-user system1 where several users would use the same installation remotely. It wouldn't make sense for one layman user to allow to change the global settings for all users. It was the sysadmin's, the root's, privilege and responsibility.

In a multi-user setting you have the preinstalled software and their system-wide configuration under /usr and /etc respectively. Touching these locations would require root permissions. But because Unix software is written with multi-users in mind, you can compile and install software under $HOME directory2, and have your own configuration files under your home, where you can edit the files freely without being a super user.

In addition to installing your own software under home, most system-wide software will read user-specific configuration from $HOME right after they first read configuration from /etc. This allows you to customize most anything without ever going root.

With a home PC, in a single main user setting, you can use sudo and root your way to things you like. But it's customary to not to touch application configuration in /etc but instead always provide user-specific config in home. That way you can allow your package manager to reset system-wide configs on upgrades. Installing new software system-wide is pretty OK in single-user setting; distro packages don't assume the alternatives so it's a easy way out.

I'll let my package manager install stuff globally but any compiled-from-sources and self-made stuff I leave under $HOME. And I don't have to sudo for any of that.

If you have data files, storage outside your $HOME, feel free to chown or chgrp the directories to your name so you can access the files without sudo.

[1] (slightly ironical as Unix was meant to be a 'single user' version of the Multics operating system)

[2] (if the system allows this by not mounting home partitions as noexec)

mike3996
  • 1,549
4

In the sorts of multiuser systems that UNIX (and, by descent, Linux) was designed for, these are not ordinary user actions. A system administrator might perform them, but not typical users, and so the system asks to make sure that the sysadmin actually wants to do this.

But even in single-user home systems, these are not ordinary user actions. One might typically have to do these when initially setting the system up, but once that's finished, a typical user should not have to do them very often. Most typical users just work on files inside their home directory (or subdirectories of it), using programs/packages that have already been installed, and you don't need sudo for that. Or they might work in a special directory somewhere else on the system that has been set aside for that purpose, and you need sudo to set that up, but you typically only need to do it once.

Why does that matter? Because "single-user" is a misnomer: you are not the only user of your machine, even though you might be its only human user. Even on a typical home Linux install, many programs are set up to use the machine in various ways of their own, often simulating something a human might do if they had the time and attention to spare: backups, updates, malware scanning, and the like. Most of the time, those uses are completely benign, but even for some of those, it is still prudent to make sure that the user really wants to do this. And when those cases arise, that's is what sudo is for. The computer is just checking in to make sure it's really you who wants to do what someone (maybe you, maybe a program) said you did. And that's not even getting into the possibility of malware, which you certainly don't want to masquerade as you.

2

This is probably not as common as represented but usually happens when something casual internally requires much more generic privileged system call to achieve its result, for instance:

  • Unmount and carry away a USB stick. umount is a serious command as you can unmount a lot of things with it.
  • Connect to the local wireless network. Nothing extraordinary, but the network configuration (ifup, etc) is for superuser only.
  • Self-updating apps that refuse to run if not updated. Update = install, and this could install a lot of things, including things you do not want.

The systems generally evolve to reduce the number of such cases. USB sticks are user-mountable now and networks are user-connectable. But it was not always like this.

h22
  • 389
1

Assumption: this is your system and your data.

You just need to weight the risk of accidentally erasing data or bricking your OS vs. the ease of do stuff without typing sudo everytime.

I routinely login and work as root on my home servers because I can it is easier.

You will be told that you may launch nuclear weapons if you do not go though the sacro-saint sudo but the reality is that today people have root powers (*) on plenty of devices (your TV, your phone, your toaster, your Windows (as you mentioned)). Linux is no different here, even though many like to think otherwise.

BTW UAC was not modelled after sudo as its man role is (beside making your life miserable) to ensure that you will see when malware wants to do things on your behalf.

(*) root powers are defined as the capacity to nuke important data. The "with great power come great issues" (or whatever that was) adage applies.

If my assumption is wrong then you still need to weight the risk above but there are more variables (your job, photos taken by your spouse and stored on the same laptop, ...)

WoJ
  • 1,545
  • 1
    root powers are not the capacity to nuke important data. You can always rm -rf ~/ without any special permissions. On the other hand, you can't brick your mobile phone or TV without rooting it first. – Dmitry Grigoryev Oct 20 '15 at 11:34
  • A device is as useful as the data it stores and the services it provides. The hardware and OS which is below is a mere commodity. So the power is where you can impact services or data. On a TV you can erase all your settings - the TV is unusable (before one restores the data). You can erase all your data on a mobile phone, which then becomes a piece of hardware without any use. This is what I meant by "root power" – WoJ Oct 20 '15 at 12:20
  • You're misusing the term then. There is simply no way to protect users from destroying their own data, so it's rather meaningless to discuss about sudo vs root in this context. Also, consider this: I have a back-up of my mobile phone data (addressbook, mails and photos), so if I have to wipe it it's not a big deal. If I brick it, on the other hand, I'll have to buy a new one. – Dmitry Grigoryev Oct 20 '15 at 13:08
  • 1
    Indeed, calling this "root power" is misuse. The word "root" is already overloaded to mean at least three different things (the root user, the / directory, and the /root directory) and adding another is unhelpful.

    On a single-user machine, even though the unprivileged user already can delete his own files, his inability to do certain administrative tasks without using sudo still protects him from various Bad Things.

    – Monty Harder Oct 20 '15 at 15:52
  • 1
    Your TV analogy is not a good one. Erasing the settings on your TV is like erasing your user config files on Linux - doing so typically just makes the system operate according to some set of defaults for that user, and doesn't usually do any harm to the system. Root enables you do modify the system itself - on the TV this would be like modifying the firmware, in which case you can break it's ability to actually operate. – JBentley Oct 20 '15 at 23:40
  • @JBentley: when I erase my TV settings I end up with an useless piece of hardware. The point is that I erased the ONLY data on the device. I can reconfigure it again - similar to restarting a system from scratch. What counts is the service and data, not the underlying platform. If someone claims that the worse you can do by using a user account vs. an admin one is to loose all your data and all your software settings then that person has never been faced with such a loss. I have never seen someone crying about the fact that his OS is gone (OS, not services/data). – WoJ Oct 21 '15 at 06:48
  • @JBentley: (cont'd) Yes, it is possibly more work to recover, and this is why I was mentioning the risk of working as as an admin vs comfort. – WoJ Oct 21 '15 at 06:48
  • @DmitryGrigoryev: the point I am making is that in modern devices, the user is the admin of devices, services and data. There is some historical, legacy thinking that a PC is somehow special. When you erase your data you just have a worthless piece of hardware until you are back with the data. If you nuke your OS in the process of destroying your data then it is of course more work to recover (this is why I mentioned the risk) but the loss is equal to zero compared to the loss of you data, which you are admin of anyway. And since there is no other data on a personal device it becomes a brick. – WoJ Oct 21 '15 at 06:52
  • How on earth can you "reconfigure" a TV if you went in with root access and deleted ALL data? Answer: You can't. You don't understand what root access means. It is NOT similar to "restarting a system from scratch." Try, "similar to reinstalling a computer operating system from the metal up." – Wildcard Oct 21 '15 at 15:13
  • Working as root all the time is a Bad Idea, even on your own system. A much better analogy is: In homemade electronic equipment, using bare wires (uninsulated) because "it's your equipment" and you're "not planning to expose it to weather." It's still a Bad Idea because of the ease with which you can totally destroy your equipment without intending to. "But it's so inconvenient, because if I want to splice in a switch I have to use wire strippers." Yes. You do. Moral of the story: Don't work from a root login on anything but a throwaway virtual machine. – Wildcard Oct 21 '15 at 15:15
  • @Wildcard: A working TV gives me one service: the ability to watch programs. I get into the menu and erase everything -> I do not have the service, just a useless box. I have just used my administrative privileges to erase the only useful data on that device. This is the same as working as a standard user on a PC. The difference is that I almost never need to MANAGE the TV (modify the firmware for instance), something which I do on a daily basis on a PC I administer. If I remove the OS than bad luck, I need to install it again, that's all. – WoJ Oct 21 '15 at 15:27
  • @Wildcard: (cont'd) This is FAR FAR less worse than losing the service, a mere inconvenience actually. It is just a matter of assessing priorities: in your case the OS is more important than the data - your choice. I am sorry not to have your experience but not everyone can understand what 'root' access mean and I will have to live with that. – WoJ Oct 21 '15 at 15:28
  • If you remove the OS and you don't have a backup, all your data is gone as well. If your backup is physically attached to your computer, you can nuke that by bad root-privilege commands along with your computer. If your backup is mounted as root (which is easy) and set up properly, you can't mess it up as a normal user, even if you delete all your files on the computer. Do you wear insulating gloves and shut down the house power when you open the microwave to put food inside? I would think not. Do you open up the casing and fiddle with the wires with the power on? Maybe you do, but I wouldn't. – Wildcard Oct 21 '15 at 15:48
  • 1
    This is why there is risk assessment. You assess the risks of doing something (which has its pros and cons) and accept, mitigate or insure. Recovering can be simple (docker, VM snapshots) or difficult (install form scratch) - it is a matter of planning and, again, assessing. But as you mentioned, I do not understand what root access means so be it. – WoJ Oct 21 '15 at 15:59
1

In defense of the person that wrote the initial question, I had this same question in years past, but I took a different approach.

Most of the answers here could just be played on a loop, because they all keep stressing the same point about sudo and root. Let me add a different perspective to this topic:

The way I learned Unix AND Linux inside out was by using one of my computers as a "guinea pig." I would install SCO Linux, and eventually Solaris and then Linux much later, all the while joyfully experimenting as root so I could read and/or explore the directory hierarchy and all files with unrestrained access, also creating "normal user" accounts on my home-grown multi-user box, even though I was the only user. And I'm glad I did it that way. I learned so much about the "Unix Philosophy" and the way Unix was intended to be used by my experimenting.

I had a blast learning about security, and also running dangerous commands by typing rm -rf /* in a terminal as root. (DO NOT DO THIS! IT WILL HOSE YOUR SYSTEM!!) I did things like this and many other commands, just to see what would happen in real-time. I did these kind of things knowing the consequences before hand, yet I still learned a lot by doing so. I was using SCO Unix LONG before the web even existed (yes, I'm that old!) and experimenting this way was invaluable to my learning.

So what I'm saying is if you don't mind doing re-installations when something goes wrong, use su or login as root all you want and configure/hack away! You'll learn a hell of a lot by doing so.

Just remember that the advice that has been repeated a lot here was reiterated for a good reason: Best practice protocols have evolved over the decades as compsec has evolved, and you SHOULD pay attention to them, even as a home/single user of your system. By doing so, good sysadmin hygiene/habits will become second nature for you.

Just some food for thought on the topic of su and sudo. Happy hacking!

mem
  • 31