What's command to delete file in command window?

Asked by Gordom

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:
Last query:
Last reply:
Revision history for this message
Andy Loughran (andylockran) said :
#1

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

Revision history for this message
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.

Revision history for this message
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?

Revision history for this message
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

Revision history for this message
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)

Revision history for this message
Gordom (gordomm) said :
#6

Thanks Nicola S., that solved my question.

Revision history for this message
Andy Loughran (andylockran) said :
#7

I think I did too :p

Revision history for this message
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.

Revision history for this message
Andy Loughran (andylockran) said :
#9

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