Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 10-18-2010, 06:29 AM   #1
LQ Newbie
Registered: Apr 2006
Location: Sweden
Distribution: Mandrake 10.1
Posts: 10

Rep: Reputation: 0
Arrow Wrong file permission when I copy a file


I have a C-function that create a file and then make a copy in the same directory, but somethin is wrong with permission or owners.
The program starts as root user.

The file creates by the program:
-rwxrwxrwx 1 root staff 199680 Oct 18 10:58 test

Ok, but after copying the permission is not the same.
The file after copying (with new name) by the program:
-rw-r--r-- 1 root root 199680 Oct 18 10:58 test_copy

I want to have full permission of the copy, how to do??

Old 10-18-2010, 06:35 AM   #2
Registered: Aug 2008
Location: Netherlands
Distribution: Xubuntu
Posts: 87

Rep: Reputation: 11
My best bet would be to chmod it after copying. I don't know if there are better ways.
Old 10-18-2010, 06:51 AM   #3
Registered: Apr 2010
Location: Johannesburg
Distribution: Fedora 14, RHEL 5.5, CentOS 5.5, Ubuntu 10.04
Posts: 559

Rep: Reputation: 92
It depends on your definition of "copy". If you are making a copy of the file itself; in the same directory as the original; you are effectively creating a new file test_copy; with same contents of your original - test. I suspect this is your case; and this is the correct behaviour of the OS based on what you're doing. You need to incorporate a command that changes permissions of test_copy - chmod as per post #2 would work.

If you are copying the file from one directory to another directory; then the permissions would stay the same - as you're not changing the file or creating a new file; but rather just moving from one directory to another.

It would be useful if you posted your C code as well.


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
wrong permission on configuration file in phpMyAdmin tootcsen Linux - Newbie 3 03-06-2013 08:00 AM
Any log file for checking file permission change history in RHEL 5.1? bilalcochin Linux - Newbie 3 04-02-2010 10:57 AM
copy last 10000+ lines of large text file to a temporary file emilyg Linux - Newbie 3 06-24-2009 03:43 PM
Copy single file to multiple locations - What am I doing wrong decartes Linux - Newbie 7 04-26-2008 05:09 PM
gave wrong syntax for tar as tar -cvzf file file.tgz how to recover the file gautham Linux - General 4 04-13-2005 04:15 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:25 AM.

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