본문 바로가기
컴퓨터 & IT (Computer & IT)/Windows and Powershell

[Windows] Cygwin 유저 홈 디렉토리 변경

by Physics 2023. 1. 23.
728x90

일반적으로 Cygwin을 설치를 하게 되면, 기본적인 루트 디렉토리와 유저의 홈디렉토리는 아래와 같다; 
 - 루트 디렉토리: C:/cygwin  
 - 유저 홈 디렉토리: C:/cygwin/home/<user>
하지만, windows 내에서의 기본적인 유저의 홈 디렉토리의 위치는 아래와 같다; 
- 윈도우 내의 유저 홈 디렉토리: C:/users/<user>/
이러한 디렉토리의 위치 차이로 인해 , cygwin에서 작업을 할 때 유저의 홈 디렉토리에 있는 파일에 접근하는 경우, 불편함을 겪는 경우가 종종 있다. 하지만 윈도우의 유저 홈 디렉토리에 있는 간단하게 접근을 하는 방법이 있다. 

최근 버전의 Cygwin에서는 cygwin의 환경 파일 중 하나를 편집하여 간단하게 위의 일을 처리할 수 있다. 
- /etc/nsswitch.conf를 "db_home" property를 %H를 사용하여 윈도우 유저 홈 디렉토리로 변경한다. 

# /etc/nsswitch.conf
#
#    This file is read once by the first process in a Cygwin process tree.
#    To pick up changes, restart all Cygwin processes.  For a description
#    see https://cygwin.com/cygwin-ug-net/ntsec.html#ntsec-mapping-nsswitch
#
# Defaults:
# passwd:   files db
# group:    files db
# db_enum:  cache builtin
db_home: /%H
# db_shell: /bin/bash
# db_gecos: <empty>

이후, 터미널을 다시 시작하면, 홈 디렉토리가 윈도우 유저 홈디렉토리로 변경이 되어있음을 확인할 수 있다. (~명령어 역시 변경된 디렉토리를 가리키게 된다.)

728x90

댓글