change a read only document

Asked by Walter Winters

I have restored a back up drive which had been accidently deleted. I have saved the retrived files to a root directly and can't do much with them. How can I delete these files si I can restore them to a non-root directly?

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu openoffice.org Edit question
Assignee:
No assignee Edit question
Solved by:
FD
Solved:
Last query:
Last reply:
Revision history for this message
Zoltán Tősér (zozi56) said :
#1

I hope I understand your problem correctly. Enter this command in the terminal:

sudo chown <your_username> <file>

where <your_username> is, of course, your username, and <file> is the absolute path to the file. Here's an example. If I want to own a file which is located in /media/disk/ and its name is backup.odt, I have to enter:

sudo chown zozi56 /media/disk/backup.odt

After this, you become the owner of the backup, and change its permissions in the right-click menu.

(Sorry about my English, I'm really tired tonight...)

Revision history for this message
Walter Winters (waltwin2000) said :
#2

I am doing something wrong. the files I am trying to delete are in my root directory. Its name is /home/walt/
One of the files I am trying to delete is named recup_dir3

I am entering sudo chown walt/home/walt.

I also tried sudo chown walt/home/walt.

I get a message that states "missing operand after_'walt/home/recup_dir3'

I am not sure what operand they want.

I really do appreciate your help.

walt

Revision history for this message
Cristi Nistor (cristi-nistor) said :
#3

To change file permissions recursively you have to type the folloeing command:

sudo chmod -R /path-to-your-directory

and you'll be able to modify the content of your directory and all files and subdirectories within.

So, the command for your folder will be:

sudo chmod -R /home/walt/

Typing man chmod in the terminal window will give information about chmod command and the options you may use with it. Are you sure that recup_dir3 is not a directory?

Good luck.

Revision history for this message
Best FD (fdouw) said :
#4

@Christi Nistor: the chmod command indeed changes permissions, but you forgot to add some arguments telling what those permissions should be; besides, I would not recommend using chmod -R on your home directory…

@Walter Winters: if you want to delete a file which you do not own, you should delete it as root. This is fairly simple: type “sudo rm <filename>”, e.g.: “sudo rm recup_dir3” (without quotation marks). If recup_dir3 is a directory and not a regular file, then you should use “sudo rmdir <dirname>” if the directory is empty, or “sudo rm -r <dirname>” if it is not – beware, this will delete the directory with everything in it!

If you do not want to delete the file, but to use it, you can make yourself the owner of the file: “sudo chown <username> <filename>”, e.g. “sudo chown walt recup_dir3”. To become the owner of everything in a directory (and subdirectories): “sudo chown -R <username> <dirname>”, e.g. “sudo chown -R walt /home/walt”

Revision history for this message
Walter Winters (waltwin2000) said :
#5

I thank you very much.

Revision history for this message
Cristi Nistor (cristi-nistor) said :
#6

@Floris Yes, I realized that I wrote something stupid. I was thinking at chmod and chown commands at the same time and I spitted out a big nothing.

Anyway, lets hope that it will be more clear after your comment.

Revision history for this message
Walter Winters (waltwin2000) said :
#7

This has resolved my problem and I learned something new. Any day I can learn something new is a great day.

walt