Can we set permissions, on a Linux box OR for a particular directory (Scientific Linux in my case) that, one can read files but cannot copy, move or delete them?

Update: My Scenario is, We developed an GUI program which are having some images which we have created by consuming lot of time and efforts. Our directory structure is :

/GUI/images/A/A1.jpeg A2.png .... A200.png
/GUI/images/B/B1.png B2.png .... B200.png
/GUI/images/I/I1.png I2.png .... I200.png

No need to say ./GUI.exe calls images which required by user to interact.
Now I need to hide /GUI/images/*.
Is there any way?

5 Answers 5


If a file can be read, it can be copied. You can, however, stop the file from being deleted or moved, by not giving write permissions to the directory where the file resides.

Edited with additional info since the question has been amended:

Given the scenario you've now added to the question, you could do this:

  • create a user that will be used only for this program, e.g. guiuser
  • change the ownership of the /GUI/images directory to e.g. guiuser
  • change the permissions of the directory and files inside it so that only guiuser has read permission
  • change the owner of the program GUI.exe to be owned by guiuser
  • change permissions of the program to run setuid (chmod u+s /GUI/program/GUI.exe)

When your users run the program, that program will have the access rights of guiuser, so the program will be able to read the files even though the ordinary user doesn't have permission.

  • 1
    I am firmly convinced that making the program setuid will only give the illusion of security in that case. How much are you willing to bet that Tejas's program, which was clearly not written with security in mind, will not have any privilege escalation hole? Mar 13, 2013 at 21:43
  • I'm not willing to bet anything at all on that. But then, I wouldn't bet on my own programs either, given how I usually feel about my own code when I come back to it after a year or two.
    – Jenny D
    Mar 14, 2013 at 7:38
  • A second point: if the users really want access to the images, there'll be lots of other ways to crack root on the local system and get at them. Yes, even if you keep the system patched etc.
    – Jenny D
    Mar 14, 2013 at 7:40
  • This will enough for me for now. Thanks Jenny D and all, I will write my program in more secure way now onwards.
    – TPS
    Mar 14, 2013 at 14:42
  • Good luck, and I'm glad I could be of some help.
    – Jenny D
    Mar 14, 2013 at 14:45

Copying isn't magic: it's just reading a file and then saving what you've read somewhere else. So, inherently, if you can read a file, you can copy it.

However, depending on what you are doing, you may be able to accomplish your goal by making the data not readable by normal users, and accessed only through a special program (in the old days, a setuid program; these days, a web app might be more appropriate). That program would dole out bits of the data on request, and not whole files. Since the inherent problem remains, this can't prevent copying, but it can make it more difficult, because you can have logic to rate-limit requests or similar. Or, you can present the data in a in lossy way, rather than giving the raw information. For example, if the source is in HTML, send rendered plain text instead. A determined user could guess and reconstruct the original, but would be unlikely to get an exact result.

  • Thank You. Your answer looks more useful to me, please go through my scenario (updated Question above).
    – TPS
    Mar 13, 2013 at 15:42

If you're going to display those images, they need to be readable. If they can be read, they can be copied, because copying consists of reading something and writing it elsewhere. This goes whether you're displaying them in a custom application or through the web as suggested by mattdm. When a web browser displays an image, it first needs to downloaded (if it didn't download the image, it wouldn't know what to display, after all).

You can grant your program extra privileges, and make the images accessible only with those extra privileges, as suggested by Jenny D. However, there is no chance that you will be able to do that without designing your application to be secure from scratch. Furthermore, the system administrator would have access to the images anyway.

You are almost certainly trying to solve a social problem through technology. This is well-known not to work. Make your users sign a contract stating that they will not copy the images. This is called a license.

  • 1
    * You are almost certainly trying to solve a social problem through technology. This is well-known not to work. * This should be tattooed on the inside of the eyelids of most programmers, managers, et al.
    – Jenny D
    Mar 14, 2013 at 7:41

Update: My Scenario is, We developed an GUI program which are having some images which we have created by consuming lot of time and efforts.

Alright, jacking with the file permissions and setuid() on your application might keep normal users from copying the images. It won't keep a really determined person from "stealing" them though. Gilles hinted at this in a comment to another answer.

You could encrypt the .png images on disk, and have your application decrypt them before using them directly. Again, not perfect, but probably more likely to keep them from being copied easily.

But (here's the bad news), anyone with a screen capture program can simply grab it off the display when your own application uses it. Once it's on the display, it's "stealable" again. Even if they don't know how to do a screen grab, if they have a smartphone or a camera, it's available.

Best hope is probably just to put copyright notices on the images.


Not with regard to the copy. Tools which copy files just read them, and there would be no way for the system to tell what the purpose of a read is.

Unless you completely eliminate a user's capacity to write anywhere, a reasonably competent user will find a way to copy a file if s/he can read it.

  • 2
    If you eliminate my capacity to write anywhere, I might start taking photos of the screen (I'm guessing I can encode about 1MB per screenful given a good camera — I don't know how many colors I'd be able to discriminate reliably). Mar 13, 2013 at 21:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.