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

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

For a single permission policy across an entire directory tree, use chmod -R. When directories and regular files need different modes—which is the common case—use two find commands so directories receive search/execute permission and files do not accidentally become executable. Preview the paths first, decide how symlinks should be treated, run with the required privileges, and verify representative results afterward.

Choose the right bulk-permission method

Linux permissions control what the owner, owning group, and everyone else may do with an object. A directory’s execute bit means that a user may search or traverse it (subject to the directory’s read and write bits); it does not make a directory “run.” Regular files generally need read and write bits, while executable programs and scripts also need execute permission.

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.
Situation Recommended command pattern Why
Every object can share one policy chmod -R u=rwX,g=rX,o= /path/to/tree GNU chmod applies the policy recursively, and capital X adds execute/search only where appropriate.
Directories and files need different modes find ... -type d -exec chmod 755 {} +
find ... -type f -exec chmod 644 {} +
Type filters prevent regular files from receiving directory-style execute bits.
Names contain spaces, quotes, or newlines find ... -exec ... + or find ... -print0 | xargs -0 ... Arguments are passed without unsafe whitespace splitting.
Specific users or groups need extra access setfacl with access and default ACL entries POSIX ACLs express named-user/group access and inheritance that the three traditional classes cannot.

The GNU manual defines chmod as changing access permissions on named files; its recursive form applies the operation throughout a tree. See the GNU chmod invocation manual for option details.

Prepare and preview before changing anything

Confirm the target path

Use an absolute path when possible, especially in scripts or privileged shells. A typo in a recursive command can alter an unintended tree. Do not run a recursive permission command on / unless that is explicitly your objective and you understand the consequences.

#1 Best Overall
Sale
Compressed Air Duster,130000RPM Super Power Cordless Air Duster,Rechargeable Brushless Blower,3 Gear Adjustable Blower with LED Light,Dust Remover for Computer/House/Outdoor/Car
  • Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
  • With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
  • Wide Application: attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
  • Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
  • Economical &Reusable: Built durable materials with a long-lasting battery,our CAGIWIRU air duster it's a sustainable alternative to disposable air cans.

List the objects that will be affected

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

These previews show directories and regular files separately. Review the output for mounted locations, generated caches, private data, and symlinks before applying a policy.

Check ownership and privilege

Changing mode bits normally requires ownership of the object or an appropriate privilege. If the account cannot modify the selected entries, prefix the final command with sudo rather than assuming it is always required. Test the exact command as the intended account where practical; sudo does not fix an incorrect path or an unsafe traversal policy.

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

Plan a rollback

Permission changes are easy to apply and harder to reconstruct later if the original state was not recorded. For a high-impact tree, save a listing before the change, for example:

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

The numeric mode, owner, group, and path in that report provide an audit reference. Treat the report as sensitive if filenames or ownership information are confidential.

Apply one policy recursively with chmod -R

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

This symbolic mode gives the owner read/write access, the group read access, and no access to others. The capital X is intentional: GNU chmod grants execute/search only to directories and to regular files that already have an execute bit. Existing executable intent is therefore retained without making every ordinary file executable. The behavior is documented in GNU’s Setting Permissions section.

Use chmod -R u=rwX,g=rX,o= /path/to/tree when the same class policy is suitable for every object. It is not the best choice when directories should be 755 but files should be 644, because one recursive mode cannot express those two exact results simultaneously.

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

Octal versus symbolic notation

Octal notation is compact and exact: 755 means owner rwx, group r-x, and others r-x; 644 means owner rw-, group r--, and others r--. Symbolic notation spells out the classes and operations, which makes a review easier and can preserve selected existing bits. For a policy that must be visible in a change review, prefer:

Rank #2
EVEO® Screen Cleaner Spray Kit (Streak-Free) TV Screen Cleaner for Smart TV, Lcd, LEd, Oled | Computer Screen Cleaner Spray and Wipe Microfiber Cloth - TV, Monitor, Laptop, iPad, Car - 6.7oz 1 Pack
  • Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
  • Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
  • Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
  • Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
  • Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth
chmod -R u=rwX,g=rX,o= /path/to/tree

For a known homogeneous set where every entry should receive exactly one octal mode, an octal command is clear, but remember that applying 755 to regular files grants execute permission to all three classes.

Set directories and regular files to different modes

The usual web, source, and data-tree policy is directories at 755 and regular files at 644. Use separate find branches so the file type is tested before the mode is changed:

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

find performs the type filtering. The -exec ... + form batches many matched paths into each invocation, reducing process overhead while still passing each pathname as a distinct argument. Add sudo before chmod if the selected objects require privilege:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo find /path/to/tree -type d -exec chmod 755 {} +
sudo find /path/to/tree -type f -exec chmod 644 {} +

Do not add sudo merely to hide an ownership problem; use the least privilege that can complete the intended change. The find(1) manual documents the type predicates and batched -exec ... + behavior.

Use symbolic modes when the 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 desired owner, group, and other permissions directly. The file branch deliberately omits execute permission, while the directory branch includes search permission. This form can be easier to audit than a pair of unexplained numbers and avoids accidentally making every regular file executable. GNU documents the symbolic permission grammar in its permission-setting reference.

Keep executable files executable

If a tree contains scripts or binaries that must remain executable, first identify them or use a policy that preserves existing execute bits. A blanket find ... -type f -exec chmod 644 ... intentionally removes execute permission from every regular file, including programs. The capital-X recursive pattern is useful when preserving already executable files is more important than forcing one exact mode:

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

For mixed trees that need exact directory/file modes plus selected executables, apply the directory and file policy, then restore execute permission only to the known program or script paths rather than using 755 for every file.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black | LED mouse pad with 14 lighting modes, covers keyboard & mouse, anti-slip rubber base, waterproof surface, USB powered
  • 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
  • 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
  • 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
  • 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
  • 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.

Handle spaces and unusual filenames safely

Never build a plain, whitespace-delimited list of filenames and feed it to chmod. Spaces, tabs, quotes, backslashes, and embedded newlines can cause one pathname to be split into several arguments or interpreted as shell syntax.

Prefer find -exec ... +

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

find supplies each pathname as a separate argument, so unusual characters are not reparsed by a shell. The same pattern works for directories, ACL changes, and audits.

Use a null-delimited pipeline when a pipeline is needed

find /path/to/tree -type f -print0 | xargs -0 chmod 644

-print0 emits a NUL after each pathname, and xargs -0 reads those boundaries exactly. This preserves embedded whitespace, quotes, and newlines. The find -exec ... + examples avoid the pipeline altogether and are generally simpler for a direct permission change.

Target only entries with a particular existing permission

Use find’s -perm predicates to audit first and then modify only matching entries. For example, to find regular files that grant write permission to “others”:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
find /path/to/tree -type f -perm /o+w -print

After reviewing the list, remove that bit from the same set:

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

The /o+w form matches files where at least one of the selected “other” permission bits is present. The symbolic o-w operation removes only others’ write bit and leaves unrelated owner, group, and execute settings unchanged. The find(1) documentation describes the permission predicates and their selection semantics.

Understand symlink traversal before using recursion

Recursive permission work must have an explicit symlink policy. By default, recursive chmod does not follow symlinks encountered in the tree. GNU documents -H, -L, and -P traversal controls; -P prevents following symlinks, while -L follows them.

Rank #4
Sale
Vaydeer Wrist Rest for Keyboard and Mouse, Computer Ergonomic Wrist Support Pad, Soft Memory Foam Arm Cushion for Desk, Palm Hand Office Laptop Typing
  • 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
  • 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
  • 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
  • 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
  • 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.

Why -L can be dangerous

Following a symlink can move the operation outside the directory you intended to manage. GNU warns that combining dereferencing with recursive operation may create a security risk; see the GNU Coreutils manual. Do not use -L unless every link target is known, trusted, and deliberately included.

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

Protect the root directory

GNU chmod supports --preserve-root, which causes a recursive operation aimed at / to fail instead of traversing the entire filesystem. Use it as a defensive option in scripts that receive a path variable:

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

--preserve-root is a guard against the catastrophic case of an accidentally empty or wrong path variable resolving to the filesystem root; it does not validate that an arbitrary non-root path is the one you intended.

Use POSIX ACLs for named users, groups, and inheritance

Traditional mode bits provide only owner, group, and other classes. When a named group such as developers needs access without changing the owning group—or when new files and directories must inherit an additional group entry—use POSIX ACLs. The setfacl utility sets access-control lists on files and directories, as described in the setfacl(1) manual.

Grant a group access throughout an existing tree

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

-R edits the existing entries recursively, and -m modifies the ACL. This grants the named group read, write, and execute/search access on the selected objects. ACL changes can also adjust the traditional mode-bit representation, so inspect the result rather than assuming the old three-field display tells the whole story.

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

Add a default ACL for new directory contents

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

Default ACL entries belong on directories and provide inheritance for objects created below them. Apply them only to directories; a regular file cannot carry a default ACL for future children.

Inspect the effective ACL

getfacl /path/to/tree

Use getfacl on representative directories and files after the change. This reveals named entries and the ACL mask that may limit the effective permissions shown for a user or group. ACLs are the appropriate tool when the requirement is “this particular user or group,” not merely “everyone in the owning group.”

Best Value
Sale
Under Desk Cable Management Tray No Drill, Metal Mesh Cable Management Under Desk with Clamp Mount, 2 Hole Cable Tray with Wire Management and Cord Organizer for Home Office Standing Desk
  • 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
  • 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
  • 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
  • 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
  • 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.
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 command exit

Inspect symbolic and numeric modes

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

stat displays the symbolic mode, numeric mode, and pathname in one line. ls -ld shows a directory’s own permissions rather than listing its contents. Check at least one directory, one ordinary file, and every intentionally executable file.

Audit for exceptions

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

The first audit lists regular files with any execute bit; compare it with the set of programs and scripts that should be executable. The second lists files writable by others. These are review commands, not automatic proof that a permission is wrong: some applications deliberately require a broader mode.

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.

Verify traversal and access as the real user

A file’s mode is not the only factor. Every parent directory in the path must be searchable by the accessing user, and ACLs, ownership, group membership, mount options, and security controls can affect the result. Test the actual operation—reading a file, creating a child, or executing a script—as the account that will use it.

Worked patterns

Private application tree with non-executable data files

find /srv/app -type d -exec chmod 755 {} +
find /srv/app -type f -exec chmod 644 {} +
stat -c '%A %a %n' /srv/app /srv/app/config/settings.ini

This gives directories search permission for owner, group, and others while keeping regular files non-executable. If the application contains executable scripts, list those paths separately and grant execute only where required.

Preserve existing executables while tightening a mixed tree

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

Capital X leaves already executable files executable and gives directories search permission, without turning every data file into a program.

Remove world-writable regular files after an audit

find /shared -type f -perm /o+w -print
find /shared -type f -perm /o+w -exec chmod o-w {} +

Run the first command, review the paths, and only then run the second. The targeted symbolic change removes others’ write bit without overwriting the rest of each file’s mode.

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

Shared project group with inherited access

setfacl -R -m g:developers:rwx /srv/project
find /srv/project -type d -exec setfacl -m d:g:developers:rwx {} +
getfacl /srv/project

The first command updates current entries; the second places a default group ACL on every directory so future children inherit the group entry. Inspect ACL output and test creation and modification as a developer account.

Common failure modes and fixes

  • Every file became executable: A recursive chmod -R 755 applies execute permission to regular files. Reapply separate directory/file modes, then restore execute only to required programs.
  • Scripts stopped running: A blanket chmod 644 removed execute bits. Identify the scripts or binaries that must run and grant execute deliberately, or use the capital-X policy when preserving existing executable intent is appropriate.
  • Names were split or skipped: A whitespace-delimited pipeline is unsafe. Replace it with find -exec ... + or a -print0 | xargs -0 pipeline.
  • A linked directory was changed unexpectedly: The operation followed symlinks. Avoid -L; use the default behavior or -P when you need to prevent traversal, and inspect links before retrying.
  • Operation not permitted: Confirm ownership, group membership, ACLs, and mount behavior. Use sudo only when the account is authorized and the path has been verified.
  • Permission looks right but access still fails: Check search permission on every parent directory, ACL entries with getfacl, and the identity actually performing the operation.
  • Changes reached the wrong tree: Stop, restore from the saved mode/ownership report where possible, and add path validation plus --preserve-root to scripts that invoke recursive chmod.

A practical decision checklist

  1. Write down the required access for owners, groups, others, and any named users or groups.
  2. Preview directories and files with find; check for symlinks and unexpected mount points.
  3. Choose one recursive policy only when one policy truly fits every object.
  4. Otherwise, run separate find -type d and find -type f branches.
  5. Use symbolic modes when preserving or documenting intent matters; use octal when an exact fixed mode is clearer.
  6. Use -exec ... + or null-delimited arguments for arbitrary filenames.
  7. Set ACLs when access belongs to named users/groups or must be inherited by future children.
  8. Apply the least privilege needed, protect recursive scripts with --preserve-root, and avoid -L unless link targets are deliberately in scope.
  9. Verify with stat, ls -ld, find -perm, and getfacl, then test access as the real user.

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.