Solved

Automatically changing the permissions of only certain files in subdirectories

Posted on 2004-03-28
6
259 Views
Last Modified: 2010-04-20
Hello.

I need to change the permission of all files with the following extentions inside of a certain directory to 777:
.dat
.bak
.lock

There are over 200 files in 15 sub-directories.

I have ssh access. How can I change the permissions of all the files in all the subdirectories at once? Thanks!
0
Comment
Question by:perldog
  • 4
  • 2
6 Comments
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 10698288
Use the find command:

find /path/to/parent -name "*.dat" -print | xargs chmod 777
find /path/to/parent -name "*.bak" -print | xargs chmod 777
find /path/to/parent -name "*.lock" -print | xargs chmod 777
0
 
LVL 44

Accepted Solution

by:
Karl Heinz Kremer earned 230 total points
ID: 10698292
You can also combine the three extensions into one command:
find /path/to/parent -name "*.dat" -print , -name "*.bak" -print , -name "*.lock" -print | xargs chmod 777

0
 
LVL 9

Assisted Solution

by:tkalchev
tkalchev earned 20 total points
ID: 10704517
Or try this one (it is almost equivalent ) :

find /path/to/parent -name "*.dat" -exec chmod 777 {} \; , -name "*.bak" -exec chmod 777 {} \; , -name "*.lock" -exec chmod 777 {} \;
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 10705071
tkalchev,
your solution will be slower: You are forking the chmod command for every single file. The xargs mechanism collects a number of file names and then forks one chmod command for a number of files.
0
 
LVL 9

Expert Comment

by:tkalchev
ID: 10705157
True, but no chance for "argument list too long" error :)
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 10705211
... and for 200 files it does not make a big difference :-)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now