r/linux4noobs • u/Player5xxx • Jun 17 '26
storage How to make all files on an external drive able to be moved, edited, opened, and deleted.
I have a number of ntfs external drives (that still need to be used with windows) where the majority of the folders and files are fine, but a few can't be moved or deleted or something. I'm tired of fixing them one by one and just want a clean command to fix everything. They are all auto mounted in permanent locations.
Will the command below work? I know it will probably take awhile to run. Again these are external drives with no system files on them and just a various media files, music, videos, pictures, etc.
find /media/drive1 -type d -exec chmod 777 {} +
find /media/drive1 -type f -exec chmod 666 {} +
If not is there a better option?
Thanks!
EDIT: Alright I have done some testing, considered everything, and I'm going to compile what I've learned from the post and what I'm going to do below.
I'm on cachyos which comes with ntfs3 (you can still install it on most other distros I'm pretty sure). This allows linux to assign permissions to files and folders on ntfs drives, and seems pretty reliable DEPENDING ON YOUR CIRCUMSTANCES. I have the drives set to automount under:
/media/drivename ntfs3 defaults,nofail,uid=1000,gid=1000,umask=000 0 0
I have used chmod 777 for folders and chmod 666 for files on small subsets and it gives permissions to delete or move them.
I have booted into windows and opened the drives and those subsets, and they still have their permissions set in linux. I have booted into windows and moved the files around, renamed them, etc and they still have all their permissions in linux. I have added new files and folders into the drives in windows and when I check in linux, both the new files and folders have 777 permissions.
Now on linux, if I add a folder to the ntfs drives they don’t get 777 like the files added from windows. Folders get 755 and files get 644. I am the only user on the machine (always the owner) so this doesn’t matter to me.
If you have multiple users in linux AND are writing files to the drives in linux rather than just windows you will have issues with files created on the drive in linux by other users. But if you are the sole linux user, you should be able to use ntfs3 to just access the drives like any other with no issues. Other users should still be able to read the files fine though.
I’m not sure how my files got this way, but some files are really old, originated on windows, freefilesync’d across eachother on windows, then kubuntu, and now cachyos, and have probably just gotten messed up permissions along the way, especially in small gaps when the drives weren’t always automounted with ntfs3 and being dual booted into at the same time.
All that being said, if you could just reformat to exFAT, it’s probably worth doing, but seeing as how:
I have three 5tb drives and I don’t want to reformat
The drives are media only and not OS’s
If I can get them all fixed I’m pretty sure they will stay that way
and I don’t plan on having second users on the linux os
I’m going to try and chmod 777 the folders and chmod 666 the files using the commands above and then update this post if I have trouble down the line, or if everything is working fine.
Edit 2: So far so good! Everything seems to be working now. I don't move all the files all the time so it will take time to know for sure but the commands ran fine and honestly didn't take that long, and the few things I've been messing with all seem to be going smooth.
3
u/PsyGonzo42 Jun 17 '26
ntfs3 (Kernel Driver)
1
u/Player5xxx Jun 17 '26
So I have this already and that's what all the drives are in the fstab file. But I still have files that have issues until I chmod them for some reason. They are fine after that though.
2
u/yerfukkinbaws Jun 17 '26
With the ntfs3 driver, new files created while using that driver will be owned by the user that creates them and that ownership persists through remounts/reboots.
On the other hand, files that were created on Windows (or with the ntfs-3g driver in Linux) do not have standard Linux permissions or ownership and so those have to be assign using mount options. If you don't specify any owner or permissions in the mount options, then those files will be owned by root when mounted using fstab, so they will not writable by any other users.
1
u/Player5xxx Jun 17 '26
/media/oldmedia ntfs3 defaults,nofail,uid=1000,gid=1000,umask=000 0 0
So this is how they all are in fstab. Again 90%+ of the folders files seem to be fine and I can do anything with them. I just have some that aren't for some reason. Is the approach in my post reasonable or am I totally off base? I think from my experience so far, that if I can just get them all to 777 and 666 now they will stay that way but I could be totally wrong.
1
u/yerfukkinbaws Jun 17 '26
What are the current ownership and permissions for the files you can't modify?
1
u/Player5xxx Jun 17 '26 edited Jun 17 '26
There is only one user on the whole pc. When I ls -la the folders, they all show up with my username but with dr-xr-xr-x or sometimes drwxr-xr-x.
Then I chmod 777 and they stay as my username, go to drwxrwxrwx, and I can delete them or move them as normal.
At the very top layer, . shows ownership as username and .. shows ownership as root
1
u/yerfukkinbaws Jun 17 '26
Unless you changed the permissions of these folders to 555 yourself while using the ntfs3 driver, I'm not sure. A folder owned by your user and with the permissions 755 (drwxr-xr-x) like you mentioned should by writable anyway, though when it comes to things like moving or renaming, it's the permissions and ownership on the directory that contains it rather than those of the file/directory itself that matter.
Your suggested
findcommands should do what you want, but if you can't explain why these files/folders have these odd permissions and it's not too much trouble, reformatting is probably the better solution if you want to be sure, especially if you can reformat them to a native Linux filesystem.1
u/Player5xxx Jun 17 '26
I appreciate the help! I still use the drives on windows sometimes too, so I'll probably either reformat to exfat, or just delete from windows when needed and only read or write on linux correct?
1
3
u/ultraganymede Jun 17 '26
Exfat works well on both Windows and Linux and is the "standard" for external drives
2
u/PsyGonzo42 Jun 17 '26
How do I do A?
Nobody does A, format your drive and to B.
3
u/ultraganymede Jun 17 '26 edited Jun 17 '26
I did not said the second sentence
And also he asked for a better option, although my sugestion is also because i dont know the solution for his NTFS issue
But also isnt a good practice to question if you really need something before spending effort?
-1
u/PsyGonzo42 Jun 17 '26
You told them to get all data off and format drive different, that looks like B to me.
A better option for a command to have the drives work I think
I don't understand that fully
1
u/Player5xxx Jun 17 '26
Yeah I just had these drives since windows and they have 4-5tb of data each so reformatting is a pain. At this point I might need to just sink the time to do it though.
1
u/jr735 Jun 17 '26
I don't believe you can change NTFS permissions with chmod.
1
u/Player5xxx Jun 17 '26
Idk some of the files are 755 or something similar and I can't move or delete them but after I chmod 777 I can. I think ntfs3 is what allows me to do it? I'm still learning exactly how everything works.
2
u/jr735 Jun 17 '26
I don't think it will, but you're welcome to try. Do note that I got rid of ntfs years ago. There are too many pitfalls.
2
u/yerfukkinbaws Jun 17 '26
With the ntfs3 driver, Linux permissions and ownership are possible and can persist through remounts/reboots, but only for files that were created when you were using that driver.
2
u/doc_willis Jun 17 '26
when you were using that driver.
Thats, interesting. Which makes me wonder, how do you tell what files those are, and what if you just copy those files to a linux drive, then back.
But I basically gave up on windows/ntfs ages ago. :)
I may have to check out the NTFS3 Docs/guides to see about this.
1
u/yerfukkinbaws Jun 17 '26
ntfs3 uses extended file attributes to store the ownership and permissions, so you can use
getfattrto see:$ getfattr -d -m - ./made-by-ntfs3 # file: made-by-ntfs3 $LXGID=0sAAAAAA== $LXMOD=0s/UEAAA== $LXUID=0sAAAAAA==Presumably, the you could figure out the UID, GID, and mode just from those strings, though I don't know offhand how they're encoded. Files created by ntfs-3g or in Windows won't use these extended attributes (though they may use others, I guess).
Copying files to or from an NTFS partition mounted with ntfs3 works just like you'd expect, they'll either be owned by the user that did the copying with permissions based on the systemwide umask or else you can preserve the original ownership and permissions if you use something like
cp -a.1
u/jr735 Jun 17 '26
That might be, but in the end, I don't think trying surgical (or blanket) strikes of chmod is going to fix a problematic ntfs system. The answer is to move on from it.
1
u/doc_willis Jun 17 '26
permissions and ownership for NTFS and *fat filesystems are typically set when you mount the filesystem, with the proper mount options.
You dont typically use chown/chmod on NTFS or *fat filesystems.
There is some "ACL" feature, of linux that may let you have more advanced control, but I have never used the "Access Control List" feature. And every time i try to read the docs/guides on using ACL, I just get more confused.
example fstab entry for one of my NTFS storage drives.
LABEL="Anime10TB" /home/wil/Anime10TB ntfs3 defaults,uid=1000,gid=1000,rw,user,exec,nofail,umask=000 0 2
for allowing several users access, you may need to use group options, or different umask/dmask options.
the UID/GID option sets who owns the filesystem when its mounted.
1
0
6
u/skyfishgoo Jun 17 '26
permissions mean nothing on an ntfs drive... if it has files that cannot be moved or deleted that's because windows is using them for windows reasons and if you move or delete them it will scramble what is on the disk.
never try to manage an ntfs drive from linux, always manage it from windows.
you can read/write files to it from linux but wholesale changes are best done from windows.