I am using Ubuntu 12.04 and I want to protect some pictures of another user using the su command (I have admin privileges). How can I protect a file using the terminal while still allowing the rest of the users to read it?
Ubuntu uses the EXT4 file-system format by default (I am assuming that we are not talking about anything else here).
If you do not want to take ownership of the file without removing the ability for the user to read that file you can start by allowing them to read, but not write to that file with:
description: change file permissions, all cannot write, user+group can read
Then can make files immutable so that even users with root permission cannot change then by using the following:
To be able to delete or even modify this file you would need to use the command:
and then you will be able to do something with it.
The plus point of using this is that most users (and admins) never have experienced immutable files in Linux.
That was the user will see this when trying to remove (or alter) the file:
while still being able to read it:
After you issue
If by protect, you mean prevent any modifications to these files at all, consider using the chattr utility. It has the option mark files as immutable (unable to be changed).
This will prevent all users and even the root user from removing or modifying any files set as immutable.
You can reverse this action by replacing the "+i" with "-i".
I recommend to use Truecrypt to create an encrypted "removable disk" to 1 file.
If you create for example 1GB Truecrypt partition and you can protect this file with password. (Expert option: you can set 2 password for that file: with first password you see a normal part of file and with password 2 you see the hidden part)
You can mount this file in Linux, Mac or in Windows (mount to drive
If you create that 1GB file (or any size, or a full disk or pendrive) you can add any extension for that file to hide. (Never place that file at your home directory as secret.truecrypt.file.with.pwd lol)
If you use any system file name in system folder maybe normal user never notice it's not a system file it's a private encrypted file.
For example for hide this file:
Other temp filenames:
You can install truecrypt if you want, for example:
More information in Truecrypt homepage
Try the below command on terminal,
The above command won't allow the another user or group to read or write that directory where pictures are stored.
To revert back the changes run the above command.
If you want to encrypt the file you can use
After installation type