0

I need to change the permissions on a folder and its sub folders from 'root' to me 'andrew'. First I need to log in as 'root' to be able to change this - correct? The folder is - /usr.

Chown and Chmod commands have been mentioned to change permissions.

I can't change to root from the terminal as I don't know the password. Do I need to do something on boot up to log in as 'root'? I think I might.

I would appreciate an accurate concise answer. Please list the steps I need to take to do this.

Zanna
  • 70,465
  • 2
  • 9
    Do not change the ownership of /usr and its subfolders - you will likely break your system – steeldriver Aug 06 '18 at 14:30
  • to login in at root without root password, you can use sudo su but just avoid to connect directly with root; most case just need sudo, more safe – damadam Aug 06 '18 at 14:41
  • 2
    @damadam consider using sudo -i rather than sudo su, sudo -i gives better isolation. https://help.ubuntu.com/community/RootSudo#Special_notes_on_sudo_and_shells – Panther Aug 06 '18 at 14:54
  • What are you actually trying to achieve? As steeldriver said, changing ownership on /usr is a terrible idea. Almost certainly you should be using sudo to do what you need there, rather than changing ownership or permissions. You can also use sudo to run chmod and chown - there's no need to log in as root for that. – Zanna Aug 06 '18 at 17:17
  • What am I trying to achieve? I've recently installed the MAME arcade machine emulator and I need to be able to store ROMs in the -/usr/share/games/mame/roms folder. – Andrew Rodger Aug 07 '18 at 09:06
  • I tried to login to root with both sudo su and sudo -i and I get this error message: '/usr/bin/sudo must be owned by uid 0 and have the setuid bit set'. When I run chmod I get this error message: 'changing permissions of '/usr': Operation not permitted. Why is it not permitted? – Andrew Rodger Aug 07 '18 at 09:15
  • because you need root for that, and you can't use sudo now, because, as the first error shows, you're already recursively messed up the permissions of /usr with chmod or chown, which means you should reinstall Ubuntu to fix it easily, or faff around a lot to more-or-less fix it with difficulty. To copy or move files to a root owned location, you just use sudo, like sudo cp my-file1 my-file2 my-file3 /usr/share/games/mame/roms – Zanna Aug 07 '18 at 16:19
  • Iv'e not messed up anything root is still the owner!! Reinstalling Ubuntu would be ludicrous. I told you the command doesn't work and it gives me an error message so nothing has changed. Sudo cp doesn't work either as it gives me the same error message as sudo su and sudo - i: '/usr/bin/sudo must be owned by uid 0 and have the setuid bit set'. – Andrew Rodger Aug 07 '18 at 19:06
  • Maybe you can answer this question. Very simple. How do i log into root without knowing the password? Is their a default password? – Andrew Rodger Aug 07 '18 at 19:30
  • The error you are getting is caused by the sudo binary having incorrect permissions or ownership. I know the command I suggested (that's what you should have done instead) won't work - no command with sudo will work now because the permissions are wrong. What permissions have you changed? By default the root account on Ubuntu has no password (not a blank password) which means it can't be accessed. This is a security feature. It's possible (though unnecessary) to enable the account by setting a password for it, but you need sudo for that, so you can't. Read the links I gave to fix this. – Zanna Aug 08 '18 at 06:40
  • I've tried every possible solution to this problem but none of them have worked. I will clearly have to reinstall Ubuntu. This isn't totally annoying to me as I have very few programs installed, documents, pictures, videos, and music. – Andrew Rodger Aug 08 '18 at 12:08
  • I only wanted to be able to place roms in the /usr/share/games/mame/roms folder. Dragging and dropping doesn't work. A terminal option is - sudo cp my-file1 my-file2 my-file3 /usr/share/games/mame/roms. I was wondering if their is a way of doing the same thing in the GUI? Thanks for your help so far. – Andrew Rodger Aug 08 '18 at 12:15
  • Yes, you can run the file browser as root, being careful while doing so and closing the window as soon as you are done. The old way of doing this is to type sudo -i then in the root shell nautilus (nautilus being the file browser program) (don't forget to exit the root shell when done) but these days you may need help from this answer – Zanna Aug 08 '18 at 17:01
  • I reinstalled Ubuntu and then sudo cp command worked. Thanks for your help I appreciate it. – Andrew Rodger Aug 10 '18 at 08:53

0 Answers0