Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk12 min

How to Change Folder and File Permissions in Bulk on Linux

A practical Linux guide to bulk permission changes, with safe chmod and find patterns, 755/644 examples, symlink precautions, filename-safe pipelines, verification, and ACL inheritance.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a single permission policy across an entire directory tree, use chmod -R. For the common requirement of directories at 755 and regular files at 644, use two type-filtered find commands instead of one recursive chmod. That distinction prevents scripts, documents, and other files from receiving execute permission accidentally.

Preview the path first, decide how symbolic links should be treated, make the smallest change that meets your access requirement, and verify representative entries with stat or ls -ld. The procedures below cover ordinary mode bits, unusual filenames, selective changes, symlink safety, and POSIX ACLs for named users or groups.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The quick answer

If every object in a tree should follow one policy, run:

chmod -R u=rwX,g=rX,o= /path/to/tree

The GNU chmod invocation manual documents recursive -R. In this symbolic mode, the owner gets read and write, the group gets read, and others get no permissions; X adds execute/search permission to directories and to regular files that already have an execute bit. It therefore avoids turning every ordinary file into an executable.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

When directories and files need different modes, use:

find /path/to/tree -type d -exec chmod 755 {} +
find /path/to/tree -type f -exec chmod 644 {} +

find performs the type filtering, and -exec ... + batches many pathnames safely. Add sudo only when your account lacks ownership or the required privilege for the selected objects; changing mode bits requires ownership or appropriate privilege under the rules described by GNU and the chmod(1) manual.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Prepare and preview the change

Permissions are an access-control policy, not merely a cosmetic setting. Before changing thousands of entries, establish exactly which tree is in scope and what should happen to links, hidden files, scripts, sockets, and special files.

Confirm the target and your identity

pwd
printf '%sn' /path/to/tree
id

Use an absolute path when a command may be run from a different working directory or inside automation. Check the top-level directory before proceeding:

ls -ld /path/to/tree
stat -c '%A %a %U:%G %n' /path/to/tree

If the path is supplied by a variable or another script, validate it rather than trusting an empty or misspelled value. A typo combined with elevated privilege can modify a completely different location.

Preview the objects

find /path/to/tree -type d -print
find /path/to/tree -type f -print

These previews show directories and regular files separately. If the tree contains symbolic links, inspect them explicitly:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
find /path/to/tree -type l -ls

Decide whether links themselves should remain untouched or whether a linked target is intentionally in scope. Recursive operations and symlink traversal are discussed below; do not assume a link points inside the tree.

Record a rollback reference

Mode changes are easy to apply and harder to reconstruct if the original permissions were heterogeneous. Save a machine-readable inventory before editing:

find /path/to/tree -printf '%m %u %g %pn' > permissions-before.txt

The %m field records the numeric mode, while %u and %g record owner and group names. Keep this file with the change record. It is an audit reference; restoring modes from it requires a deliberate script that handles spaces and newlines safely rather than parsing it with an unsafe whitespace-splitting loop.

Choose the right bulk method

Requirement Recommended method Why Main caution
One policy for every object chmod -R u=rwX,g=rX,o= One command applies a consistent symbolic policy and X preserves executable intent. It does not express a separate directory/file policy.
Directories at 755 and files at 644 Two find -type branches with -exec ... + Directories receive search permission; files remain non-executable. Regular files only are selected by -type f; links and special files are not included.
Readable, explicit owner/group/other assignments Symbolic modes such as u=rwx,g=rx,o=rx The intended permissions are visible in the command. Assignments replace the selected classes rather than merely adding a bit.
Names contain spaces, quotes, tabs, or newlines find ... -exec ... +, or -print0 | xargs -0 Pathnames are passed without unsafe text splitting. Do not use an unquoted for loop or plain newline-delimited xargs.
Only entries with a particular existing bit find -perm with -print or -exec You can audit and change a narrowly selected set. Understand whether the predicate means any, all, or an exact permission match.
Access for named users/groups or inherited defaults POSIX ACLs with setfacl ACL entries go beyond the three traditional classes and can define directory defaults. ACLs can also alter the displayed mode bits and require compatible filesystem support.

Apply one policy to the entire tree

Use recursive chmod when one policy genuinely fits directories, regular files, and any other supported objects in scope:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
chmod -R u=rwX,g=rX,o= /path/to/tree

The symbolic expression sets owner read/write, group read, and no permissions for others. It grants execute to directories because directories need search permission to be traversed. For regular files, X grants execute only if an execute bit was already present. This is useful when a tree contains a mixture of scripts and data files and you want to preserve which files were executable.

Octal notation is shorter but less self-documenting. For example:

chmod -R 750 /path/to/tree

sets owner read/write/execute, group read/execute, and no permissions for others on every object selected by the recursive operation. It also makes every regular file executable, which is usually wrong for documents, uploads, and configuration data. Use it only when that uniform result is intentional.

GNU’s setting-permissions documentation explains symbolic classes (u, g, and o) and the conditional behavior of X. If you need to add or remove a bit without replacing other permissions, use operators such as g+w or o-w; if you need an exact policy, use =.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Set directories and regular files differently

The standard web-content, project, and shared-data pattern is directories 755 and regular files 644:

find /path/to/tree -type d -exec chmod 755 {} +
find /path/to/tree -type f -exec chmod 644 {} +

Directory mode 755 gives the owner read, write, and search; group and others read and search. File mode 644 gives the owner read/write and group and others read, with no execute bit. This is a policy choice, not a universal default: private data, shared team directories, and executable deployments often need different values.

Use symbolic modes when intent matters

find /path/to/tree -type d -exec chmod u=rwx,g=rx,o=rx {} +
find /path/to/tree -type f -exec chmod u=rw,g=r,o=r {} +

These commands state the same result without asking the reader to decode octal digits. They also make code review easier: a reviewer can see that only directories receive execute/search and that regular files do not.

Include only the object types you mean

-type f selects regular files and -type d selects directories. Neither branch changes symbolic links, device nodes, sockets, or FIFOs. That conservative behavior is often desirable. If a deployment contains executable symlinks, change the link target policy separately and deliberately rather than broadening the file branch without checking what it will reach.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Handle spaces and other unusual filenames safely

Linux pathnames can contain spaces, tabs, quotes, and newlines. A command that turns pathnames into newline-delimited text and then reparses that text can split one file into several arguments. Prefer -exec ... +, as in the examples above, because find passes the selected names directly to chmod.

When a pipeline is useful, use a null delimiter at both ends:

Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by
find /path/to/tree -type f -print0 | xargs -0 chmod 644

The -print0 action emits a NUL after each pathname, and xargs -0 reads those records without treating whitespace or quotes as separators. This pattern is documented in the find(1) manual. Never replace it with plain xargs chmod 644 when names are not strictly controlled.

Quote the starting path when it is supplied by a shell variable:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
root='/srv/shared data'
find "$root" -type f -exec chmod 644 {} +

The quotes protect the starting path from shell word splitting; find still handles the individual results safely.

Change only entries that match existing permissions

Sometimes a blanket policy is too broad. GNU find permission predicates let you audit a condition first and then modify only matching entries. To locate regular files writable by others:

find /path/to/tree -type f -perm /o+w -print

After reviewing the list, remove only the other-write bit:

find /path/to/tree -type f -perm /o+w -exec chmod o-w {} +

The slash form of -perm matches when any of the specified bits is present. Other forms let you require all specified bits or match an exact mode; consult the find permission predicate documentation before using them in an enforcement script.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

This two-pass pattern is safer than changing first and discovering the scope afterward. Keep the preview output as evidence of what the command selected, especially when removing world-write permission from a shared tree.

Understand recursive symlink behavior

Symlinks are the most important boundary in a recursive permission change. GNU tools provide traversal choices commonly expressed as -H, -L, and -P. The default behavior for recursive operations does not follow every symlink into its target tree. -L follows encountered links, which can cause a command aimed at one directory to modify files elsewhere; GNU warns that combining dereferencing with recursive operation may create a security risk in its Coreutils manual.

Use the default physical behavior, or explicitly request -P where supported, when the goal is to stay within the directory structure. Treat -L as an exceptional choice requiring a verified target, a controlled path, and a clear reason to cross the link.

For find, the starting-point and traversal options also affect links. Test the exact command on a small copy when links are present. A find -type f expression normally does not select a symlink as a regular file; selecting links requires -type l, and following them changes which objects are visited.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

Protect the root filesystem

Never run an unreviewed recursive mode command against /. GNU chmod supports --preserve-root, which makes a recursive operation fail when the operand is the root directory. Pair that safeguard with an explicit absolute target and a preview:

chmod --preserve-root -R u=rwX,g=rX,o= /srv/project

The safeguard reduces the chance that a variable-expansion or copy-and-paste error turns a project operation into a system-wide permission change; it does not replace careful path validation.

Use POSIX ACLs for named users, groups, and inheritance

Traditional mode bits provide one owner, one group, and one other class. If a named group such as developers needs access without changing the owning group, or if new files must inherit an access rule, use POSIX ACLs. The setfacl(1) manual describes the utility as setting Access Control Lists for files and directories.

Grant a named group recursively

setfacl -R -m g:developers:rwx /path/to/tree

-R applies the access ACL to entries below the starting path, and -m modifies existing entries or adds the specified one. Grant only the minimum rights required; rwx on every file may be excessive for source code or data.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Set a default ACL for future children

find /path/to/tree -type d -exec setfacl -m d:g:developers:rwx {} +

A default ACL belongs to a directory and is inherited by newly created children. Apply it to every relevant directory, not just the root, if directories can be created at multiple levels. Existing files do not automatically become compliant with a future default; adjust them with an access ACL command when needed.

Inspect effective and default entries

getfacl /path/to/tree
getfacl /path/to/tree/some-directory

Look for the named user or group entries, the mask entry, and any default: records. The ACL mask can limit the effective rights of named users, named groups, and the owning group, so an entry that appears to grant rwx may be constrained by the mask. ACL support and mount options vary by filesystem; if setfacl reports that ACLs are unsupported, check the filesystem documentation before falling back to a broader mode-bit change.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Verify the result instead of trusting the exit status

After the change, inspect the root, several nested directories, ordinary files, and any intentionally executable files:

stat -c '%A %a %n' /path/to/tree/some-file
ls -ld /path/to/tree /path/to/tree/some-directory

For a directory/file policy, sample both classes with a report:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
find /path/to/tree -type d -exec stat -c '%A %a %n' {} + | head
find /path/to/tree -type f -exec stat -c '%A %a %n' {} + | head

Check that directories retain search permission. A directory can be readable yet unusable for traversal if the execute/search bit is missing. Conversely, an executable regular file should be executable only when its content and deployment model require it.

To audit for files that still violate a 644 policy:

find /path/to/tree -type f ! -perm 644 -print

To audit directories that are not exactly 755:

find /path/to/tree -type d ! -perm 755 -print

Exact-mode audits intentionally flag special cases, such as a private configuration file or an executable script. Review each exception rather than repeatedly forcing a global mode that destroys a required distinction.

Worked recipes for common situations

Publicly readable project tree, no accidental file execution

  1. Preview the path and links with the commands in the preparation section.
  2. Set directories and regular files independently:
    find /srv/project -type d -exec chmod 755 {} +
    find /srv/project -type f -exec chmod 644 {} +
  3. Restore execute permission only to known entry points, for example:
    chmod 755 /srv/project/bin/run-app
  4. Audit for remaining unexpected modes with find ... ! -perm expressions.

This approach keeps documents and source files non-executable while allowing a deliberately selected launcher to run.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Mixed tree where existing executable intent must survive

chmod -R u=rwX,g=rX,o= /opt/tools

Use this when the same owner/group/other policy is appropriate everywhere and some regular files are already executable. The conditional X preserves those existing executable files while granting directory search permission.

Remove risky world-write permission only

  1. List candidates:
    find /var/www -type f -perm /o+w -print
  2. Review the output for intentional shared drop locations.
  3. Remove the bit from approved candidates:
    find /var/www -type f -perm /o+w -exec chmod o-w {} +
  4. Run the same audit again and investigate any remaining matches.

Shared developer directory with inherited group access

  1. Grant the named group access to current entries:
    setfacl -R -m g:developers:rwx /srv/team
  2. Add a default group ACL to directories:
    find /srv/team -type d -exec setfacl -m d:g:developers:rwx {} +
  3. Inspect representative directories with getfacl and confirm the ACL mask allows the intended effective rights.

Troubleshoot common failures

Operation not permitted or Permission denied

Confirm that you own the objects or have the required privilege. If the tree belongs to another account, rerun the narrowly scoped command with sudo only after reviewing the path and preview. A read-only mount, immutable attribute, network filesystem policy, or ACL can also prevent a mode change; inspect the mount and file attributes rather than repeatedly adding privilege.

Files became executable

A recursive octal mode such as chmod -R 755 intentionally sets execute on regular files. Replace it with separate find -type d and find -type f branches, or use symbolic X when preserving existing executable intent is the goal.

Users still cannot open a file

Every directory in the path needs search permission for that user or group. Inspect each parent with namei -l /path/to/tree/some-file when available, then check ACL entries and the ACL mask with getfacl. On a service account, also verify that the process is running under the account you expect.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A linked directory changed unexpectedly

Review whether -L was used directly or inherited through a wrapper. Stop and inspect the affected target, then use physical traversal (the default or -P, where supported) for future runs. A symlink can point outside the apparent project tree, so include link inspection in the preview phase.

The command breaks on a filename with a newline

Replace newline-delimited pipelines and shell loops with find ... -exec ... + or the null-delimited -print0 | xargs -0 form. Do not attempt to repair the problem by adding more quoting to a fundamentally whitespace-delimited parser.

A repeatable operational checklist

  • Write down the absolute target path and intended owner/group/other or ACL policy.
  • Preview directories, regular files, and symbolic links separately.
  • Choose one recursive policy only when one policy truly fits every selected object.
  • Use separate find branches for different directory and file modes.
  • Use symbolic X when conditional execute/search behavior is required.
  • Use -exec ... + or null-delimited processing for arbitrary filenames.
  • Avoid symlink-following recursion unless the target has been verified; protect against an accidental root operand.
  • Use ACLs for named users/groups and default inheritance instead of forcing an overly broad traditional mode.
  • Record a pre-change inventory and verify representative results plus an exception audit afterward.

The Bottom Line

Use chmod -R only for a genuinely uniform policy. For different folder and file modes, type-filtered find commands are clearer and safer; use null-delimited handling for unusual names, conservative symlink traversal, and POSIX ACLs when named identities or inheritance are part of the requirement.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.