Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm new to Ubuntu. I installed it because i'm using it in my operating systems class in college. One thing needed to do is copy. This is the lecturers notes on how to do this:
Change to your home directory

cd

Display a listing of the files contained within it in long format

ls -al

Make a directory here called test

mkdir test

Below test create two directories x and y

cd test
mkdir x
mkdir y

Copy the file fstab from the /etc directory to the directory y

cd y
cp /etc/fstab .

But it's not working. Can anyone help me with this?

share|improve this question
4  
you might want to check the permissions of the /etc directory using ls -ld /etc for umask of 002 it must be rwx-r_x-r_x(755). –  Ankit Oct 14 '12 at 17:46
    
@OliveTwist Just the copy step everything else is fine. –  Pendo826 Oct 14 '12 at 17:54
1  
@Ankit Thanks man. yeah its read/write –  Pendo826 Oct 14 '12 at 17:54
    
@Ankit I suggest you to add an answer with a bit more details. It will help future visitors –  Anwar Shah Oct 14 '12 at 18:00
add comment

1 Answer

up vote 1 down vote accepted

In order to copy a file you must have read permission on the parent directory of the file and write permission on the destination.

Think of directory as a container with a lock and file as contents of the container.

You must have an access to the keys of the lock in order to access the file inside the directory(container).

File Permissions:-

r - can read the file.

w - can write to a file.

x - can run the file as a program.

Directory Permissions:- 

r - can read the contents of the directory.

w - can make changes to files inside the directory/ add or delete the files.

x - can cd to a directory.

Directory permissions are important and can override the file permissions.

Even if you're file doesn't have read permissions but the parent directory of the file has a read permission than you can copy the file assuming that you're copying the file to a location where you can write.

I assume this might be helpful.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.