9

I am wondering why directories such as /usr and /usr/local/ are owned and created by root. Usually I am logged in as a normal user and I want to store programs that I personally use in these dirs. For example the Android Studio are stored there. Whenever, I need to make an update or to make any kind of change, permission are not granted because I am not logged in as root.

The directory name "usr" already implies that (normal) user based programs are supposed to be there.

Didn't I get the concept behind this directory?

null
  • 1,231
  • 7
    usr = unix system resources... nothing to do with user :) – Jacob Vlijm May 02 '16 at 13:43
  • 1
    @JacobVlijm thats actually a backronym, it seems, look at pages 13,14 (paginated as 8,9) of http://bitsavers.trailing-edge.com/pdf/bellLabs/unix/PreliminaryUnixImplementationDocument_Jun72.pdf, they used /user. – guntbert May 02 '16 at 17:55
  • 1
    @guntbert WOW, looking around, there are many different explanations to what /usr literally stands for. The bottom line is that all (modern) explanations mention that it is about "shareabble, read- only data", and: "should not be written to". – Jacob Vlijm May 02 '16 at 18:24

4 Answers4

16

There is nothing that stops you from installing and running applications locally, without sudo privileges. Locally, meaning: in your own home directory. That is how it is supposed to be.

You shouldn't have the same permissions on directories you are sharing with possible other users on your system.

About /usr

The explanation on what usr literally stands for varies from unix system resources, to user system resources. The latter however should not be interpreted as owned by users, but as serving users, opposite to serving the system. Here we read about /usr:

Secondary hierarchy for read-only user data; contains the majority of (multi-)user utilities and applications.

The bottom line is that all (modern) explanations mention that it is about "shareabble, read- only data", and: "should not be written to"

Jacob Vlijm
  • 83,767
5

The directory name "usr" already implies that (normal) user based programs are supposed to be there.

Not since the Dark Ages of Unix history, if it ever was. What do the abbreviations "etc" and "usr" mean?

Now, the /usr directory is for the administrator to handle. However, almost all content in /usr is handled by packages, and /usr/local is where the administrator can install local software, outside of the package management system. Let's consult the Filesystem Hierarchy Standard:

/usr/local : Local hierarchy

Purpose

The /usr/local hierarchy is for use by the system administrator when installing software locally. It needs to be safe from being overwritten when the system software is updated. It may be used for programs and data that are shareable amongst a group of hosts, but not found in /usr.

Locally installed software must be placed within /usr/local rather than /usr unless it is being installed to replace or upgrade software in /usr.

For both /usr and /usr/local in a modern Linux system, normal users shouldn't have write permissions. On a single-user system, sure, you could give write access to /usr/local, but you have sudo privileges anyway (how often do you have to write to these directories?).

muru
  • 197,895
  • 55
  • 485
  • 740
0

Try placing the files you like in a sub-directory; such as ~/program/runthis

Then in /usr/bin do

sudo ln -s /home/username/program/runthis runthis

and then do

chown -h username:username runthis

That should create a symlink with only your permissions in the /usr/bin directory that points to a file that resides in a subfolder of your home directory. In that way the execution of that file only has your user permissions and never has root permissions as the symlink and the executables are owned by you no root. This would be fine for running on a personal machine and restricting the access of the program.

someon
  • 1
  • 1
    No never put files in /usr/bin/ and aways use the "/ocal" version (all bin directories also have a local/bin version). The 1st will delete what is there when you install software that uses your version, and /local never is changed by the system itself – Rinzwind Mar 19 '21 at 21:56
  • how would having the file owned by you and not root restrict access? – Zanna Mar 20 '21 at 14:46
0

The directory is for globally installed software by the admin. If you want to install software by yourself for yourself, do it in your home directory. Check the FHS for more information about standard locations.