Recently I have been involved in code porting from Windows to a Linux. I came across so many windows functions which retrieve registry keys and edit it. I am not sure what can be the equivalent approach for Linux. I know registry is just a windows database which stores data in "Key=value" format. I am thinking about INI file. Other than this is there anything that is more efficient?
I am not asking from a storage perspective. My question is related to registry equivalent in Linux. How can we achieve registry structure in Linux?
There's no registry, because all the settings are in text files in /etc and in your home directory. You can edit them with any old text editor.
There is no Registry in linux. But you should take a look at gconf-editor and dconf-editor ... and also hidden files/folders inside your home directory (with names starting with dot), mostly plain (TXT) files containing some configuration for a specific program. Save this answer.
Linux does not have a registry. This is both a blessing and a curse. The blessing is that configuration files are most often kept as a series of text files (think of the Windows . INI files before the days of the Registry).
Why don't Linux operating systems have a registry like Windows? A few different things. At the system level, the /etc directory stores almost all configuration data, largely in plaintext files. There's also stuff in /var like the dpkg database on Debian based systems that records all of the installed software.
A typical way to store configuration in Linux per user is to store it in /home/username/.someapp
, where someapp
is the name of your program. I love this in Linux actually because when I move to another computer, all I have to do is save/move my home directory, and that will save all my configuration.
On Windows, the registry has a user part HKEY_CURRENT_USER
, and others that represent any user, such as HKEY_LOCAL_MACHINE
, being global for the whole system. For the user part, you should put the configuration in the user directory like I explained before, because it shouldn't require any super-user privileges. The local machine part you can choose either to also put in the user directory, where then every user will have separate configuration, or put it in something like /var/lib/someapp
, but keep in mind that it'll be read-only then.
With all this, keep in mind that you should create your own configuration format, or use some library, such as libconfig, XML or JSON.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With