Setting permissions / ownership

Note that I'm not talking about the OS drive, system files, programs etc - the equivalent of the C:. I am only talking about my own files, the data drive (D:). The default OS file settings would be unchanged, the OS would be applying protection just the same. I just want to make sure I don't lose access to the files my life depends on, just because another OS I install on a different PC (or the same one) thinks I am a different person.

If I have Zorin and Mint dual booting on my PC, I don't want the draft of a novel written on one of them to be restricted when I uninstall that OS and only access the file from the other. Likewise when I transfer the file to my writing laptop, or share a file with an editor, of pass some photos on to my family, or get a new PC and transfer all my files. Any restriction that stops the files working properly in those scenarios is a problem, hence me wanting to make sure that doesn't apply to my personal data files. Over the last 20 years I have installed or reinstalled nine different operating systems across five PCs, sometimes reinstalled more than once, so let's say up to 20 installations. I have transferred my backed up data drive contents to each new one that I use. The last thing I want is to be prevented from accessing and "owning" my own files!

As far as I can tell, the whole permissions and ownership thing is fine on the OS drive (and gets reset to a new user each time an OS is installed); and also fine is someone only ever has one PC and OS. But if applied to personal data files across so many PCs and OSs, then it's bound to cause problems if it (incorrectly) thinks each user is a different person, when really it is the same one, me, Karl Drinkwater.

This is not meant to be a direct answer to your question.

But I just wanted to show you other solutions for such situation - moving data between/among different machines.

Case 1.
One of our acquaintances had to move his data between 2 households after he divorced. He needed a desktop for his works. He bought a large capacity external HDD and saved his data only on that HDD.

Case 2.
I have a home made NAS (OpenMediaVault) and copy files (photos, video, music, text files, etc) I want to share with my family on it. This is another way to share files provided all machines are connected to the same network.

2 Likes

I guess case 1 is what I do when I transfer my files to a new PC. Whereas if I reinstall the OS or install a new one, my files are already there on the separate data drive - the new OS needs to access them exactly the same as if they'd been created in that OS, not see them as "owned" by someone else and restrict me (which is, I think, what Linux would do by default, as I found out when it stopped me backing up my files via an emergency Linux version).

In a way, this is my central question: how to stop Linux from seeing my files as "owned" by someone else if I access them from a different OS (e.g. a fresh install, new PC, different distro or whatever). And the only way to do that, as far as I can tell, is to make sure the permissions don't restrict the files/folders only to the current OS user.

[Re: case 2 - none of my family are in my house or town, I'm just thinking about general shares via USB sticks, email, Google drive etc - maybe I share my document of recipes or some pictures or something, I wouldn't want them to get blocked from making changes to the files.]

That really surprises me.
Unless those files are saved in HOME directory, there should be no ownership attached to the files in the external drive.

I have a multimedia drive which I can access from any machines I have here (3 laptops + 2 desktops) regardless of the OS on them.

2 Likes

Interesting, none of the stuff I read made that clear. Even in the posts above I thought I was clear that I was mainly referring to my data drive, not my OS drive. Is there any way to confirm that all the files and folders on my data drive have the same permissions and ownership? That's why I thought (due to them being created in so many places over the years) that running a single command on that drive would make sure that everything was fine, every folder and file with the correct permissions. Then, if I can also store my Desktop on that drive in its own folder, I'd be fine. That's what I'm after, making sure that drive is accessible for me from any OS, with no different historic permissions on anything.

You could have your HOME directory on the external drive.
It does not have to be in the default location.

Some users prefer to have a separate partition or a separate drive for their HOME directory.

In this case scenario, each file can have a permission issue since HOME directory is essentially a part of the OS.

But if you never have your external drive in such configuration, there should not be any permission issue. At least that was my experience since the time I used Ubuntu 8.

I have no answer to that question, since I've never experienced this issue myself.
I hope other forum volunteers can answer your question.

1 Like

I'm pretty sure your drive is mounted on boot, correct? Open a terminal and type:

sudo gedit /etc/fstab

In the window that opens you are looking for where it is mounted (/mnt/[volume label]), which will be after the uuid (a long number with dashes in it sort of like windows registry keys). You will see a group of 3 or 4 numbers, that is your permissions for the mount. It will have something similar to 007 or 0007, yours may be different. Change this value to all 0's. Save and reboot for it to take effect.

3 Likes

Ah, so permissions/ownership can be applied to a drive (/dev) rather than the folders and files (/mnt)? I'm confused by how the OS can summaries a whole drive if (potentially) the files and folders on it all have different permissions? Sorry if I missed the point there!

Thanks - this is what I see. Wow, that is a lot of codewords! I'm not sure which is my data drive partition, since that appears as /mnt/sda2/Data in Nautilus.
(Yes, the drive is always there when I am in the OS, so is mounted at boot. Its the one I keep all my files on so I use it continuously.)

Line 13, after auto add: umask=0000
Make sure to have space before and after (not touching auto or nosuid)

2 Likes

Sorry, I'm lost about what to type into the terminal - I'm new to this. :frowning:
Also, the articles I looked at said 0 = no permissions, 7 = all, so wouldn't 0000 be the opposite of what I need?
I just want to make sure all the files and folder on my data drive (not the OS drive) won't ever lock me out if I reinstall the OS, copy them to a new PC, access them via an emergency USB OS etc.

I checked my currently mounted external drive in fstab:

My entry is like this
(drive UUID) / ext4 errors=remount-ro 0 1

I saw your drive is set to
0 0

While mine is
0 1

2 Likes

I'm really sorry, I have no idea what the numbers mean! Permissions etc is a total mystery to me. The more I read, the less I can get my head round how it translates into real world scenarios like mine ... :frowning:

I wonder what @Aravisian might think about your fstab.

1 Like

It's an octal not the regular permission numbers and is equivalent to 777. You can look it up online.

I gave you everything you need to make it work....in steps....so I'm not doing it again. You were in the file as root...so you followed them fine once.

Good Luck

3 Likes

Aravisian thinks that Karl has a very good reason to be paranoid.

But... is being paranoid and over-worrying the issue. :wink:

karl, I think that given your profession as an author, with a large number of essential files, you fear that you will lose permissions to these files and lose access to them. This will not happen.
The Worst Case Scenario would actually be only that you may not have read / write access to a file on a separate drive. While annoying, this is not only not data loss, but due to its very nature cannot create data loss. You are actually more secure.
What you want it to eliminate the annoyance.
But first, we must establish whether or not you have this annoyance. Can you clarify this?

3 Likes

Ah, I'm learning a lot, sorry for being slow. And thank you for your patience. :slight_smile:

1 Like

Ha ha, you have me to rights!

Yep, maybe it is just paranoia. Basically I have my personal files (work etc) all on a separate HDD (it was D: in Windows). I've always done that. Sometimes I have reinstalled an OS (with or without the same "username") on the separate OS drive, but access my data files as before; sometimes it has been a new PC, so the data drive has then been filled with my files from the backup drive.

As such, my personal/data files have been created and modified on various computers and operating systems over the years. So I have a kind of worry that their metadata is in a bit of a mess - that different files and folders will be tied to different ownerships and permissions. I am worried about that potentially causing problems like I had once in Windows, where I couldn't make changes to some of my files because Windows seemed to think they weren't mine. So that's where the pranoia sets in.

Now, it may be that when I copied all my files off my backup drive to my new Linux PC all the permissions and ownerships got reset anyway and became the same. Or maybe when I reformatted half of the drive as an ext4 partition and put the files and folders on that they got reset. Maybe everything is fine there. It partly stems from the fact that there's no way to look at a drive as a whole, with its 100,000+ files and folders, and check that they all have whatever permissions and ownership they should, which is why I thought resetting them in some way might achieve that.

This is purely for my data drive, not the OS drive. I'm happy to let Linux do whatever it needs to do to that!

The situation was probably complicated by my inability to load Linux last week. I could boot into Windows but that couldn't read my data drive partition that is ext4. But that was fine. I knew I could reinstall Linux and I'd be able to (hopefully!) access my data drive as before, even though I might appear like a new user then.

However, I knew that reinstalling Linux would wipe my OS drive. And that, by default, Linux stores all my Desktop files on that drive. So I needed to pull them off before reinstalling Linux. But when I booted into Zorin from USB and tried to copy the Desktop files off my OS drive, it wouldn't let me, saying I didn't have permission or wasn't the owner, which is an example of the security being a barrier that got me more worried.

That's why I also thought that it could be a good idea to make sure my Desktop is stored on the data drive, not the OS drive. That would prevent that problem ever happening again. I'd be able to reinstall the OS, then follow whatever procedure put the Desktop on my data drive in the first place, and nothing would be lost. (Assuming that moving the Desktop to the data drive didn't keep restricted permissions that might lock me out - that there's be some way to make sure it acted like any other folder on my D drive).

So Desktop on D: would perhaps remove one of the problem scenarios where I know I could lose important files. This is fresh in my mind after last week's scare! My Desktop is my workspace for projects before they go into long term D: storage. The Desktop has current drafts of books, cover designs, current Kickstarter projects and fulfilment levels etc.

(Note: I don't want to move the whole Home set of folders to my D: - I don't use any of them, and when I reinstall an OS I like everything to be reset apart from my personal files. If the Home folders is anything like Windows User folders, it can fill up with all sorts of crud put in there by software, one of the reasons I never back that up - losing all the old stuff is part of a fresh install for me.)

Does that make sense? Sorry for writing another novella.

Yes, there is an easy way to do this and it was covered by @FrenchPress and @337harvey above.

It's actually safer than you worry. But please bear in mind, you are trying to flood your brain with a lot of learning quickly. You are impatient to get right to work.
I struggle with this mindset, so I understand it. I am impatient and I wish to have all the knowledge I need and I want it Now, Right Now.
Sadly, we must, at times, sit back and let experience teach us rather than attempting immersive learning. As long as your data is safely stored on the "D" drive, it is safe. So, you can afford to relax a little. And should you run into a permissions issue, which can happen and has happened to me recently even : One or Two commands issued in terminal will fix it right up.

Your real worry should be about the D drive developing bad sectors and failing.

Yes, this can happen. I always overcame this easily by mounting the drive as me, then entering my password. Easy peasy.

Yes, you can have your Home Directory on the Data Drive if you want to. And this would also have the bonus of backing up your Home Directory and all personal settings and configurations. :slight_smile:

I do not advise this. I understand your reasoning, but Home does not fill up on Linux like it does on Windows. Windows tends to mix Root and Home together in an illogical way.
But you can get most of what you need by creating the directories you want on the primary drive and using them instead of the ones in home. For example, redirect "Downloads" to the primary drive instead of to the home ~/Downloads directory.

2 Likes

Excellent, okay, that set my mind at rest. As long as there's a way to override ownership/permissions if I needed to, I can cross it off my list! Thanks.

It's why I do regular backups (and keep them off site). I once had a failure, bought a new (bigger, faster) drive, installed it, copied the files off my backup. I think I lost a bit of work from between backups but not much. But I am very keen on a good backup system (and have two backup drives which I alternate).

Excellent, it makes sense for me to do that. I had thought it would be easier to just do the one folder I want (Desktop), because when I was in
gedit .config/user-dirs.dirs
I saw that other folders could maybe be individually moved, though Desktop wasn't one of them (and as you know, I couldn't alter that file anyway without changing another setting which then stopped the right click New Document menu item from appearing). So storing my Home dir on my data drive would be a good thing to do.

If I did that, would the Home directories on my data drive have the same permissions/ownership as the other files on my data drive, or would they have the restricted permissions of their previous location on the OS drive?

It's okay, no need for that. I don't use any of these:

XDG_DOWNLOAD_DIR="$HOME/Downloads"
XDG_TEMPLATES_DIR="$HOME/Templates"
XDG_PUBLICSHARE_DIR="$HOME/Public"
XDG_DOCUMENTS_DIR="$HOME/Documents"
XDG_MUSIC_DIR="$HOME/Music"
XDG_PICTURES_DIR="$HOME/Pictures"
XDG_VIDEOS_DIR="$HOME/Videos"

It's why I was keen to get rid of them from the file manager, since they were just clutter for me. Thunar and Nemo do that nicely, easily letting me hide them, so that's no longer an issue.