Search code examples
linuxfiledirectoryconfighome-directory

Linux, command line program's config file on home-dir-less setup


Several programs for Linux invoked from terminal/shell use config file where options normally put to program's invocation command line string are put. For instance Vim, for instance curl and their config files ~/.vimrc, ~/.curlrc. If to take curl and Vim they look for such file in the home directory (it works this way at least according to their man pages). However I know Linux setups without home directories. For example a NAS. The known NAS houses several shared volumes / directories to be accessed from client devices via several protocols and by registered users. By default however the NAS does not create home directory for each user newly registered. The administrator hesitate to enable the option "create home directory for this user" if such is needed only for the above purpose.

Is then the usage of program's config file on such setup not possible at all?


Solution

  • To quote from the curl manual:

    When curl is invoked, it always (unless -q is used) checks for a default config file and uses it if found. The default config file is checked for in the following places in this order:

    1) curl tries to find the "home dir": It first checks for the CURL_HOME and then the HOME environment variables. Failing that, it uses getpwuid() on Unix-like systems (which returns the home dir given the current user in your system). On Windows, it then checks for the APPDATA variable, or as a last resort the '%USERPROFILE%\Application Data'.

    2) On windows, if there is no _curlrc file in the home dir, it checks for one in the same dir the curl executable is placed. On Unix-like systems, it will simply try to load .curlrc from the determined home dir.

    So no home directory is needed to store the config files as long, in the case of curl, the variable CURL_HOME, which can point to any location, is set.

    Other programs have similar mechanisms.

    But I am asking myself: Can one can log in (via ssh?) as a user without a home directory?