0

How do I give myself read/write/execute permissions for all files in the root directory without making the system unusable?

Would this command do it?

sudo chown -R jacob3 /
sudo chmod -R a+rwx /

This is for my personal computer, where I (jacob3) am the only user. No private information is stored on my device without being encrypted.

The reason I want to do this is to avoid having to use sudo.

Also, I'm not actually going to do this. This is more of a hypothetical, in the sense of how this would be done.

closed as unclear what you're asking by Braiam, Stephen Rauch, Anthon, roaima, Rui F Ribeiro Jul 12 '17 at 22:06

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 19
    This command will make your system unusable. What problem are you trying to solve here? – doneal24 Jul 11 '17 at 16:36
  • 30
    Then just log in as root or change your user account's UID to zero. And then heed our advice to just reinstall from scratch after you brick your system. – DopeGhoti Jul 11 '17 at 16:42
  • 6
    Did you consider configuring sudo (in /etc/sudoers) to avoid typing any password? – Basile Starynkevitch Jul 11 '17 at 17:12
  • 14
    Why do you want to avoid sudo so bad that you would rather brick your system? – Kevin Jul 11 '17 at 17:40
  • 6
    @rmmaddy You can, however, very easily render it almost entirely unusable and unreachable, at which point "bricked" becomes a meaningless distinction. – Shadur Jul 12 '17 at 8:44
42

Changing the ownership of all files on the system is a very very very bad idea. Consider just for starters that the first command you propose will change the owner of sudo, which means it will no longer have root privileges to allow you to run the second command.

Ponder this.

You are immediately breaking fundamental tools and you haven't even finished doing what it is you think you want to do.

I would strongly suggest that you instead think about what the problem is that you are trying to solve for which you suggest your proposed solution.

sudo is provided for a reason; avail yourself of it.

  • 23
    sudo is provided to protect you from yourself. However, if you really want to do this, just change the UID of your account (in /etc/passwd) to zero, or simply log in as the root user. However, I can offer you nearly 100% certainty that you will inadvertently render your system unusable at some point, and the only advice you will get after you do this to yourself will be to restore from a backup (you will be keeping backups, right?) or to reinstall from scratch once this happens. – DopeGhoti Jul 11 '17 at 16:45
  • 3
    @Yoshimaster as others have said, it's a horrible idea but even if you do want to access anything without sudo, why would you want to give write permissions to everything (many things should not be writeable) and why in the world would you want to make everything executable? – terdon Jul 12 '17 at 12:16
  • 1
    @DopeGhoti The chance to render your system unusable by using root as the default login is not greater than rendering a Windows95 system unusable by the standard user with admin rights, is it? That is, it has happened in the past, but not terribly often. The main reason for restricted user rights is multiple users. Of course, if you are a power user and run funny scripts with the wrong glob or in the wrong path you may wreck havoc; but in all reality the user who wants to be root as a default is the least likely power user candidate and will just run a mail and http GUI client from KDE. – Peter A. Schneider Jul 12 '17 at 13:59
  • 1
    @PeterA.Schneider several tools require certain files to have specific permissions. Some of these tools would not work at all. Other tools makes assumptions of the permissions the files have and break in unexpected ways. sudo, ssh, lightdm are some of these tools. – Braiam Jul 12 '17 at 14:51
  • 1
    @Braiam [Somehow my original comment seems to have disappeared.] I was referring to Yoshi's comment that as root you'll likely brick your system by mistake at some point. I was saying that in Win95 and earlier we all were root, all the time, and didn't have fatalities that often.-- By contrast, it is totally obvious, as Dope points out in his answer, that the OP's idea to change owner and/or permissions system-wide will not work. – Peter A. Schneider Jul 12 '17 at 16:14
14

As DopeGhoti says, the classic way to do this is to log in as root. There is also a history of giving a second user other than root the UID 0. This gives them the root privileges, but with their own passwd settings e.g. password and home directory.

Modern desktop software e.g. gdm will be set up to refuse logins as root / UID 0. There may be methods to gainsay this in some cases.

https://fedoraproject.org/wiki/Enabling_Root_User_For_GNOME_Display_Manager

https://wiki.archlinux.org/index.php/GDM#Enable_root_login_in_GDM


Attempting to maintain full access for a user which is not UID 0, will be stymied because the permissions of system files are set according to the packages they are installed from. When you install new packages, or upgrade existing ones, it will set permissions on new files.

There will also be restrictions, e.g. on the files you don't own, you won't be able to change their mode including the executable bit.

Any daemons that rely on setuid programs would be broken.

Software which checks for sensible permissions on files containing authentication secrets or authentication configuration (e.g. sshd authorized_keys), will be broken.

It wouldn't make a lot of sense to try and do it this way.

  • 3
    Oh and furthermore, this will hose binaries that really need to be setuid. – Joshua Jul 12 '17 at 1:44
  • 4
    Not to mention that several pieces of software are designed to throw a massive fit if the permissions on their config files are not secure. – Shadur Jul 12 '17 at 8:38
5

Reiterating the above because it can't be said often enough: DO NOT DO THIS.

Even aside from the utterly ridiculous security risks you're inviting and the complete dismantling of every failsafe inherent in the access control design, this will break various parts of your system because certain bits of software are designed to throw a literal fit if they detect that a config file containing sensitive information is not properly secure.

Treat sudo the way you'd treat your seatbelt or bike helmet. Minor inconvenience to put on before every trip, but the first time you make a mistake on the road when you didn't wear it will be your last.

  • You're making a number of assumptions here. There are in fact plenty of times when this would be absolutely fine, such as a stripped back virtual machine that lives for all of twenty minutes per provisioning and has only a very specific set of tasks to achieve. Doing everything as root on one of those is not only perfectly safe, but perfectly natural. Not everybody is always working on a PC or a server connected to the internet. – Lightness Races in Orbit Jul 12 '17 at 16:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.