How to freeze a folder in linux? - linux

I wanna to freeze a folder in red hat so nobody (even root) can not add file into the folder or change files that exist in the folder already, i tried to make folder read only but this does not work and root user can add files normally as before, please somebody help me to solving this problem.

Create a filesystem in a file (eg: an iso file) containing the files you want in the directory then use a loopback mount to mount it read only onto the directory.
Anybody who tries to modify the filesystem normally (including root) will get a "read-only filesystem" error.

No. By design, in Linux, root ignores existing permissions on all entities. However, what you can do is encrypt files so that they can't be read and can't be modified by those who don't know the key. You can't prevent new files from being added, but with both encryption and decryption keys private, you can easily verify if any file is valid.
This also means you can't have either key on your computer!

Related

Interrupt file-system operation

Assume that I have a directory that should contain only jpg files.
How can I prevent users from adding files that don't have jpg format to that directory?
My initial guess was to use inotify but it doesn't seem to give me the ability to interrupt/block the "operation" on the file / directory.
My second guess was to set the directory to read-only, when a user adds a file I'll check its extension then add the write permission to the directory before it gets an invalid access error.
Assume any file system that Linux supports
This file system will be used by Samba if this is a helpful info.

Perforce messes up symlinks

When I download source code from perforce, the symlinks gets downloaded as files and the project, of course, doesn't build. This happens on certain computers and virtual machines but the same symlinks download fine on other computers.
The download file is often a short file which just contains path of the linked file instead of being zero byte symlink file.
This actually had to do with user permissions on windows, not so much with perforce. The problem is that the user doesn't have permission to create symlinks so perforce ends up creating a file (In my opinion, it should generate an error message instead of converting the symlink to file).
The simple solution in most cases should be to start P4V as administrator and then download the source code. You may have to force it to download everything since it will not re-download wrong symlinks because those objects already exist on disk.
You can check if you have permissions with the following command. More here.
mklink <linkFile> <ExistingFile>
Note: you may well be able to create symlinks (=shortcuts) using File Explorer but it's the command line (above) that will determine if you have the privileges or not.

How can I make a file "permanent" in a Linux live version?

I am working with a live Linux version. If I create a user and that user creates a file, how can I make that file visible for that user after I have restarted the system? (Normally it would be erased)
You can save the file in the device's hard drive, if you are using a CD/DVD.
In case you are using a flash drive, you can save the file in the root / folder.
Note: Be careful with name given in root folder, try to avoid things like boot or other names found in that folder. They are used to start the live system and boot manager usually recognize them based only in file names

mounting an .iso file into a directory and replacing all of its content

I was trying to install matlab on my linux (mint) computer, using some of the .iso files. I was trying to mount one of them using the command
mount R2017a_glnxa64_dvd1.iso /home/.../Documents/
which seems to have mounted the .iso file into my Documents directory and replaced everything there. When I try and open up the Documents directory, it just contains the contents of the .iso file and none of the files which I know were in there previously.
If I go to, say libre office, and click 'open recent file', any of my recent files which were in my documents now don't exist. This is quite worrying as I have a lot of work in there which isn't backed up.
I don't really know anything about what mount does. Will it have permanently deleted all the files from my Documents directory? I can 'unmount' the Documents directory now, but am worried it might be a bad idea and permanently delete the stuff that used to be there. Can anyone help me try and recover my Documents directory?
thanks

KohanaException : Directory APPPATH\cache must be writable

i am trying to run a project of kohana-3 in wamp server but getting following error
Kohana_Exception [ 0 ]: Directory APPPATH\cache must be writable
please help.
Previously this was working fine.
You must set your cache folder to be writable.
Bare in mind that usually in WAMP the PHP user is 'nobody' which doesn't have access to your folders, therefore you must set your folders to be writable.
Check whether the file actually exists (application/cache), this folder comes empty with Kohana, and some versioning systems and other software usually delete and ignore empty folders.
If it does not exist, create the folder and insert a blank file in it (ie, empty.txt) if the error persists, give the appropriate permissions.
Oh yeah, I read an answer from someone yesterday but I only figured it out today. What I did was this:
Go inside application/
Create a new folder cache/
Go inside cache/
Create a empty textfile. (I created empty.txt)
Then thats it. hope it helps

Resources