62

When I do a ls -al, I can see the owner and group of files or folders. However, I recently changed my UID, so how do I find out if all my folders belong to my username and the new uid?

muru
  • 197,895
  • 55
  • 485
  • 740
john smith
  • 3,033
  • I am not sure about the question. Are you meaning that you want to find all the files with your old UID and changing their ownership to the new one? – Rmano Nov 17 '15 at 22:00

4 Answers4

101

Well, If you meant that you want to see the UIDs of the file then ls command can help.

You can use ls with n flag.

    ls -n

-n explanation from man page :

-n, --numeric-uid-gid
              like -l, but list numeric user and group IDs.
damadam
  • 2,833
imox
  • 1,173
5

Well, linux tracks ownership by uid only so

find / -uid 1000

Change the uid 1000 to the uid you wish to search on.

Panther
  • 102,067
  • It found loads and said permission denied. – john smith Nov 17 '15 at 20:12
  • There doesn't seem to be a process in Ubuntu to create the first user account with a specific UID. If you want to use a non-default UID, it appears you have to break everything in your system by changing the UID & then try and fix parts of it when you find the problems. It's really terrible & I'm absolutely lost as to what has to change and where everything that needs to change is located. – john smith Nov 17 '15 at 20:13
  • No, you have to change the uid properly, best from a live usb. You can probably select a uid using the advanced options in the installer. See also https://muffinresearch.co.uk/linux-changing-uids-and-gids-for-user/ . But yes, is you go changing things , especially system settings, without understanding how, you will break ubuntu. – Panther Nov 17 '15 at 20:21
  • What I normally do is install the system creating an administrative user (say "defaultadm") and then from there I create, using adduser, my user which has a different, special UID (you know, in 1992 we had a personal UID to share file with NFS that had no UID tables then, and I got sentimental with it :-)). This way is clean and you'll have no problem whatsoever. Trying to change an UID all over the system is almost impossible --- it's not just file ownership, it's into some file too --- think /etc/groups. – Rmano Nov 17 '15 at 22:03
1

$ ls -lnR yourdir

  • In case information is needed of a directory
SH'
  • 23
1

For checking the uid:gid of a directory owner:group

$ ls -nd /path/to/directory
Salim
  • 111