![]() |
LXer: The Ultimate Sudo FAQ — To Sudo Or Not To Sudo?
Published at LXer:
Sudo is a simple program which allows the administrator to give regular users extra permissions to execute the commands they would normally not be allowed to use. In order to use sudo you need to configure it properly. This FAQ is supposed to help you with this task. Read More... |
The Polish 'sudo' tutorial does not address "To Sudo Or Not To Sudo". It shows how to use 'sudo' but doesn't address when 'sudo' is needed.
How does one know when they need 'root' privilege? I've 'sudo'ed what to me was system-type stuff only to be told by Linux gurus, "Don't run this as 'root'". At other times, some system-type task can only be accomplished as 'root'. How is one to know? (Hint: Getting an error message is not a sufficient clue.) Another thing: (I write this as a Linux novice, but this is my notion...) When you 'run as Administrator' in MS-Windows, you merely borrow the Administrator's credentials, not the Administrator's identity. Thus, you end up as owner of anything that's created. But in Linux, when you 'sudo' or 'su', you apparently BECOME root, so 'root' winds up being the owner of things that are created. That's very different. Linux appears to work around the problem by setting rights to: '-rwxrwxrwx'. I don't much like that. I'm probably wrong in half of what I write about above. If so, I'd sure like to be straightened out. |
Hi,
Quote:
Quote:
Evo2. |
Hi evo2. You have over 3400 posts, so I'm going to consider you to be an authority. Now, up front I want to acknowledge your authority and I also want to confess that, 1, I'm a Linux novice, and 2, I've gotten thrashed in some Linux forums recently and have been accused of being a troll. I'm sure that in my detractor's eyes I appeared to be a troll. But "Don't feed the troll" can be an effective way to evade questions, can't it? I ask hard questions because I'm a computer architect.
Quote:
I recently installed 'Evolution' and 'lxmed'. I installed 'Evolution' via 'mintInstall' (which required me to supply the 'root' password - I guess invocation of 'gksudo' is built-in), but I had to install 'lxmed' manually. In the 2nd case, how am I to know whether to 'sudo' or not? Of concern is not that I might not 'sudo' when I should because I assume that, in that case, the install will fail. My concern is that I'll use 'root' to install something that shouldn't be installed as 'root', as when the Linux gurus told me I'd screwed up - BTW, I don't know why that was a screw-up... well, maybe I do: 'root' will wind up as 'owner'. Quote:
You also recommended consulting 'man' pages. In the case of lxmed, there's no 'man' page and no 'info' page. What do you do? (I have a lot more questions, but this will do for now.) Thanks - Mark (who's just trying to figure it out in advance so he doesn't wind up repeatedly reinstalling during his learning period). |
Quote:
Quote:
Quote:
Quote:
|
Since I have already stated my own thoughts about when and when not to use sudo I hope others won't mind if I just quote myself. ;)
Quote:
Quote:
|
Quote:
|
Hi,
Quote:
Quote:
Quote:
Code:
mkdir /opt/Foo-3.14When installing in /usr/local I can usually do everything as evo2, since I've made /usr/local writable by members of the group "staff" and I've put evo2 in that group. I like this method becuase it ensures that what I install 3rd party software (that has not undergone the same sort of auditing as the code from the official Debian repos), I am not running any of the install scripts as root. Any damage that these scripts is reduced to the permissions of the user evo2. Eg doing something nasty/overwriting files in places like /bin/, /usr/bin/, /usr/lib and so on. Code:
You also recommended consulting 'man' pages. In the case of lxmed, there's no 'man' page and no 'info' page. What do you do?Quote:
Evo2. |
You've answered my questions, Tobi.
Not to quibble Quote:
Quote:
Quote:
Unless you get back here and tell me I misunderstood, I'll stick with your advice to first try installing as an ordinary user, and then using 'sudo' only if that doesn't work. Thanks - I'm off to see the wizard. Ciao - Mark. |
Dear ruario,
Quote:
PS: And one distinction that should be made that Linux gurus don't usually address is the difference between 'su' and/or 'sudo' in Linux (or Unix) versus 'run as Administrator' in MS-Windows, to wit: When an ordinary Linux user elevates via 'su' or 'sudo', the $USER becomes 'root', whereas when an ordinary Windows user elevates, the $USER remains 'mark' in my case. A further complication: 'su' retains 'mark' as $USERNAME while 'sudo' changes $USERNAME to 'root'. In other words, In Windows, a user borrows the Administrator credentials while fully retaining his/her identity, whereas in Linux, a user's identity is either partly ('su') or fully ('sudo') buried. This difference in ownership has to have an effect. |
Quote:
Try running whoami, under su and sudo, e.g. Code:
$ whoami Code:
$ echo $USERAs it happens to is possible to see the same problem with su if you were to do the following: Code:
$ su -c "echo $USER"Code:
$ su -c 'echo $USER'Quote:
|
Quote:
Quote:
I must admit that in hindsight my comment about sudo being pointless for single users is an exaggeration and a bit ranty, plus it somewhat contradicts the previous statement. I think I wrote it this way as it was in a Slackware installation thread and too many times I have read complaints from users who are new to Slack (typically from a distro like Ubuntu) failing to understand that sudo isn't needed for everything (as it happens the user from that particular thread does not say or imply this but others have). Anyway, next time I quote myself I'll leave that sentence out. ;) |
Quote:
Quote:
Code:
./configure Quote:
|
Sorry, Ruarí. I seem to have missed your post.
Quote:
Code:
mark@Iris ~ $ su mark@Iris ~ $ sudo envQuote:
|
| All times are GMT -5. The time now is 11:47 AM. |