LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-30-2010, 07:40 AM   #1
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
How are file permissions handled on external media and other computers?


I was wondering, what if you had a flash drive formatted with an FS that has UNIX permissions. Then what if you copied some of your files onto it. And then put it into another computer that has a user account by the same name. WIll the user be able to access the files?

What if you named your own user differently on the other computer, will you be able to get your files?

What about tar archives?
 
Old 01-30-2010, 07:46 AM   #2
HasC
Member
 
Registered: Oct 2009
Location: South America - Paraguay
Distribution: Debian 5 - Slackware 13.1 - Arch - Some others linuxes/*BSDs through KVM and Xen
Posts: 329

Rep: Reputation: 55
AFAIK, it's not the username that is important, it's the user ID.
So, if your hypotetic user has the same UID in both systems (not necessarily the same username), then yes, (s)he will be able to access those files as well.
 
Old 01-30-2010, 07:49 AM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
It is the UID of the files that determined ownership. Yes, another computer with a user of that UID will have access to the filesystem.
On that computer "ls -l" will list the username that corresponds to the same UID. The filesystem doesn't contain usernames. The kernel doesn't use usernames either.

The filesystem itself will have user.group permissions. When mounted, the user & group of the mountpoint will change to reflect those of the filesystem. To access the filesystem, a user has to have the right permissions. The root user on that computer could use chmod and chown of course.

If you want the contents to be private, you will need to use an encrypted filesystem. E.G. use cryptsetup to create an encrypted partition before formatting it.
 
Old 01-30-2010, 07:51 AM   #4
White Tea Citrus
LQ Newbie
 
Registered: Sep 2009
Location: Slovakia
Distribution: Trisquel 5.0 Dagda
Posts: 27

Rep: Reputation: 0
First of all, hello MTK358!

It is just like if you'd download a file from a linux server. The permissions are the same, he who controls chroot and chmod, controls the file.
 
Old 01-30-2010, 07:51 AM   #5
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
I still don't quite understand. So I have Linux installed on my computer. I save my stuff to a flash drive. I reinstall Linux on the computer. My new accound has a different UID. Will I have access to my files?

EDIT: And if my new installation has another user with the same UID as my account on the original installation, will the new installation show the wrong username?

Last edited by MTK358; 01-30-2010 at 07:53 AM.
 
Old 01-30-2010, 07:54 AM   #6
HasC
Member
 
Registered: Oct 2009
Location: South America - Paraguay
Distribution: Debian 5 - Slackware 13.1 - Arch - Some others linuxes/*BSDs through KVM and Xen
Posts: 329

Rep: Reputation: 55
You'll have to check the permissions of your files

Edit: And, the new installation will show your files as belonging to the "other" user, yes.

Last edited by HasC; 01-30-2010 at 07:58 AM.
 
Old 01-30-2010, 07:55 AM   #7
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
what do you mean?
 
Old 01-30-2010, 07:58 AM   #8
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by White Tea Citrus View Post
First of all, hello MTK358!

It is just like if you'd download a file from a linux server. The permissions are the same, he who controls chroot and chmod, controls the file.
I thought that when you download a file it automatically belongs to you!

And what decides the ownership of the files taken out of a tar archive? The user that untarred it?
 
Old 01-30-2010, 08:06 AM   #9
White Tea Citrus
LQ Newbie
 
Registered: Sep 2009
Location: Slovakia
Distribution: Trisquel 5.0 Dagda
Posts: 27

Rep: Reputation: 0
The new distribution will show the wrong username (if the drive is not somehow encripted with a password or the other), but the file will be definitely accessible to other users according to the permissions set for other users:

So:

ls -laR "files on the drive" # and check for the string with 3-4 numeric characters which represent the user permissions (for more details type in "man chmod", man is a manual).
 
Old 01-30-2010, 08:09 AM   #10
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by White Tea Citrus View Post
The new distribution will show the wrong username (if the drive is not somehow encripted with a password or the other), but the file will be definitely accessible to other users according to the permissions set for other users:

So:

ls -laR "files on the drive" # and check for the string with 3-4 numeric characters which represent the user permissions (for more details type in "man chmod", man is a manual).
So i'd have to recursively chown the drive to restore ownership to me, right?

And is it right that before I chown it, the files will belong to the other user?
 
Old 01-30-2010, 09:46 AM   #11
White Tea Citrus
LQ Newbie
 
Registered: Sep 2009
Location: Slovakia
Distribution: Trisquel 5.0 Dagda
Posts: 27

Rep: Reputation: 0
I'd rather chmod or umask recursively if I'd want the files to be read by someone else. In other case, I mean if I would want the files to be read only to me and not anyone else, I'd use some crypting for the drive (but be careful about the password). Anyway a recursive chown for your files is a good way for reclaiming ownership
 
Old 01-30-2010, 10:10 AM   #12
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
What if I had a tar file that was made on my theoretical previous Linux installation, and I extract it on the new one? Will its contents belong to the other user on the new installation, or the user that extracted it?
 
Old 01-30-2010, 11:43 AM   #13
michapma
Member
 
Registered: Oct 2003
Location: Zürich
Distribution: Debian
Posts: 537

Rep: Reputation: 39
Quote:
Originally Posted by MTK358 View Post
So i'd have to recursively chown the drive to restore ownership to me, right?

And is it right that before I chown it, the files will belong to the other user?
To the first question: Not necessarily. As someone mentioned above, the file/directory permissions are set by UID. This doesn't depend on the installation. The following is hypothetical, I didn't test it. Let's assume that in an original installation, let's say Ubuntu, your user ID is 1001. Next you install Debian and you set up a user with ID 1001. The content previously belonging to the Ubuntu user with UID 1001 now belongs to to the Debian user with UID 1001. Note that the Debian install would not have to replace the Ubuntu install (e.g., multi-boot).

To find out what your UID is, just type the command id at the prompt. I believe the value is kept in /etc/group.

To the second question, yes, the file and directory permissions always belong to the original user until reset by chown.

Quote:
Originally Posted by MTK358
What if I had a tar file that was made on my theoretical previous Linux installation, and I extract it on the new one? Will its contents belong to the other user on the new installation, or the user that extracted it?
tar preserves permissions, using UID. So when you extract the tarball, the uid of the extracted directories and files are set as they were recorded. This has to make sense on the new system; if for example you extracted content with uid 1003 on a system without that had no user with uid 1003, then listing the content would show 1003 instead of a username.

This is useful when reinstalling a system when, for example, your /home directory is on its own partition. See the fourth post of this thread for a way to get the users set up in the new system with all their home content ready; it creates the user using the pre-existing uid.

Hope that helps.
 
Old 01-30-2010, 12:49 PM   #14
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Howcome when I download a .tar from the internet and unpack it, all the files have my username on them?
 
Old 01-30-2010, 12:57 PM   #15
HasC
Member
 
Registered: Oct 2009
Location: South America - Paraguay
Distribution: Debian 5 - Slackware 13.1 - Arch - Some others linuxes/*BSDs through KVM and Xen
Posts: 329

Rep: Reputation: 55
It could depend of your distro's implementation of tar. Read the distro's manpages about that.

Or, just by chance, the tar maker UID was equal to your user' UID

Last edited by HasC; 01-30-2010 at 12:59 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
External Hard Drive won't work with other computers zeebert Linux - Software 6 01-30-2010 06:35 AM
User names and file permissions on two different computers rosv Linux - Security 4 07-23-2009 10:10 AM
Sharing external wireless internet with two computers. fair_is_fair Linux - Wireless Networking 4 07-15-2007 04:18 PM
Setting up an https or other kind of proxy for external computers mysteriouslurker Linux - Networking 1 05-04-2006 08:16 AM
How to play a media file/ video file/mp3 file recorded in harddisk/cd-rom arindam Linux - Newbie 2 09-05-2003 10:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration