Windows Registry equivalent support for Linux in .Net 5

Sruti Ranjan Majhi 1 Reputation point

We are planning to Move our existing C# .Net framework supported application to .Net 5 or .Net 6 and will be platform indepedent (for now Windows and Linux).
The .Net framework implementaion currently depends on Windows Registry to store few information. Was unable to find any equivalent mechanism to store the same in the Linux platform. Basically i am looking for an similar functionality like "preference" class does in Java.

Any help is appreciated and Thanks in advance.

Microsoft Technologies based on the .NET software framework.
3,165 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
9,943 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Ken Tucker 5,841 Reputation points

    There is not an equivalent to the registry in Linux. What are you storing in the registry? First thought is to use a config file but depending on what is stored maybe there is a better way

  2. Bruce ( 52,496 Reputation points

    Linux uses configuration files rather than a registry. Historically there were two locations

    ~/.programname - user config, for example git uses ~/.gitrc
    /etc/programname/ - global system

    But as the number of files has gone up and security increased, there is no true consensus.

    ~/.config/ is now a popular location for user configuration file.

    Global config file location varies by how changeable. See

    Note: is also common to use environment variables to define the location of the config files

  3. Bruce ( 52,496 Reputation points

    .net 6 focuses more on reading configuration (app settings) then setting them. there is an azure app setting provider (pushing cloud), but not much for local storage. as dotnet applications are usually deployed to a folder (except on MacOs), typically you can do a read/write appsettings.json file. see all the configuration builder options.

    in unix/linux/MacOs there a read only filesystems, where system applications go, and folders for local hardware applications, and read/write folders for data. Of course MacOs has a folder for UI applications, but command line follow the unix conventions, and home-brew has its own conventions.

    note: there may be a nuget package that does what you want, but I don't know of one.

    0 comments No comments

  4. Petrus 【KIM】 456 Reputation points

    Use the JSON file Rather than Registry. There is not an equivalent...

    public class SomeInfo
        public string KeyName { get; set; }
    public class ConfigManager
        public SomeInfo LoadFromJson(string sFilePath)
            var vJsonText = File.ReadAllText(sFilePath);
            // .NET CORE
            var vOption = new JsonSerializerOptions
                 WriteIndented = true,
                 PropertyNamingPolicy = null,
                 IgnoreNullValues = true,
                 Encoder = JavaScriptEncoder.Create(UnicodeRanges.All)
            return JsonSerializer.Deserialize<SomeInfo>(vJsonText, vOption);
    --- JSON FILE
       "KeyName" : "Value"
    0 comments No comments