Programing

Linux / unix에서 ini / config 파일의 위치?

lottogame 2020. 11. 29. 09:33
반응형

Linux / unix에서 ini / config 파일의 위치?


두 가지 질문이 있습니다.

(1) 구성 파일의 배치에 관한 표준 / 규약이 있습니까? 시스템 또는 준 시스템 프로그램의 경우 일반적으로 / etc에있는 것처럼 보입니다. / etc에 대한 권한이 부족한 일반 응용 프로그램이나 pgm에 대해서는 명확하지 않은 것 같습니다.

(2) 환경 변수, 명령 줄 옵션, ini 파일 등과 같이 프로그램에 정보를 제공하는 방법에는 여러 가지가 있습니다. 프로그램 옵션을 처리 할 때 우선 순위가 부여되는 표준 계층이 있습니까? 예를 들어 명령 줄 옵션이 초기화 파일을 재정의합니까? 그 반대? 아니면 전적으로 개발자에게 달려 있습니까?


  1. 일반적으로 시스템 / 글로벌 구성은 / etc 아래에 저장됩니다.
  2. 사용자 별 구성은 사용자의 홈 디렉토리에 종종 숨겨진 파일로, 때로는 숨겨진 파일 (및 더 많은 하위 디렉토리)을 포함하는 숨겨진 디렉토리로 저장됩니다.

일반적으로 명령 줄 옵션은 시스템 기본값을 재정의하는 사용자 기본값을 재정의하는 환경 변수를 재정의합니다.


애플리케이션은 XDG 기본 디렉토리 사양 을 준수해야합니다 . 여기에있는 대부분의 답변은 구식이거나 잘못되었습니다.

애플리케이션은 다음 환경 변수가 가리키는 디렉토리에 데이터 및 구성 파일을 저장하고로드해야합니다.

  • $XDG_DATA_HOME(기본값 :) : "$HOME/.local/share"사용자 별 데이터 파일.
  • $XDG_CONFIG_HOME(기본값 :) : "$HOME/.config"사용자 별 구성 파일.
  • $XDG_DATA_DIRS(기본값 "/usr/local/share/:/usr/share/":) : 우선 순위가 지정된 시스템 데이터 디렉토리 집합입니다.
  • $XDG_CONFIG_DIRS(기본값 "/etc/xdg":) : 우선 순위가 지정된 시스템 구성 디렉토리 집합입니다.
  • $XDG_CACHE_HOME(기본값 :) : "$HOME/.cache"사용자 특정 비 필수 데이터 파일.

먼저 문제의 파일이 다음과 같은지 확인해야합니다.

  1. 구성 파일 ( $XDG_CONFIG_HOME:$XDG_CONFIG_DIRS);
  2. 데이터 파일 ( $XDG_DATA_HOME:$XDG_DATA_DIRS); 또는
  3. 필수가 아닌 (캐시) 파일 ( $XDG_CACHE_HOME).

응용 프로그램이 위 디렉토리의 하위 디렉토리에 파일을 배치하는 것이 좋습니다. 일반적으로 $XDG_DATA_DIRS/<application>/filename또는 $XDG_DATA_DIRS/<vendor>/<application>/filename.

로드 할 때 먼저 사용자 별 디렉토리 ( $XDG_*_HOME) 에서 파일을로드하고 실패한 경우 시스템 디렉토리 ( $XDG_*_DIRS) 에서 파일을로드합니다 . 저장할 때 사용자 별 디렉터리에만 저장합니다 (사용자가 시스템 디렉터리에 대한 쓰기 액세스 권한이 없을 수 있기 때문).

다른 사용자 지향적 인 디렉토리에 대해서는 XDG 사용자 디렉토리 사양을 참조하십시오 . 데스크탑, 다운로드, 문서, 비디오 등에 대한 디렉토리를 정의합니다.


최신 애플리케이션

XDG 기본 디렉토리 사양을 따르십시오 일반적 ~/.config/yourapp/*으로 INF, JSON, YML 또는 보트에 떠 다니는 형식이 될 수 있으며 모든 파일 yourapp은 실행 파일 이름과 일치하거나 조직 / 회사 / 사용자 이름 / 핸들과 함께 네임 스페이스가 지정되어야합니다.~/.config/yourorg/yourapp/*

이전 애플리케이션

일반적으로 홈 디렉토리에서 사용자 별 구성 ...

  • ~/.yourapp 단일 파일 용 파일
  • ~/.yourapp/여러 파일 + 일반적으로 ~ / .yourapp / config에 있는 데이터

전역 구성은 일반적으로 /etc/appname파일 또는 /etc/appname/디렉토리에 있습니다.

글로벌 앱 데이터 : /var/lib/yourapp/

캐시 데이터 : /var/cache/

로그 데이터 : /var/log/yourapp/


tutorialhelpdesk.com의 추가 정보

Linux / 기타 Unix 계열 시스템의 디렉토리 구조 및 디렉토리 세부 사항.

Windows에서 거의 모든 프로그램은 'Program Files'라는 디렉토리에 파일 (모든 파일)을 설치합니다. Linux에서는 그렇지 않습니다. 디렉토리 시스템은 설치된 모든 파일을 분류합니다. 모든 구성 파일은에 /etc있고 모든 이진 파일은 /bin또는 /usr/bin또는에 /usr/local/bin있습니다. 다음은 포함 된 내용과 함께 전체 디렉토리 구조입니다.

/-파일 시스템의 기반을 형성하는 루트 디렉토리. 모든 파일 및 디렉토리는 물리적 위치에 관계없이 루트 디렉토리 내에 논리적으로 포함됩니다.

/bin-Linux 운영 체제의 일부인 실행 프로그램을 포함합니다. cat, cp, ls, more 및 tar와 같은 많은 Linux 명령은 다음 위치에 있습니다./bin

/boot -LILO 및 GRUB 부팅 관리자에 필요한 Linux 커널 및 기타 파일이 포함되어 있습니다.

/dev-모든 장치 파일을 포함합니다. Linux는 각 장치를 특수 파일로 취급합니다. 이러한 모든 파일은 /dev.

/etc-대부분의 시스템 구성 파일과 /etc/rc.d하위 디렉토리에 있는 초기화 스크립트를 포함 합니다.

/home -홈 디렉토리는 사용자 홈 디렉토리의 상위입니다.

/lib -시스템 부팅에 필요한로드 가능한 드라이버 모듈을 포함한 라이브러리 파일이 포함되어 있습니다.

/lost+found-손실 된 파일의 디렉토리. 모든 디스크 파티션에는 lost + found 디렉토리가 있습니다.

/media -CD-ROM 드라이브, 플로피 디스크 및 Zip 드라이브와 같은 이동식 미디어에 파일 시스템을 마운트하기위한 디렉토리입니다.

/mnt -임시로 마운트 된 파일 시스템을위한 디렉토리.

/opt -옵션 소프트웨어 패키지는 여기에서 파일을 복사 / 설치합니다.

/proc - A special directory in a virtual filesystem. It contains the information about various aspects of a Linux system.

/root - Home directory of the root user.

/sbin - Contains administrative binary files. Commands such as mount, shutdown, umount, reside here.

/srv - Contains data for services (HTTP, FTP, etc.) offered by the system.

/sys - A special directory that contains information about the devices, as seen by the Linux kernel.

/tmp - Temporary directory which can be used as a scratch directory (storage for temporary files). The contents of this directory are cleared each time the system boots.

/usr - Contains subdirectories for many programs such as the X Window System.

/usr/bin - Contains executable files for many Linux commands. It is not part of the core Linux operating system.

/usr/include - Contains header files for C and C++ programming languages

/usr/lib - Contains libraries for C and C++ programming languages.

/usr/local - Contains local files. It has a similar directories as /usr contains.

/usr/sbin - Contains administrative commands.

/usr/share - Contains files that are shared, like, default configuration files, images, documentation, etc.

/usr/src - Contains the source code for the Linux kernel.

/var - Contains various system files such as log, mail directories, print spool, etc. which tend to change in numbers and size over time.

/var/cache - Storage area for cached data for applications.

/var/lib - Contains information relating to the current state of applications. Programs modify this when they run.

/var/lock - Contains lock files which are checked by applications so that a resource can be used by one application only.

/var/log - Contains log files for different applications.

/var/mail - Contains users' emails.

/var/opt - Contains variable data for packages stored in /opt directory.

/var/run - Contains data describing the system since it was booted.

/var/spool - Contains data that is waiting for some kind of processing.

/var/tmp - Contains temporary files preserved between system reboots.


Please do also consult the Filesystem Hierarchy Standard.


  1. Typically in a dotfile (like .myprogramrc) in the user's home directory.
  2. It is of course up to the programmer but normally command line arguments override everything else. If environment variables are used it is usually as an alternative to the command line arguments or to specify where the configuration is located.

For user configuration I've noticed a tendency towards moving away from individual ~/.myprogramrc to a structure below ~/.config. For example, Qt 4 uses ~/.config/<vendor>/<programname> with the default settings of QSettings. The major desktop environments KDE and Gnome use a file structure below a specific folder too (not sure if KDE 4 uses ~/.config, XFCE does use ~/.config).


(1) No (unfortunately). Edit: The other answers are right, per-user configuration is usually stored in dot-files or dot-directories in the users home directory. Anything above user level often is a lot of guesswork.

(2) System-wide ini file -> user ini file -> environment -> command line options (going from lowest to highest precedence)

참고URL : https://stackoverflow.com/questions/1024114/location-of-ini-config-files-in-linux-unix

반응형