Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
9
rated 0 times [  9] [ 0]  / answers: 1 / hits: 2813  / 2 Years ago, thu, december 16, 2021, 5:20:39

A while ago I was installing NPM and I noticed that when I tried to run their install shell script using sudo it threw errors regarding some commands not being found. However when trying to run the same script without sudo everything worked like a charm.


I'm a new linux user, but from my understanding, sudo's permissions and visilibity are a superset of the normal user.


Why does it happen?


More From » permissions

 Answers
2

From my understanding, sudo's permissions and visilibity are a superset of the normal user.



Permissions, yes, but not necessarily visibility. Visibility of applications is governed by the PATH environmental variable


~$ printenv PATH
/home/vanadium/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/games

When a command is typed, the command interpreter first checks whether it is an internal command, or whether the command corresponds with the name of an executable file on the disk. The system then searches the directories listed in PATH until an executable file is found with a name matching the command.


As you see in the example, a user can have additional private directories in the PATH, searched only when this user is issuing the command. Thus, yes, a user account can have different commands available than the root user, i.e., the administrator, the role assumed when you use the sudo command.


Still, the permissions of an executable ultimately determine who can run the file. Provided the permissions allow it, an executable can always be run by providing the full path name on the prompt, e.g. /usr/bin/mount instead of just the file name, mount. And indeed, root can always execute as long as the executable bit is set, even if so only for the owner.


[#275] Friday, December 17, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ingssex

Total Points: 21
Total Questions: 122
Total Answers: 98

Location: Sweden
Member since Fri, Mar 26, 2021
3 Years ago
;