LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-11-2005, 08:02 PM   #1
shadkong
Member
 
Registered: Apr 2005
Location: Guangzhou, China
Distribution: Slackware 10.2
Posts: 114

Rep: Reputation: 15
How to change all files' right?


I copied a whole directory from a vfat partition, and there are many files and directories in it. I want to change all the directories to 755, all the files to 644, how can I do it easily? chmod?
 
Old 04-11-2005, 08:06 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
When you say "from a vfat" partition, do you mean you
copied them, or is it mounted (still on vfat)?


Cheers,
Tink
 
Old 04-11-2005, 08:14 PM   #3
shadkong
Member
 
Registered: Apr 2005
Location: Guangzhou, China
Distribution: Slackware 10.2
Posts: 114

Original Poster
Rep: Reputation: 15
Sorry, I mean copied.
 
Old 04-11-2005, 08:15 PM   #4
shadkong
Member
 
Registered: Apr 2005
Location: Guangzhou, China
Distribution: Slackware 10.2
Posts: 114

Original Poster
Rep: Reputation: 15
As you know, the right of files that copied from a vfat partition is 755, I want them be 644.
 
Old 04-11-2005, 08:17 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Code:
find /<path/to/your/files> -type f -exec chmod 644 {} \;
find /<path/to/your/files> -type d -exec chmod 755 {} \;


Cheers,
Tink
 
Old 04-11-2005, 08:23 PM   #6
poiuytrewq
Member
 
Registered: Jul 2004
Posts: 107

Rep: Reputation: 15
edit: opps looks like it took me 20 minutes to reply from when i clicked the reply button,
why are you guys giving such a convoluted example when it can just be done like i showed?

if the files are still residing on the vfat partition, then, in short you cant, vfat does not support file permissions like ext3 and the like do. you can remount the file system with different premission, but i dont think that is what you are asking for.

if you did indeed copy the vfat partition onto a linux partition then just go like so:
Code:
chmod 644 /path/to/your/files -R
(i think the -R (recursive) tag might be the trick you were looking for)

Last edited by poiuytrewq; 04-11-2005 at 08:26 PM.
 
Old 04-11-2005, 08:23 PM   #7
shadkong
Member
 
Registered: Apr 2005
Location: Guangzhou, China
Distribution: Slackware 10.2
Posts: 114

Original Poster
Rep: Reputation: 15
Is it like this:
find /<path/to/your/files> -type f -exec chmod 644 {}
find /<path/to/your/files> -type d -exec chmod 755 {}

but it displays:
find: missing argument to `-exec'
 
Old 04-11-2005, 08:26 PM   #8
chbin
Member
 
Registered: Mar 2005
Distribution: slackware-current
Posts: 379

Rep: Reputation: 31
You have to include the \;

find /<path/to/your/files> -type f -exec chmod 644 {} \;
find /<path/to/your/files> -type d -exec chmod 755 {} \;
 
Old 04-11-2005, 08:29 PM   #9
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally posted by poiuytrewq
edit: opps looks like it took me 20 minutes to reply from when i clicked the reply button,
why are you guys giving such a convoluted example when it can just be done like i showed?

Code:
chmod 644 /path/to/your/files -R
Because your non-convoluted example won't allow him
to change into directories afterwards?


Cheers,
Tink

Last edited by Tinkster; 04-11-2005 at 08:33 PM.
 
Old 04-11-2005, 09:07 PM   #10
shadkong
Member
 
Registered: Apr 2005
Location: Guangzhou, China
Distribution: Slackware 10.2
Posts: 114

Original Poster
Rep: Reputation: 15
find /<path/to/your/files> -type f -exec chmod 644 {} \;
find /<path/to/your/files> -type d -exec chmod 755 {} \;

This commend is ended by ";" ?
 
Old 04-11-2005, 09:14 PM   #11
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Yes, as it is done in three posts now ... :}


Cheers,
Tink
 
Old 04-11-2005, 09:37 PM   #12
shadkong
Member
 
Registered: Apr 2005
Location: Guangzhou, China
Distribution: Slackware 10.2
Posts: 114

Original Poster
Rep: Reputation: 15
But do you think a commend ended with ";" can be executed?
I can't execute it.
 
Old 04-11-2005, 09:44 PM   #13
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally posted by shadkong
But do you think a commend ended with ";" can be executed?
I can't execute it.
Works here, has for years ...
It wouldn't work, for instance, if you had a SPACE
between the \ and the ; ...

May I suggest that you copy & paste my example
from the 2nd post, and just edit the path bit... ?


Cheers,
Tink
 
Old 04-11-2005, 10:23 PM   #14
shadkong
Member
 
Registered: Apr 2005
Location: Guangzhou, China
Distribution: Slackware 10.2
Posts: 114

Original Poster
Rep: Reputation: 15
Thank you Tinkster! It works now!
Can you tell me the meaning of this commend? I really have the interest to know it.
 
Old 04-11-2005, 10:43 PM   #15
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally posted by shadkong
Thank you Tinkster! It works now!
Can you tell me the meaning of this commend? I really have the interest to know it.
In brief ... :)

find is a very flexible tool to allow you locating
files by varied criteria and do a variety of things in
response ...

The default is to print the name of whatever matches
the criteria.

What we've done here is:

1.)
Search the directory under /path/to/your/files for anything
that is an ordinary file (type f), and change the permissions
to 664 (-exec chmod 644 {} \;)
-exec tells find to run a command against each found file.
It consists of three parts, that's the -exec, the {} and the \;
-exec is the start of the phrase (followed by the actual command),
{} is the placeholder for the files name, and \; terminates the
exec phrase ... you could, for instance, put other parameters
to your command behind the file-name ...
(e.g. -exec cp {} /tmp/results/. \; )


2.)
does the same thing, only for directories (type d)

For details read the man-page
man find


Cheers,
Tink
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I change files and save as... xstealthrtx Linux - Newbie 7 12-26-2004 01:30 AM
How do you change a files permissions Charlie Chan Linux - Security 8 10-20-2004 10:19 PM
ssh cant change files SCX Linux - Networking 3 09-09-2004 05:06 PM
can't change files on my own webserver tidasu Linux - Newbie 2 08-26-2004 06:44 PM
Need way to change the date of files BH_Exeter Linux - Software 7 08-26-2004 08:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration