brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: ls -n shows owners as numbers, which explains odd permissions on shares and containers

Permissions
~/tips/tip-permissions-ls-n-numeric-ids

ls -ln /srv/data

Prints UIDs and GIDs instead of names, so mismatched IDs become visible.

Names in ls -l are a lookup. The file system only stores numbers, and the name is whatever account has that number on the machine you’re looking from.

Show the numbers directly:

ls -ln /srv/data
id alice

When the permissions look right but access still fails, comparing these two usually explains it. A file owned by 1000 belongs to whichever user is 1000 here. On an NFS share, a USB disk moved between machines or a container bind mount, that can be someone else entirely, or nobody, in which case ls -l also prints the bare number.

Containers are where I’d expect this most. A database image may run as UID 999, and on the host that number belongs to some system account with another name, or to none. The files look owned by the wrong user, but for the container they are exactly right.

To fix ownership after a move, change it by number so there’s no confusion about which account you mean:

sudo chown -R 1000:1000 /srv/data

Before you run that, make sure 1000 is really the account that needs the files on this machine, and not just the first user of another one. Changing owners on container data to match a host user can break the container. In that case it’s usually better to keep the numbers and give the host user access through a group.

Further reading: ls(1) manual page

More Permissions tips sudo su -s /bin/bash www-data sudo setfacl -R -d -m g:media:rwX /srv/media sudo cp -r /srv/site /srv/site.r newgrp media sudo journalctl -k --since '10 min ago' | grep 'apparmor="DENIED"' All Permissions tips (30) All topics

Link