Linux / UNIX Delete a file

Originally published at:

How do I delete a file under Linux / UNIX / BSD / AIX / HP-UX operating system using command line options?

Command to delete file is “rm”.

  1. rm <filename> deletes the file without asking anything
  2. rm -i <filename> asks before deleting file.
  3. rmdir <dirname> is used to delete an empty directory.
  4. rm -r <dirname> delete a directory with all the files in it including all sub-dirs.
  5. man rm and man rmdir to read help pages about rm and rmdir.