How to Set Permissions On a USB Stick?

Issues and / or general discussion relating to Puppy


Moderator: Forum moderators

Post Reply
JusGellin
Posts: 851
Joined: Fri Jan 19, 2024 11:12 pm
Has thanked: 112 times
Been thanked: 114 times

How to Set Permissions On a USB Stick?

Post by JusGellin »

I seem to get myself into a lot of trouble when I use a usb stick between puppylinux and other logon type linux distros for data sharing.
I tend to set up thumbdrives used for data using puppylinux, which of course sets everything to root.
Also since I'm generally just using linux I format the drive as ext4.

Then when I try to write anything with linux, I can't do anything since the root has ownership of it.

What is the best way to set up a usb stick so files can be shared between puppylinux and linux?
Would it be better if I used linux to set them up and still have a bit of security on them?

Permissions have always been a mystery for what to do for me.

How would you set up a usb stick to share data, without having to touch changing permissions to use it?

Thanks

Last edited by Flash on Wed Nov 27, 2024 1:45 pm, edited 1 time in total.
Reason: Added question mark to a question
williwaw
Posts: 2151
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 196 times
Been thanked: 414 times

Re: How to Set Permissions On a USB Stick?

Post by williwaw »

JusGellin wrote: Wed Nov 27, 2024 12:58 pm

How would you set up a usb stick to share data, without having to touch changing permissions to use it?

Thanks

one way you can help without changing permissions
its more about how you access the files on your USB
I would access the files on the USB owned by root the same way you mount the drive. Dont you have to be root, (or have root privileges) in the other OS to mount?
that said, try mounting the USB under a directory owned by the user you normally work from in the other OS.

Last edited by williwaw on Wed Nov 27, 2024 5:42 pm, edited 1 time in total.
d-pupp
Posts: 426
Joined: Tue Nov 22, 2022 9:11 pm
Location: Canada
Has thanked: 245 times
Been thanked: 82 times

Re: How to Set Permissions On a USB Stick?

Post by d-pupp »

@JusGellin
Yes permission are an issue when switching between Linux Distro's as most of Linux uses a non root user.
To set your permissions in Linux you have 3 groups the owner, group, and other. The owner and the group are often the same but they don't have to be. Most Distro's use a permission like this ..

For files
owner rw
group r
other r

For Directories
owner wrx
group -rx
other -rx

This is because to cd into a directory you need x

This set up give the owner full control and everyone else read only.

What you have to do is change the owner of all you puppy files to the username of your other Linux Distro.
That will give your username full access to your puppy file and root can do anything anyways so doing things in Puppy will be the same.

One thing to look out for is anything you do as root like copy, move or create will be owned by root and not accessible by your other username until you change the owner.
Hope this helps

User avatar
wiak
Posts: 4311
Joined: Tue Dec 03, 2019 6:10 am
Location: Packing - big job
Has thanked: 70 times
Been thanked: 1296 times
Contact:

Re: How to Set Permissions On a USB Stick?

Post by wiak »

d-pupp wrote: Wed Nov 27, 2024 4:54 pm

What you have to do is change the owner of all you puppy files to the username of your other Linux Distro.
That will give your username full access to your puppy file and root can do anything anyways so doing things in Puppy will be the same.

The overall info all good and very useful, except above which is an important misunderstanding that often results in things not working as expected.

The user and group names are a convenience for humans. But these are mapped to numeric IDs which are what actually determines permissions to use resources. If, for example, user spot had UID 1001 on your system, you need to create a user with that UID on the other system, if not already assigned, and in general the name of that user may well not be spot. So if user mary had UID 1001 then she could access, say, spot's files on a hard drive partition or usb stick that spot had created on the other OS.

Summary: the user name is unimportant, it is assigned numeric ID that determines access permissions. Same goes for groups.

https://www.tinylinux.info/
DOWNLOAD wd_multi for hundreds of 'distros' at your fingertips: viewtopic.php?p=99154#p99154
Αξίζει να μεταφραστεί;

d-pupp
Posts: 426
Joined: Tue Nov 22, 2022 9:11 pm
Location: Canada
Has thanked: 245 times
Been thanked: 82 times

Re: How to Set Permissions On a USB Stick?

Post by d-pupp »

@wiak
Yes I agree usernames are just for us the system uses numbers.
Thie suggestion above would only work if the user ownership was set in the other Linux distro. It would also only work for one other system. If there are many disrto's involved it would not work for the reasons you laid out in your post.
However the only other option would be to use the other group which I can not recommend because it a very big security risk. One mistake with you network security and you could expose all your files to the Internet.

All in all Linux permission were meant to work inside a disto not across many.

That's the way I understand it anyway. Please correct me if I'm wrong.

User avatar
fredx181
Posts: 3386
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 438 times
Been thanked: 1485 times
Contact:

Re: How to Set Permissions On a USB Stick?

Post by fredx181 »

wiak wrote: Thu Nov 28, 2024 2:42 pm
d-pupp wrote: Wed Nov 27, 2024 4:54 pm

What you have to do is change the owner of all you puppy files to the username of your other Linux Distro.
That will give your username full access to your puppy file and root can do anything anyways so doing things in Puppy will be the same.

The overall info all good and very useful, except above which is an important misunderstanding that often results in things not working as expected.

The user and group names are a convenience for humans. But these are mapped to numeric IDs which are what actually determines permissions to use resources. If, for example, user spot had UID 1001 on your system, you need to create a user with that UID on the other system, if not already assigned, and in general the name of that user may well not be spot. So if user mary had UID 1001 then she could access, say, spot's files on a hard drive partition or usb stick that spot had created on the other OS.

Summary: the user name is unimportant, it is assigned numeric ID that determines access permissions. Same goes for groups.

Yes, I agree with that.
What I do is leave the files/directories owned as root as they are and then on the Linux system where you are running as 'normal' user, use sudo, e.g. to run the filemanager e.g. sudo thunar (or whatever) to have root access. (or perhaps it's recommended to use pkexec rather than sudo, not sure)

JusGellin
Posts: 851
Joined: Fri Jan 19, 2024 11:12 pm
Has thanked: 112 times
Been thanked: 114 times

Re: How to Set Permissions On a USB Stick?

Post by JusGellin »

fredx181 wrote: Thu Nov 28, 2024 3:38 pm

Yes, I agree with that.
What I do is leave the files/directories owned as root as they are and then on the Linux system where you are running as 'normal' user, use sudo, e.g. to run the filemanager e.g. sudo thunar (or whatever) to have root access. (or perhaps it's recommended to use pkexec rather than sudo, not sure)

I can see to do it this way.

I started to also look into ACLs. Is that something that could be used?
Or would this be another case of possible id uid problems?

Thanks

JusGellin
Posts: 851
Joined: Fri Jan 19, 2024 11:12 pm
Has thanked: 112 times
Been thanked: 114 times

Re: How to Set Permissions On a USB Stick?

Post by JusGellin »

Would it be true that the only way to secure a usb stick is to encrypt it?
Could a root user on any computer access a usb stick? - or reset read write permissions on one?

Thanks

d-pupp
Posts: 426
Joined: Tue Nov 22, 2022 9:11 pm
Location: Canada
Has thanked: 245 times
Been thanked: 82 times

Re: How to Set Permissions On a USB Stick?

Post by d-pupp »

I have been thinking about this issue. I have 2 versions of Vanilladpup 11 installed. The latest version just changed from run as root to run as spot. So I changed owner of all my files to spot. I can access all my files from both systems because spot is the first user with an uid of 1000.
I'm wondering if that would work on other distro's as long as the uid was also 1000?

d-pupp
Posts: 426
Joined: Tue Nov 22, 2022 9:11 pm
Location: Canada
Has thanked: 245 times
Been thanked: 82 times

Re: How to Set Permissions On a USB Stick?

Post by d-pupp »

@JusGellin Would you be willing to test my theory that any user from any distro as long as their uid is 1000 can access the same files?

It would be easy to test. I already know it works for me on 2 different installs of dpup11. It just needs to be tested on a different distro say one of the Kennel distro's

The process is strait forward and easy to reverse.

Login as a regular user on one of your Kennel installs
Check the uid.

Code: Select all

$ id
uid=1000(spot) gid=1000(spot) groups=1000(spot)

or cat /etc/passwd

Code: Select all

spot:x:1000:1000:,,,:/home/spot:/bin/bash

As root change the owner of some of your files to that username
chown owner:group files to change

Code: Select all

chown -R spot:spot my-files

Then test it on other distro's
This might be what you are looking for in your original post.

JusGellin
Posts: 851
Joined: Fri Jan 19, 2024 11:12 pm
Has thanked: 112 times
Been thanked: 114 times

Re: How to Set Permissions On a USB Stick?

Post by JusGellin »

@d-pupp

Wow! that works great.

I set up a USB stick on BookwormPup64_10.0.8 and the made a Test directory with a test file in it.
BW has uid=0(root) gid=0(root) so that's what these have to begin with.

Then I went to PopOS linux and ran the chown for the whole USB Stick so now it would have uid=1000 and gid=1000 for everything for the logged on user.
I could edit the file on the stick with the normal user then.

I also went to a live Linux Mint and was able to fully access the USB stick since it also had uid=1000 and gid=1000 but with its default user now named Mint.
I could edit and save the file on the stick using its normal user.

I think this will work for me for my own computers without any complications.

Thanks, I really appreciate better understanding of how I can do this.

I really like how I can keep the rwx the same all the time as the original set up for the USB stick.
Also when I again write something to it using puppy linux or KLV I just run chown again if I go to a mainline linux to be able to write to those files if needed.

d-pupp
Posts: 426
Joined: Tue Nov 22, 2022 9:11 pm
Location: Canada
Has thanked: 245 times
Been thanked: 82 times

Re: How to Set Permissions On a USB Stick?

Post by d-pupp »

@JusGellin Thanks for testing it. I'm glad it worked.
I like you have all my files separate from my Home folder. Only mine are on a separate partition. I now prefer to do most of my work as spot and only use root when I have to. Most of the stuff I do only needs read permission anyways and spot has that for most of the system.
I also have a custom setup script that works best when run as spot.

I think this can help a lot of people who are running multiple distro's

Thanks again for testing it out.

Post Reply

Return to “Users Help”