Cannot change file permissions
I know how to use a Raspberry Pi, that's not the problem. I am trying to change file perms to execute compiled C code and even after using `sudo chmod -x |filenamehere|`, it still says permissions are denied. I am the only user and superuser on this system (Raspberry Pi 3 Model B) so I don't get it. Also, in pcmanfm, the default file manager, when I try to change the permissions, it does a reload of the folder page and it resets to default. I can provide screen proof, but the video may be slow.
Edit: Talking about +x in the chmod command, not -x
Edit: Talking about +x in the chmod command, not -x
Last edited by Kronix on Tue Jun 06, 2023 8:27 pm, edited 1 time in total.
Re: Cannot change file permissions
To change permissions with File Manager (pcmanfm), open a terminal and use sudo.
Code: Select all
sudo pcmanfm
Unless specified otherwise my response is based on the latest and fully updated RPi OS Bullseye w/ Desktop OS.
Re: Cannot change file permissions
Was there a typo in that? It's "+" to add a permission "-" to remove it. sudo chmod -x somefile will remove execute permission not add it.
Assuming, of course, the file is on a file system that supports Linux style owner, group, and permissions.
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.
All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides
All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides
Re: Cannot change file permissions
Right, yes, that was a typo. Just used to - arguments.
Re: Cannot change file permissions
Even this doesn't work! It doesn't do the little refresh, however, even though the perms aren't changing.klricks wrote: ↑Tue Jun 06, 2023 7:28 pmTo change permissions with File Manager (pcmanfm), open a terminal and use sudo.Code: Select all
sudo pcmanfm
Re: Cannot change file permissions
Three further things to check:
- Is the partition containing the file using a file system that doesn't natively support permissions (FAT, NTFS, a remote SMB share, etc.)
- Has it been mounted read only?
- Has it been mounted with the noexec option?
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.
All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides
All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides
Re: Cannot change file permissions
I have checked and it says it's VFAT. (but why tho) It isn't read only, as I put the code on there in the first place, but it may be a file system that doesn't allow perms.
Re: Cannot change file permissions
Where have you saved the file ? On my rpi's vfat is only used for /boot and vfat isn't a Unix filesystem, so Unix filesystem tools do not work.
Re: Cannot change file permissions
Well, the file is stored on my 16gb USB drive formatted with vfat in ./Progamming/C/
How can I format the drive?
Edit: Forgot about Imager
How can I format the drive?
Edit: Forgot about Imager
Re: Cannot change file permissions
So I reformatted the drive using Imager (FAT32) after moving my files from it to a safe folder. When I move them back, an error occurs and there are a few files left in the backup folder. Then I find that the drive can no longer be accessed and so I have lost everything (except for a few Spotify application files because I wanted portable Spotify). How is this happening? And why is Linux weird?
Re: Cannot change file permissions
It sounds like you used another non Unix filesystem 'fat32', you should have used a Unix filesystem such as ext4.
Why your files have disappeared, who knows, we were not there when you did the copy (you did do a copy ?).
Linux isn't weird, it is just different from Windows.
Why your files have disappeared, who knows, we were not there when you did the copy (you did do a copy ?).
Linux isn't weird, it is just different from Windows.
Re: Cannot change file permissions
Do any of the filenames have mixed CaSe?Kronix wrote: ↑Wed Jun 07, 2023 9:29 amSo I reformatted the drive using Imager (FAT32) after moving my files from it to a safe folder. When I move them back, an error occurs and there are a few files left in the backup folder. Then I find that the drive can no longer be accessed and so I have lost everything (except for a few Spotify application files because I wanted portable Spotify). How is this happening? And why is Linux weird?
In Linux filesystems, file.txt and FILE.txt are 2 different files.
In Windows filesystems (FAT32 etc), file.txt and FILE.txt are treated as the same file. This can lead to loss of files when copying BTDT.
Also I don't think pcmanfm supports auto refresh. You may need to press F5 to refresh.
Unless specified otherwise my response is based on the latest and fully updated RPi OS Bullseye w/ Desktop OS.
Re: Cannot change file permissions
Well, I don't think any of the files have mixed case or the same name, but even if it did, it doesn't explain why I can't access the drive. When I use lsusb the drive is there, but anywhere else it's not accessable.
Re: Cannot change file permissions
FAT32 (and all other varients), exFAT, NTFS and other non linux native filesystems have no support for owner, group, and permissions. What you see is set in the driver, the same for all files, and cannot be changed with chmod or chown. FAT/exFAT don't even have a concept of owner or group and the only permissions it supports are "read only" and "archive".Kronix wrote: ↑Wed Jun 07, 2023 9:29 amSo I reformatted the drive using Imager (FAT32) after moving my files from it to a safe folder. When I move them back, an error occurs and there are a few files left in the backup folder. Then I find that the drive can no longer be accessed and so I have lost everything (except for a few Spotify application files because I wanted portable Spotify). How is this happening? And why is Linux weird?
You have two choices:
- Reformat to ext4 or another Linux native file system
- Mount it with different options so everything on it has the execute bit set.
Code: Select all
man mount
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.
All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides
All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides
Re: Cannot change file permissions
But how can I detect the USB drive, let alone mount it, if I don't know how? I've tried websites, forums, even AI. No luck. It even isn't showing in Imager! I've tried many things except for physical inspection/potentially reparation, which I don't want to do as i don't have the resources.
The only thing that allows me to know the USB is still working to an extent is that it shows up on without any errors:
Edit: At least I don't think...
The only thing that allows me to know the USB is still working to an extent is that it shows up on
Code: Select all
sudo dmesg
Code: Select all
[ 4677.662375] usb 1-1.4: new high-speed USB device number 8 using dwc_otg
[ 4677.793225] usb 1-1.4: New USB device found, idVendor=1e3d, idProduct=198a, bcdDevice= 1.00
[ 4677.793277] usb 1-1.4: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[ 4677.794312] usb-storage 1-1.4:1.0: USB Mass Storage device detected
[ 4677.795440] scsi host0: usb-storage 1-1.4:1.0
[ 4678.833059] scsi 0:0:0:0: Direct-Access ChipsBnk Flash Disk 5.00 PQ: 0 ANSI: 2
[ 4678.834196] sd 0:0:0:0: Attached scsi generic sg0 type 0
[ 4678.835154] sd 0:0:0:0: [sda] Media removed, stopped polling
[ 4678.836556] sd 0:0:0:0: [sda] Attached SCSI removable disk
Re: Cannot change file permissions
So the OS is recognising your USB drive but may or may not be mounting the partition and you don't know where if it is.
It would appear from your references to pcmanfm you're working in the desktop even if not booting directly to it.
The default behaviour under the RPiOS desktop is to mount all partitions on a drive when it is plugged in unless you have am entry in /etc/fstab for a particular partition. Those are ignored and must be mounted manually.
An unmounted drive cannot be accessed through the normal tools (pcmanfm, ls, cd, etc.)
Automatic mounts by the desktop are to directories in the form /media/<username>/<volumelabel> e.g. /media/pi/mydisc
Things in fstab get mounted wherever fstab says but only automatically during boot. Use or to mount them after hotplug.
will show you what devices you have, what partitions they contain, if and where they are mounted (nothing in the MOUNTPOINT column means not mounted). Your USB drive should appear at least as sda and sda1. If there is no sda1 (or sda followed by any number) there are no partitions on the drive.
It would appear from your references to pcmanfm you're working in the desktop even if not booting directly to it.
The default behaviour under the RPiOS desktop is to mount all partitions on a drive when it is plugged in unless you have am entry in /etc/fstab for a particular partition. Those are ignored and must be mounted manually.
An unmounted drive cannot be accessed through the normal tools (pcmanfm, ls, cd, etc.)
Automatic mounts by the desktop are to directories in the form /media/<username>/<volumelabel> e.g. /media/pi/mydisc
Things in fstab get mounted wherever fstab says but only automatically during boot. Use
Code: Select all
sudo mount -a
Code: Select all
sudo mount /path/to/mountpoint
Code: Select all
lsblk
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.
All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides
All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides
Re: Cannot change file permissions
So my drive doesn't have any partitions? How does that even work? Can I find the missing partitions and therefore files?thagrol wrote: ↑Wed Jun 07, 2023 10:19 pmwill show you what devices you have, what partitions they contain, if and where they are mounted (nothing in the MOUNTPOINT column means not mounted). Your USB drive should appear at least as sda and sda1. If there is no sda1 (or sda followed by any number) there are no partitions on the drive.Code: Select all
lsblk
Re: Cannot change file permissions
I've no idea whether your drive has any partitions. You need to run either lsblk or sudo lsblk with the drive connected and examine the output.Kronix wrote: ↑Wed Jun 07, 2023 10:40 pmSo my drive doesn't have any partitions? How does that even work? Can I find the missing partitions and therefore files?thagrol wrote: ↑Wed Jun 07, 2023 10:19 pmwill show you what devices you have, what partitions they contain, if and where they are mounted (nothing in the MOUNTPOINT column means not mounted). Your USB drive should appear at least as sda and sda1. If there is no sda1 (or sda followed by any number) there are no partitions on the drive.Code: Select all
lsblk
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.
All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides
All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides
- FTrevorGowen
- Forum Moderator
- Posts: 7218
- Joined: Mon Mar 04, 2013 6:12 pm
- Location: Bristol, U.K.
Re: Cannot change file permissions
I would add that whilst "Imager" may "format" a drive (somewhat "indirectly") that, assuming you mean the Imager tool in Raspberry PiOS, is not its main purpose (which is to write O.S. images, which include "partitions" etc.). One of the main Linux tools for that is GParted which may appear under "System Tools" if it is installed by default. (It's quite a while since I installed legacy "Buster" on the P400 I'm posting from and I'm not sure if I had to install it or not.)thagrol wrote: ↑Wed Jun 07, 2023 11:04 pmI've no idea whether your drive has any partitions. You need to run either lsblk or sudo lsblk with the drive connected and examine the output.Kronix wrote: ↑Wed Jun 07, 2023 10:40 pmSo my drive doesn't have any partitions? How does that even work? Can I find the missing partitions and therefore files?thagrol wrote: ↑Wed Jun 07, 2023 10:19 pmwill show you what devices you have, what partitions they contain, if and where they are mounted (nothing in the MOUNTPOINT column means not mounted). Your USB drive should appear at least as sda and sda1. If there is no sda1 (or sda followed by any number) there are no partitions on the drive.Code: Select all
lsblk
Trev.
Begining to test Bullseye on some older Pi's (an A, B1, 2xB2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B, B+, and a A+) and Pi's with cameras with Buster on the P3B+, some P4B's & P400. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm
Re: Cannot change file permissions
I have already tried both things, and:
1. When using, no non-system drives are listed, and
2. GParted doesn't show or list the drive.
1. When using
Code: Select all
sudo lsblk
2. GParted doesn't show or list the drive.
Code: Select all
user@raspberrypi:~ $ sudo lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
mmcblk0 179:0 0 29.8G 0 disk
├─mmcblk0p1 179:1 0 2.2G 0 part
├─mmcblk0p2 179:2 0 512B 0 part
├─mmcblk0p5 179:5 0 32M 0 part
├─mmcblk0p6 179:6 0 256M 0 part /boot
└─mmcblk0p7 179:7 0 27.4G 0 part /
zram1 254:1 0 3.6G 0 disk [SWAP]
zram2 254:2 0 3.6G 0 disk /zram
Re: Cannot change file permissions
Do you have another computer you can test the drive with? If it works on there try a repartion and reformat.
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.
All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides
All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides
Re: Cannot change file permissions
Before I saw this post, yes, I tried it on two Windows computers: first one couldn't detect it, second one said it had limited connection. I am guessing limited connection means it's not being able to copy files because there isn't enough transfer speed.
Also, I tried troubleshooting the drive on Windows, it said there were no problems detected.
Also, I tried troubleshooting the drive on Windows, it said there were no problems detected.
Re: Cannot change file permissions
For new people:
To recap, I had problems with file permissions on my USB drive, so I reformatted it to FAT32 with Imager, after moving all of the files from it into a backup folder. I then tried to move the files back, but failed midway and now I can't open my USB or do anything.
To recap, I had problems with file permissions on my USB drive, so I reformatted it to FAT32 with Imager, after moving all of the files from it into a backup folder. I then tried to move the files back, but failed midway and now I can't open my USB or do anything.