Changing file ownership for security reasions

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
mintybarrels
Level 3
Level 3
Posts: 170
Joined: Fri Mar 26, 2021 2:57 pm

Changing file ownership for security reasions

Post by mintybarrels »

Hi...

Here is a previous thread I'd like clarification on.

Code: Select all

 sudo find ~/ -user root
What does this do?

~/ (tilde slash) The tilde (~) is a Linux "shortcut" to denote a user's home directory. Thus tilde slash (~/) is the beginning of a path to a file or directory below the user's home directory. To my knowledge, The command means to find or search in your user home directory and find root files that for some reason was in there. (Most of the time these root files are from other apps that was installed by the user)

Code: Select all

    sudo chown -Rc $USER:$USER $HOME
This command changes the ownership of the output of the previous command from root to your User.


My question is... where is says $USER, should this be my $'username', the same one my home folder is named after?

Tx

MB
Last edited by LockBot on Tue Sep 26, 2023 10:00 pm, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
Pjotr
Level 24
Level 24
Posts: 20140
Joined: Mon Mar 07, 2011 10:18 am
Location: The Netherlands (Holland) 🇳🇱
Contact:

Re: Changing file ownership for security reasions

Post by Pjotr »

mintybarrels wrote: Sun Mar 26, 2023 4:54 am

Code: Select all

sudo chown -Rc $USER:$USER $HOME
This command changes the ownership of the output of the previous command from root to your User.


My question is... where is says $USER, should this be my $'username', the same one my home folder is named after?
No. Just use the command "as is". Don't change a thing.
Tip: 10 things to do after installing Linux Mint 21.3 Virginia
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.
Cosmo.
Level 24
Level 24
Posts: 22968
Joined: Sat Dec 06, 2014 7:34 am

Re: Changing file ownership for security reasions

Post by Cosmo. »

mintybarrels wrote: Sun Mar 26, 2023 4:54 am Most of the time these root files are from other apps that was installed by the user
No. This happens, if sudo gets used with graphical programs. A typical mistake.
mintybarrels
Level 3
Level 3
Posts: 170
Joined: Fri Mar 26, 2021 2:57 pm

Re: Changing file ownership for security reasions

Post by mintybarrels »

So, is this a command I should run regularly, after say, installing new programs from the software center?

I was under the impression that new programs/apps downloaded would live on the / directory?

This as I noticed it was an anomaly that autocpu-freq lived in my home folder.

Is that where it is supposed to live?

MB
Cosmo.
Level 24
Level 24
Posts: 22968
Joined: Sat Dec 06, 2014 7:34 am

Re: Changing file ownership for security reasions

Post by Cosmo. »

I told you, where the wrong ownership comes from. This answers your question.
User avatar
Midnight True
Level 7
Level 7
Posts: 1549
Joined: Wed Jul 20, 2022 3:23 am
Location: Southern and Southwestern area of Mato
Contact:

Re: Changing file ownership for security reasions

Post by Midnight True »

mintybarrels wrote: Sun Mar 26, 2023 5:59 am So, is this a command I should run regularly, after say, installing new programs from the software center?
to my experience No, this only occurs via manual installation of the user. Typically via github or gitlab if the developer did not package the app as app image or flatpak or snap. But running it every installation would be a good security practice in my opinion.
mintybarrels wrote: Sun Mar 26, 2023 5:59 am I was under the impression that new programs/apps downloaded would live on the / directory?
Yes indeed, please try this in the terminal

Code: Select all

whereis auto-cpufreq
though the binaries/dependencies resides on wherever folder you extracted it
mintybarrels wrote: Sun Mar 26, 2023 5:59 am This as I noticed it was an anomaly that autocpu-freq lived in my home folder.

Is that where it is supposed to live?

MB
i use auto-cpufreq too and it lives too in my /home, so far i have not encountered any problem except the manual finding of update for the app.
User avatar
AndyMH
Level 21
Level 21
Posts: 13760
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Changing file ownership for security reasions

Post by AndyMH »

mintybarrels wrote: Sun Mar 26, 2023 4:54 am My question is... where is says $USER, should this be my $'username', the same one my home folder is named after?
USER is an environment variable that contains your username, $ means the contents of. Try echo $USER in a terminal to see.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
mikeflan
Level 17
Level 17
Posts: 7159
Joined: Sun Apr 26, 2020 9:28 am
Location: Houston, TX

Re: Changing file ownership for security reasions

Post by mikeflan »

I was under the impression that new programs/apps downloaded would live on the / directory?
Everything in Linux lives in the / directory, including your home directory.
/ is the truest form of root - the mother of all roots :)
Locked

Return to “Software & Applications”