How to reset file owner back after chown command?

Hi, I was trying to install Yaourt after a fresh EndeavourOS install based on this: and the guide told me to add this bit:

SigLevel = Never
Server =$arch

at the bottom of the /etc/pacman.conf file. I did not have permissions to save the file after adding the bit, so I ran the

sudo chown -R <my user> /etc

command to gain permissions and save the file. But after saving it, now while trying to install something, I get the /etc/sudo.conf is owned by uid 1000, should be 0 error message in Terminal.

This happened once in past, and I fixed it by running the

pkexec chown root:root /etc/sudoers /etc/sudoers.d -R

command, which is not working this time.

Any tips on how to reset the owner back to fix this issue? I am very new to all of these steps - as well as to file permissions and other stuff - and am basically learning through experimentation with commands I find while looking up guides online.

Thanks in advance.

There are so many things here.

First that “guide” is terrible. yaourt hasn’t been maintained in many years. There are lots of options to use instead but yay is the one we include with our installs.

Umm…don’t ever do that. You irreversibly broke the permissions on /etc. The easiest solution at this point is to reinstall.

In the future, you don’t change the permissions so you can edit the file. You edit the file as root or use an editor which lets you save the file as root. For example, you could use sudo nano /etc/pacman.conf. Alternatively, an editor like kate would let you edit the file and then ask for your password when you tried to save it.


If you want to know what to do after a fresh install just follow the Welcome Screen, if you have any questions about it ask away. As @dalto mentioned that guide is terrible and most guide that show up on google are. As check out as it contains lots of useful information.

1 Like

Thanks for the replies. I did not know how to edit a file with root permissions, or that there were editors to save as root. Will use that for the future.

1 Like

P.S. I used to also use chown for gaining access to theme/icon folders, so I could paste downloaded themes into them. Is there a command that would enable me to do it without using chown?

You could use folders under your home directory for adding more themes/icons for the current user:

.icons, .themes or
.local/share/icons, .local/share/themes

If you want to “install” them system-wide:

sudo mv /path/to/source/ /path/to/target/


Most of us have broken an install or two in the past. It’s all part of the learning experience.

Lessons for the future:

Do not follow random guides online. If unsure, ask here.

Never change the ownership or permissions of files outside your home directory. Doing so without knowing exactly what you’re doing will break your system in a way that is extremely difficult, if not impossible, to repair (apart from reinstalling).

Be extremely careful whenever using the recursive option on any command. And if you’re doing it with sudo, reconsider what you’re doing and find some other way.

If you need to edit a root owned file, use a program that allows you to do that. If it is a terminal program, chances are you can safely run it with sudo. If it is a GUI program, it should have polkit support, if not, use a terminal program. Never use sudo with any GUI program. If you absolutely must use a GUI program to edit a root owned file, make a copy of the file in your home directory, change the permissions on the copy and edit that.


I have bookmarked this thread for reference :+1: thank you. My experience with forums of different distros is that this community is the most helpful and active, and that plays no small part in people’s choices of distros, I would imagine.


I would like to say, I don’t know why changing a file’s permission to edit it hadn’t occurred to me before; it’s not a good idea but does seem more of a natural solution (on first glance), doesn’t it?

I know right? Especially when you don’t really have experience, you aren’t aware of more advanced and granular solutions, so it seems natural.

Can I ask further about this? I started attempting to copy the theme files/folders with this command, but it was not working, and I realised it was because of spaces in the folders. After renaming them to remove the spaces, it worked. But I can imagine having to do a lot of operations in the future with files with spaces in their names. Is there a way to make the terminal recognise spaces in file/folder names, so that you don’t have to rename them?

This example can be used for files or directories:

file\ name\ with\ spaces

Example, to move a file named dog bone.txt to the folder named dog house from the Downloads folder.

mv /Downloads/dog\ bone.txt /dog\ house/dog\ bone.txt

To copy:

cp /Downloads/dog\ bone.txt /dog\ house/dog\ bone.txt**

Edited for clarity.



1 Like

In addition to what @linesma showed you, you can also use quotes.

cp 'my file with spaces and maybe other stuff like !?' /my/location

Please note that the man command is your friend.

Some example commands in terminal ( # starts a comment ):

man man    # see what 'man' is
man ls
man chmod
man chown
man cp
man mv
man rm
man find   # this is more advanced... but useful
man cd
man pwd
man sudo   # use sudo only if you have to
man nano   # editor
man bash   # this is huge, but you'll find lots of nice stuff

man manuel # to learn everything about @manuel is up to
:wink: :sweat_smile:


Actually, it leaves a lot out! :grin:

1 Like

Do you have your man-db.service enabled? :smile:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.