LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 11-26-2013, 07:59 AM   #1
validator456
Member
 
Registered: Apr 2013
Location: Rotterdam, The Netherlands
Distribution: Crunchbang Linux
Posts: 135

Rep: Reputation: Disabled
chmod problem


I have to change the file permissions for a large amount of files (17 or so).
I can create a new directory and then move the files to this directory and then change all the files permissions within it.

But I was trying something else:
Code:
ls -m
The files of the directory are seperated by a comma. I then copied the files I wanted to change the permissions.

Then I run nano in the terminal. Search and replace (CTRL-\). I removed the commas by empty space.

Then I tried to copy and paste the result after the command
Code:
sudo chmod 664
. But it only pasted the first line of the files. And I want all 17 files in one go.

I hope I have been clear enough.
 
Old 11-26-2013, 08:15 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
Why use the -m option and not the -C option?
Code:
sudo chmod 664 $(ls -C)
 
1 members found this post helpful.
Old 11-26-2013, 09:57 AM   #3
ixion2600
LQ Newbie
 
Registered: Aug 2013
Posts: 11

Rep: Reputation: Disabled
Or you can use the -R option, for recursive, if you moved all of them in one place:

chmod 664 -R /path/to/directory

man chmod:

...
-R, --recursive
change files and directories recursively (this will modify the permissions for all files and sub-directories in the path)
...
This does the same thing:

find /path/to/directory -type f -exec chmod 644 {} \; (this will modify the permissions for all files and sub-directories in the path)

if you have your files in /home/user/test ... but have another directory there test2 and files inside, it will modify the permissions there as well.
 
Old 11-26-2013, 11:38 AM   #4
validator456
Member
 
Registered: Apr 2013
Location: Rotterdam, The Netherlands
Distribution: Crunchbang Linux
Posts: 135

Original Poster
Rep: Reputation: Disabled
Yes, I do know about the possibility of moving all of the files in one place and then do the -R method.

But I don't want to make a submap. I don't want to move the files. I just wanted to change the file permissions of SOME of the files in a map.

And ls -C doesn't allow you to select the files that you want.

But I guess that I am doing difficult and that I just have to create a map and move the files that I want to change over there.

Thank you for answering my question.
 
Old 11-26-2013, 11:54 AM   #5
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
Quote:
Originally Posted by validator456 View Post
And ls -C doesn't allow you to select the files that you want.
Why not?
Code:
$ ls -l
-rw-r----- 1 druuna druuna     0 nov 26 17:52 bar
-rw-r----- 1 druuna druuna     0 nov 26 17:52 foo
-rw-r----- 1 druuna druuna     0 nov 26 17:52 foobar
-rw-r----- 1 druuna druuna     0 nov 26 17:52 fubar
-rw-r----- 1 druuna druuna     0 nov 26 17:52 one
-rw-r----- 1 druuna druuna     0 nov 26 17:52 test
$ ls -C f*
foo  foobar  fubar
 
Old 11-26-2013, 12:51 PM   #6
validator456
Member
 
Registered: Apr 2013
Location: Rotterdam, The Netherlands
Distribution: Crunchbang Linux
Posts: 135

Original Poster
Rep: Reputation: Disabled
In one word: brilliant.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Sticky Bit? (ie: chmod 2770 vs chmod 770) JeffC1 Linux - Newbie 7 03-18-2010 08:39 AM
Apache: difference between chmod 644 and chmod 666 and chmod 600 for output/txt/dat? frenchn00b Programming 6 04-22-2009 02:10 PM
chmod 775 to only the directories and chmod 664 to only the files? apachenew Linux - Security 6 09-27-2007 04:26 PM
chmod, external usb, vfat - can't chmod a directory itsjustme Slackware 2 04-02-2006 05:23 PM
CHMOD in shell : chmod 777 /usr/ <---is that right? cpanelskindepot Programming 5 07-16-2004 06:37 AM


All times are GMT -5. The time now is 11:08 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration