this post was submitted on 02 Mar 2025
9 points (90.9% liked)

Linux

52030 readers
1327 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

At long last I'm finally switching operating system for my gaming PC. I have a lot of photos and such saved that have been moved from an NTFS drive. Is there any tool out there to help me fix the permissions of these files according to file type in bulk?

top 6 comments
sorted by: hot top controversial new old
[–] FauxLiving 11 points 2 weeks ago

Your things may be owned by root and have unusual permissions.

So, to make your NTFS drive be owned by your user and group and to set the permissions you can:

# Change owner to user:user
sudo chown -R username:group your_directory

# Change permissions to default (typically 755 for directories and 644 for files)

# For directories
find your_directory -type d -exec chmod 755 {} \;

 #files
find your_directory -type f -exec chmod 644 {} \;
[–] just_another_person 9 points 2 weeks ago

chmod -R [mode] /dir/path

[–] p_consti 9 points 2 weeks ago (1 children)

If you need finer control than recursive chmod (see other replies), you can also use find to match precisely which files/folders you want and use the -exec parameter to run chmod on those

[–] stuner 8 points 2 weeks ago* (last edited 2 weeks ago)

I wanted to write the same thing. E.g., you can run this in bash to set the permissions for all .conf files to 600:

find /mnt/the/directory -iname "*.conf" -exec chmod 600 {} \;
[–] [email protected] 6 points 2 weeks ago

Chmod works recursively.

What modes exactly are you trying to set? Why do you need different perms based on the file type?

[–] [email protected] 5 points 2 weeks ago* (last edited 2 weeks ago)

Not like you need another utility to do this, but I highly recommend you checkout fd. It's badass;

fd -e jpg -e png -e webp -x chmod newuser:newuser

-e jpg is clearly the file extensions you want, -x is to execute a command with each result. You can also use -X which executes a command using all the files found as a single argument;

fd -e conf -X rm # delete all .conf files in one command versions an rm command for each file found