Change ownership of a directory

I want to change the ownership of a directory ONLY.

my id

id1 owns the files under the /mypath/bin

but /mypath/bin is owned by id2

If i log into id2

I can't do

chown id1 /mypath/bin

Sorry but on most types of UNIX, you need to be the root user to do that. It's a security feature (directories included).

Imagine a shared environment in, say, a university. You don't like "bob" very much so you create a bunch of dodgy files containing unsavory pictures, bomb recipies and other antisocial things and drop it into /tmp. You then chown to the files to bob and then send an email the head of department :wink:

If it's something you need to routinely do though and it's on the same name files every time, talk to your administrator about being given special rights to run the following command:
sudo chown id1 /mypath/bin