Aug
26
2006

How to delete write protected file

Reader Ashish asks “How to delete write protected file under Linux…”

Under Linux (and other Unixsh oses) following criteria should matched before deleting a file:

Criteria # 1

To delete or remove a file you need to be owner of a file. Use ls -l command to verify your ownership:
$ ls -l filename

If you have sufficient rights, you can remove a file. Otherwise, become a superuser to remove a file.

Criteria # 2

In addition, you must have a write access to on a directory that allows you to remove or add new files. Again us ls -l or ls -ld command to get write ownership of directory.
$ ls -ld dirname

If you have sufficient rights, you can remove a file. Otherwise, become a superuser to remove a file. Use chown / chmod commands to setup permission OR run rm command as root user:
# su -
# rm -f file.txt

[More on NixCraft below...]

How to delete write protected file

Originally from nixCraft by nixcraft

Leave a Comment

Name (required)

Email (required)

Website

Comments

2006 (c) Tech Tips, Using the ReviewSaurus Theme : Powered by WordPress