60 likes | 78 Views
Sometimes you may need to delete write protected file in Linux. Here are the steps to do it.<br><br>Visit https://fedingo.com/how-to-delete-write-protected-file-in-linux/
E N D
Check Permissions Only owners, superusers and root users are allows you to delete or modify write protected files & directories. So first view its permissions using ls -l command. $ ls -l filename -rwxrwxrwt ... In the above output, the last bit ‘t’ is the sticky bit and if its value is t only then it is write protected. Otherwise, anyone can delete it.
Check Directory Permission Next, you need to have write access to the directory (its parent directory) that allows you to modify or delete this file or directory. $ ls -ld dirname If you don’t have enough privileges, you can switch to superuser and then remove the file. $ su - $ rm -f filename
Check i attribute Finally, you need to check if the extended file system ‘i’ attribute is set or not, for this file. If your file or directory has this attribute set, then it cannot be modified, deleted, renamed or linked to. Only root users can add/remove this permission. You can use the lsattr command to check the value of this attribute. $ lsattr filename You will see the following type of output. ----i------------ filename
Change i attribute You can use chattr -i command to remove the file’s ‘i’ attribute. But please note, only the root user will be able to run this command. Once you have removed the ‘i’ attribute for a file or directory, it can be deleted by other users also. $ chattr -i filename $ rm -f filename
Thank You Visit for details https://fedingo.com/how-to-delete-write-protected-file-in-linux/