chmod: Setting a file read-only in Linux
The tutor uses Linux and Windows both, so he tries to cover them equally.
In yesterday’s post I explained a way to set a file read-only in Windows. Today, I do so for a Linux system.
Linux has many flavours; I use Ubuntu. I’m told that some more elite Linux users find Ubuntu “too easy to use – anyone can use it.” (I’m sure the Ubuntu developers are only too happy to hear such criticism.)
Although Ubuntu has a very user-friendly desktop, it also has the terminal. The highbrow might be more comfortable there. It’s the context I’m using today, because so far as I know, the terminal is common to all Linux users.
Let’s imagine you’ve just finished a program called prog0.txt, which you’ve saved in your scripts directory. You’ve tested it and you’re very pleased. Naturally, you want to safeguard it from impetuous changes.
Here’s how you can set it read-only:
- For simplicity’s sake, close the file first.
- In the terminal, navigate yourself into the scripts directory.
- Type the command chmod 444 prog0.txt
On Linux, the text editor I use is gedit. When I open a read-only file in gedit, no indication appears that the file is read only. However, when I try to make a change to the file, a read-only message appears across the top. If I try to save any changes, I am forced to save them under a different file name.
Besides this simple use, the chmod command has other capabilities. I’ll be covering some of them in future posts:)
Source:
McGrath, Mike. Linux in easy steps. Southam: Computer Step, 2008.
Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.
Leave a Reply
You must be logged in to post a comment.