Chown isn't working


#1

I copied some files from an account1 to an account2.
I chmod 777 those files, both accounts belong to the same group.

And I’m trying to chown those files to account2.
I’m getting permission denied.

Can someone help me?


#2

Are you trying to chmod them as user1 or user2? To get the full picture, log in via SSH and type ‘ls -l’ in that directory to see who owns the files, and their permissions. The owner will be able to chmod the file.

To be safe when copying files, I log in as user1 to make sure user2 can copy the files, then log in as user2 and copy the files from account1 to account2. This avoids many headaches.

-Scott


#3

He’s trying to chown, not chmod, sdayman.

If you are trying to copy htaccess.txt from ~/directory1 to ~/directory2, and change ownership of the file in ~/directory2 to user2.

login as user1.
cd ~/directory1
chmod 777 htaccess.txt
log out.

Because the second digit of the permissions is 7, other members of the same group have read/write/execute permission.

log in as user2.
cd ~/directory2
cp ~/directory1/htacess.txt .
chown user2.mygroup htaccess.txt
chmod 644 htaccess.txt
log out.

You had permission to copy the file, and you also have permission to change ownership and permissions of the file. You change the file back to 644 when you’re done. (Normally, directories and CGI executables should be 755, data files like HTML files should be 644.)

log in as user1
cd ~/directory1
chmod 644 htaccess.txt
log out.

Changing the original file back to the original permissions.


#4

is the chown necessary? i thought files created using the cp command were owned by the user who issued the command.

track7 - my dream-hosted site


#5

I thought I was right, but do an ls -al and see.

Proof of the pudding is in the tasting…