[...] 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)
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:20sudoers
to allow them to execute those commands under a 'normal'/implied privilege token. – underscore_d Oct 19 '15 at 19:51sudo
when you shouldn't? A normal Unix user's commands should consist mostly ofcd
,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:41sudo !!
to re-run the last command you typed with sudo in front. – asfallows Oct 20 '15 at 17:54sudo su -
<- quick way to get a root prompt. – Criggie Oct 20 '15 at 22:12sudo -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:42sudo
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<username> ALL=NOPASSWD: /bin/command1, /bin/command2
and so on to thesudoers
file. – Alex Oct 22 '15 at 07:27./configure --prefix=$HOME/opt
beforemake
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:51sudo
privileges withoutsudo
": as others explained, those commands require administrator (or "root" in *nix lingo) privileges, notsudo
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:02i.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