cp-issue in unix

Posted on 2011-10-26
Last Modified: 2012-06-27
When i try
cp /home/njifcip/stmtpim/wmr/* /home/nyistpp/stmt/data/wmr/
cp: cannot create regular file `/home/nyistpp/stmt/data/wmr/abc.txt': Permission denied

Why i am getting this error.
Both path have wmr directory full permission.
I created test dir under wmr and could perform successful copy
Please advise.

Question by:sunilbains
    LVL 68

    Expert Comment

    Could it be that the source of "abc.txt" is a symbolic link pointing to a file you don't have read permission to?

    Check with

    ls -l /home/njifcip/stmtpim/wmr/abc.txt

    If it's indeed a link use the "-P" flag to copy links as links, if appropriate.


    Author Comment

    i tried ls -l /home/njifcip/stmtpim/wmr/abc.txt

    and getting following output
    -rw-r--r--    1 njifcip  pcs-tech--1   717336 Oct 22 02:09 /home/njifcip/stmtpim/wmr/abc.txt
    Does not seem to be link?
    LVL 68

    Expert Comment


    What do you get with

    ls -ld /home/nyistpp/stmt/data/wmr




    Author Comment

    $ ls -ld /home/nyistpp/stmt/data/wmr
    drwxrwxrwx    5 nyistpp  games        4096 Oct 26 12:34 /home/nyistpp/stmt/data/wmr
    wmr]$ id
    uid=72619(nyoteapb) gid=20(games) groups=20(games)
    LVL 40

    Expert Comment

    the dir is owned by other user nyistpp  and file abc.txt is owned by other user njifcip and you have read only on that file
    LVL 19

    Expert Comment

    /home/njifcip/stmtpim/wmr/abc.txt already exists and is owned by another user, so you cannot overwrite it, however you are still permitted to create new files or directories because /home/njifcip/stmtpim/wmr is world-writable.  This is exactly how the system should act.

    Author Comment

    Hello xterm,
    what is the alternative solution?
     should we have 777 permission on tgt-- /home/nyistpp/stmt/data/wmr/ existing files.
    LVL 19

    Accepted Solution

    If you chmod 777 /home/nyistpp/stmtpim/wmr/abc.txt, then yes, you will be able to overwrite it, but it's new permissions will now become exactly what the permissions are of /home/njifcip/stmtpim/wmr/abc.txt.

    Course you will have to be root to do that, and if you're going to do that, you might as well just rm  /home/nyistpp/stmtpim/wmr/abc.txt and get it out of the way.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
    Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

    759 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

    8 Experts available now in Live!

    Get 1:1 Help Now