Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a file called myfile that I would like to move using:

sudo mv myfile deep-dark-directory/

I need to use sudo to move the file as deep-dark-directory needs root privileges to write and I can't change the permissions of the deep-dark-directory.

How can I change the permissions/ownership of myfile so that the root user can move it ?

Attempt 1:

$ chown root myfile 
chown: changing ownership of `myfile': Operation not permitted

Attempt 2:

$ sudo chown root myfile 
chown: changing ownership of `myfile': Operation not permitted

Attempt 3:

$ chmod a+x myfile
$ ls -l index.html.1
-rwxrwxrwx 1 hh360 hh360 10819 May 15 12:08 myfile
$ sudo mv myfile deep-dark-directory/
mv: cannot remove `myfile': Permission denied

Attempt 4 :

$ sudo chmod a+x myfile
chmod: changing permissions of `myfile': Operation not permitted

OS: Ubuntu 12.04 64bit

share|improve this question
    
use sudo in your chown and chmod commands. – Frank Thomas May 15 '13 at 11:43
    
tried that, edited question to show outcome – Heidi May 15 '13 at 11:49
    
is the file currently in use? – Frank Thomas May 15 '13 at 11:51
2  
Also: what are the perimissions on the directory containing myfile? It looks like that directory is not permitting you to modify the directory (remove files, change their permissions.) – Wandering Logic May 15 '13 at 12:05
1  
Fixed, turns out my home directory was on a networked drive as highlighted by @WanderingLogic – Heidi May 15 '13 at 14:04

you probably need to have write permission in your current working directory:

chmod u+w .
share|improve this answer
    
since it was root on nfs drive, what was needed was probably "chmod o+w ." – Wandering Logic May 15 '13 at 15:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .