Ubuntu – Does an application need root permissions if it modifies files in the “/” directory

application-developmentdebdirectorypermissions

I'm creating a program for Ubuntu that involves creation of files within the folder where the code is present.

What I want to know is: When a .deb package is installed, where do the contents go?

If a program makes modifications to or creates new files within the /... directory, does it require root privileges?

Best Answer

Strictly, the directory: / is the "root" directory of all directories. That includes all sub- directories, so includes your home directory as well.

You need additional privileges for all directories outside ~ (your homedirectory), so either you need to:

  • be member of a specific group (e.g. to share files or directories), or, more drastically,
  • you need sudo privileges

outside your personal home directory.

A .deb installer, to install items globally for all users, will therefore need t be run with sudo privileges, since it installs files and executables outside your home directory.

When a .deb package is installed, where do the contents go?

Although there are quite strict rules for using directories outside your home directory, there is no easy answer to that; it depends on the application, its role and what kind of application it is. See also here and here (among others).

If you want to get an impression on where files are installed, look inside an unzipped .deb installer of a simple application. It contains a scaled version of your system and shows where the files will be "projected" to.