How Do I Make a File Read Only in Linux?
Contents

You can use the chmod command to set read-only permission for all files on a Linux / Unix / macOS / Apple OS X / *BSD operating systems.

How do I make a text file read only in Linux?

You can alter a file’s permissions with the ‘chmod‘ command: Read-only to your UID (userid): chmod 400 <filename> Read-only to you and your GID (group): chmod 440 <filename>

How do I make a file not editable in Linux?

Method #1: You can make file readonly by removing users’ write permission for a file. Under Linux and UNIX user cannot remove or modify file if they don’t have a write permission. You can use normal chmod command for this purpose.

James H. Sterling

James H. Sterling

Environmental Science & Climate Journalist

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.

Share this article
Twitter Facebook Pinterest