LinuxQuestions.org
Register a domain and help support LQ
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 06-18-2012, 05:59 AM   #1
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Rep: Reputation: 30
copy file and change permission


I would like to copy a file to another path , can advise how can the file owner is not changed but change the permission to 666 ( the file is 644 originally ) , is there a single command can do that ?

thx
 
Old 06-18-2012, 06:05 AM   #2
414N
Member
 
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 635

Rep: Reputation: 186Reputation: 186
You can change what attributes to preserve or not using the cp options --preserve and --no-preserve, but I don't think you can set arbitrary permissions on the fly.
For that you'd need chmod.
 
Old 06-18-2012, 06:30 AM   #3
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by 414N View Post
You can change what attributes to preserve or not using the cp options --preserve and --no-preserve, but I don't think you can set arbitrary permissions on the fly.
For that you'd need chmod.
thx reply ,

that mean I must run two command to do that ?

ps. as I will run cron job to do it so I prefer one single command .

thx
 
Old 06-18-2012, 06:48 AM   #4
414N
Member
 
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 635

Rep: Reputation: 186Reputation: 186
Quote:
Originally Posted by ust View Post
ps. as I will run cron job to do it so I prefer one single command .

thx
You can put all the commands required inside a single script and then launch it via a cron job...
 
Old 06-18-2012, 09:43 AM   #5
VDP76
Member
 
Registered: Apr 2010
Location: Bayreuth, Germany
Distribution: CrunchBang Linux (#!)
Posts: 111

Rep: Reputation: 19
Quote:
Originally Posted by ust View Post
ps. as I will run cron job to do it so I prefer one single command
what about the syntax
Code:
command_1 && command_2
!?

in that way if command_1 fails, command_2 won't be executed.
 
Old 06-18-2012, 10:01 AM   #6
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
and of course you can just string the commands together on one line:

command1; command2; command3
 
  


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
Cannot copy file even as root (read permission denied) dhamilton Linux - Newbie 10 01-04-2011 08:59 AM
Restore copy folder&file permission aiushtha Programming 3 12-21-2010 10:02 AM
Wrong file permission when I copy a file henrik9 Linux - Newbie 2 10-18-2010 06:51 AM
Any log file for checking file permission change history in RHEL 5.1? bilalcochin Linux - Newbie 3 04-02-2010 10:57 AM
change file permission of a mouse device file permanently alexandre_fs Linux - General 5 01-09-2007 07:30 AM


All times are GMT -5. The time now is 12:17 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