Question about chown

rado84

Well-Known Member
Joined
Feb 25, 2019
Messages
757
Reaction score
623
Credits
4,705
I finally found out how to have an ext4 FS automatically mounted at startup, so now I'm gonna migrate almost all of my storages to ext4. One thing troubles me though - setting user rights with chown: when you set rights with chown, do they remain forever? Or do I have to set them up again, IF one day I have to reinstall Arch for whatever reason?
 


They are kept forever as they are part of the file system.

As far as I understand, what you need to care about when you reinstall your system are the group and user ID of the owners, for them to match.

I presume that such situation might have been experienced by someone else in the forum, and it’s the same that happens when you have your /home in another partition and reinstall the OS in /.

My upfront idea to test would be focus on single-user groups I’d create, and for which I can control the GID, rather than on users and groups that are default for the system, present in a lot of files, and that may change at the distribution’s will, or that may be different from one distribution to another.
 
And now that I think of it, you may be able to translate UID and GID it my means of fstab / mount, anyway.
 
And now that I think of it, you may be able to solve it my means of fstab / mount, anyway.
Yeah you can just set your ext4 filesystems up in fstab, once the ownership and permissions are set once they will remain.
 
And now that I think of it, you may be able to translate UID and GID it my means of fstab / mount, anyway.
I was told I didn't need to add uid and gid to the string in fstab for an ext4 since that's set with chown.

As for the concerns about home and groups, that's not a concern to me bc I always install home on the same partition where Linux is and the group always has the same name as my user. I don't like it the other way where home is on a different partition.
 
If I am understanding your concerns correctly...

The chown permissions remain - and so long as your UID is 1001 (or is it 1000?, whatever the default is) you won't actually have to mess with it again - even after re-installing - as the default user will have the default UID.

Now, if you make another user besides the default user, they'll need permission to access the disks.

I have chowned disks that have gone through all sorts of installs and never need to be adjusted.
 
That’s great to know, I wasn’t certain that the defaults for the first user were 1000 (or 1001). Thanks!
 
1000 is provided at installation time.

Wiz
 
1000 is provided at installation time.

Wiz
If my reasoning is correct, that would explain why I didn't have to set uid or gid in fstab for ext4. When the partitions were NTFS I had to state both uid and gid in fstab but now I'm thinking these were unnecessary because of my reasoning below.

1000 is root and when I installed Arch I gave my user (rado) administrative rights during the installation itself. Then, through the GUI I set up a group with the same name and set it to have the same rights as the root group. So without knowing (back when I installed Arch) I've set my user to uid and gid 1000. :)
 
Slight correction. Root is 0. Your user is 1000.

Code:
sudo cat /etc/passwd

(That'll show user IDs.)
 
Slight correction.

Significant, I would say. Root's UID and GID is zero, and that is why it is so powerful.

My output for David G.'s command is

Code:
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:65534:65534:Kernel Overflow User:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
unbound:x:999:999:Unbound DNS resolver:/etc/unbound:/sbin/nologin
tss:x:59:59:Account used for TPM access:/dev/null:/sbin/nologin
geoclue:x:998:998:User for geoclue:/var/lib/geoclue:/sbin/nologin
rtkit:x:172:172:RealtimeKit:/proc:/sbin/nologin
polkitd:x:997:997:User for polkitd:/:/sbin/nologin
pipewire:x:996:996:PipeWire System Daemon:/var/run/pipewire:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/usr/sbin/nologin
systemd-oom:x:995:995:systemd Userspace OOM Killer:/:/usr/sbin/nologin
systemd-resolve:x:193:193:systemd Resolver:/:/usr/sbin/nologin
systemd-timesync:x:994:994:systemd Time Synchronization:/:/usr/sbin/nologin
systemd-coredump:x:993:993:systemd Core Dumper:/:/usr/sbin/nologin
flatpak:x:992:992:User for flatpak system helper:/:/sbin/nologin
avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
sstpc:x:991:989:Secure Socket Tunneling Protocol(SSTP) Client:/var/run/sstpc:/sbin/nologin
chrony:x:990:988::/var/lib/chrony:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
usbmuxd:x:113:113:usbmuxd user:/:/sbin/nologin
openvpn:x:989:987:OpenVPN:/etc/openvpn:/sbin/nologin
colord:x:988:986:User for colord:/var/lib/colord:/sbin/nologin
abrt:x:173:173::/etc/abrt:/sbin/nologin
setroubleshoot:x:987:985::/var/lib/setroubleshoot:/sbin/nologin
nm-openvpn:x:986:984:Default user for running openvpn spawned by NetworkManager:/:/sbin/nologin
openvswitch:x:985:983:Open vSwitch Daemons:/:/sbin/nologin
nm-openconnect:x:984:980:NetworkManager user for OpenConnect:/:/sbin/nologin
lightdm:x:983:979::/var/lib/lightdm:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
vboxadd:x:982:1::/var/run/vboxadd:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/usr/share/empty.sshd:/sbin/nologin
dnsmasq:x:981:977:Dnsmasq DHCP and DNS server:/var/lib/dnsmasq:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
chris:x:1000:1000:chris:/home/chris:/bin/bash

So root at top, and chris at bottom.

Each output line consists of seven (7) fields, which can sometimes include an empty field looking like this.

::

Redhat have an article here which explains

https://www.redhat.com/sysadmin/user-account-gid-uid

Avagudweegend, off to look for music for Rock Roxx ;)

Chris
 

Members online


Top