What's command to delete file in command window?

Asked by Gordom on 2008-08-14

Can't find reference for deleting files. Can edit, move, etc but how to delete a file? Thanks.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu xterm Edit question
Assignee:
No assignee Edit question
Solved by:
Nicola S.
Solved:
2008-08-14
Last query:
2008-08-14
Last reply:
2008-08-14
Andy Loughran (andylockran) said : #1

rm.. but rm --help before hand to learn all the flags.

Steven Rose (steveydoteu) said : #2

rm <path to file>

As Andy has said though run rm --help first though so you can see what all the flags are and what they do.

Gordom (gordomm) said : #3

Going along nicely but the files are write protected and even though I say Yes to delete, it says access denied.
I guess I need to change the properties?

Andy Loughran (andylockran) said : #4

If you are sure that the file should be deleted.. use 'sudo' before the command. eg/

sudo rm /home/andy/test.txt

I'd recommend printing the full path for the first few times (such as /home/andy rather than just rm text.txt) just incase you've moved directory without realising.

Regards,

Andy

Best Nicola S. (strambinico) said : #5

open a terminal and write: sudo rm <file path>
(e.g. sudo rm /home/Steven/Desktop/file.py)
then you are asked for admin password, give it and it should be deleted.

if it's a directory: sudo rm -R <directory path>
(e.g. sudo rm -R /home/Steven/Documents)

Gordom (gordomm) said : #6

Thanks Nicola S., that solved my question.

Andy Loughran (andylockran) said : #7

I think I did too :p

Gordom (gordomm) said : #8

You sure did - but when I clicked on the answer it didn't do the two, just the last one.
Hey man, I'm off and running and lovin' it!
A BIG thanks.

Andy Loughran (andylockran) said : #9

hehe. I'm only messing. Enjoy YOURbuntu :p