-5

The answer in How to solve "permission denied" when using sudo with redirection in Bash? says to use "sudo -i". Is this always going to make sure I have write permissions for every file and every program launched from terminal being able to edit any file I want? Because I am trying to edit the UI to something more to my tastes, it seems I really need to be digging deep into this distro and I keep running into permission denials repeatedly. Ubuntu 22.04 or whatever was the latest stable version as of a week ago.

  • 1
    The answer is Yes – Raffa Jul 31 '22 at 13:40
  • 2
    Best practice is to never log in as root, but use sudo to get elevated privileges only when needed. sudo <cmd> gives elevated privileges for that one command, sudo -i starts a (login-) shell and you will have elevated privileges until you exit that shell. Please read man sudo for further details. – Soren A Jul 31 '22 at 13:49
  • Textbook XY Problem: In comments, you finally revealed that what you are REALLY trying to do is edit the Firefox Snap. Snaps are provided on a read-only squashfs filesystem; even root cannot edit those read-only files. The actual solution for you is to not use the snap. Use a deb or the upstream installer to create Firefox files that you CAN edit. – user535733 Jul 31 '22 at 19:45

1 Answers1

3

You asked two questions:

Question #1

Is this always going to make sure I have write permissions for every file and every program launched from terminal being able to edit any file I want?

Is clear and can be squarely answered ... Assuming writable(not read only) file system … The answer is, simply, yes.

sudo runs commands as the user root ... try:

whoami

versus:

sudo whoami

The option -i logs you in to that root's login shell specified in the /etc/passwd database so you become root until you enter exit or terminate the shell ... This, however, means that root's login-specific resource files such as .profile or .login will be read by the shell.

Please see man sudo:

-i, --login Run the shell specified by the target user's password database entry as a login shell. This means that login-specific resource files such as .profile or .login will be read by the shell. If a command is specified, it is passed to the shell for execution via the shell's -c option. If no command is specified, an interactive shell is executed. sudo attempts to change to that user's home directory before running the shell. The command is run with an environment similar to the one a user would receive at log in. The Command environment section in the sudoers(5) manual documents how the -i option affects the environment in which a command is run when the sudoers policy is in use.

Question #2

Because I am trying to edit the UI to something more to my tastes, it seems I really need to be digging deep into this distro and I keep running into permission denials repeatedly. Ubuntu 22.04 or whatever was the latest stable version as of a week ago.

Is too broad and lacks details and can't be squarely answered as is ... so I suggest you move this part to a new post and provide more details.

Raffa
  • 32,237