성태의 닷넷 이야기
홈 주인
모아 놓은 자료
프로그래밍
질문/답변
사용자 관리
사용자
메뉴
아티클
외부 아티클
유용한 코드
온라인 기능
MathJax 입력기
최근 덧글
[정성태] Roll A Lisp In C - Reading ; https...
[정성태] Java - How to use the Foreign Funct...
[정성태] 제가 큰 실수를 했군요. ^^; Delegate를 통한 Bein...
[정성태] Working with Rust Libraries from C#...
[정성태] Detecting blocking calls using asyn...
[정성태] 아쉽게도, 커뮤니티는 아니고 개인 블로그입니다. ^^
[정성태] 질문이 잘 이해가 안 됩니다. 우선, 해당 소스코드에서 ILis...
[양승조
] var대신 dinamic으로 선언해서 해결은 했습니다. 맞는 해...
[양승조
] 또 막혔습니다. ㅠㅠ var list = props[i].Ge...
[양승조
] 아. 감사합니다. 어제는 안됐던것 같은데....정신을 차려야겠네...
글쓰기
제목
이름
암호
전자우편
HTML
홈페이지
유형
제니퍼 .NET
닷넷
COM 개체 관련
스크립트
VC++
VS.NET IDE
Windows
Team Foundation Server
디버깅 기술
오류 유형
개발 환경 구성
웹
기타
Linux
Java
DDK
Math
Phone
Graphics
사물인터넷
부모글 보이기/감추기
내용
<div style='display: inline'> <h1 style='font-family: Malgun Gothic, Consolas; font-size: 20pt; color: #006699; text-align: center; font-weight: bold'>Windows 10 - bash 실행 시 시작 디렉터리 자동 변경</h1> <p> bash 처음 켜면 경로가 /home/[username]으로 설정되어 있는데요.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > TestUser@MYPC:~$ <span style='color: blue; font-weight: bold'>pwd</span> /home/TestUser TestUser@MYPC:~$ </pre> <br /> 이걸 바꾸고 싶다는 질문이 들어와서 잠깐 찾아봤습니다. 뭐랄까, 도스(DOS) 시절 같으면 autoexec.bat에서 "cd ...[path]..." 명령어를 등록해 주면 DOS Shell 시작하자마자 특정 폴더로 이동하게 할 수 있는데... bash는 리눅스이므로 그에 따른 별도의 절차를 따르면 됩니다. 이는 다음의 문서에 잘 나와 있습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > Shell initialization files ; <a target='tab' href='http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_01.html'>http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_01.html</a> </pre> <br /> 위의 문서에 보면 다음의 다양한 설정 파일에 대한 소개가 나옵니다.<br /> <br /> <ul> <li>/etc/profile: 시스템 전역 설정</li> <li>/etc/profile.d: 특정 프로그램에 대한 시스템 전역 설정</li> <li>/etc/bashrc: Bash Shell 전용 설정 파일</li> <li>~/.bash_profile: 사용자 전용 설정 파일</li> <li>~/.bash_login: 사용자 로그인 시에만 실행되는 설정 파일</li> <li>~/.profile: 2개의 설정 파일(~/.bash_profile, ~/.bash_login)이 없는 경우에 적용되는 설정 파일</li> <li>~/.bashrc: 로그인이 없는 환경에서도 참조되는 사용자 설정 파일</li> </ul> <br /> ls -a 명령을 내려보면 이미 ~/.bashrc 파일과 ~/.profile이 있는 것을 볼 수 있습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > TestUser@MYPC:~$ <span style='color: blue; font-weight: bold'>ls -a</span> . .. .bash_history .bash_logout <span style='color: blue; font-weight: bold'>.bashrc .profile</span> TestUser@MYPC:~$ </pre> <br /> 테스트해보면 윈도우의 bash shell을 실행하면 ~/.profile은 로드되지 않고 ~/.bashrc는 로드됩니다.<br /> <br /> 아마도 ~/.profile은 해당 파일에 포함된 주석(executed by the command interpreter for login shells)에 따라 명시적으로 로그인하는 경우에만 실행되는 듯합니다. (~/.bashrc 파일은 주석에서 "executed by bash(1) for non-login shells."라고 명시하고 있습니다.)<br /> <br /> 그럼, 이제 답이 나왔군요. vi든 nano든 편집기를 이용해 .bashrc 파일의 마지막에 cd ...[경로]...를 입력해 두면 됩니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > TestUser@MYPC:~$ <span style='color: blue; font-weight: bold'>nano .bashrc</span> TestUser@MYPC:~$ <span style='color: blue; font-weight: bold'>cat .bashrc</span> # ~/.bashrc: executed by bash(1) for non-login shells. # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) # for examples ...[생략]... # enable programmable completion features (you don't need to enable # this, if it's already enabled in /etc/bash.bashrc and /etc/profile # sources /etc/bash.bashrc). if ! shopt -oq posix; then if [ -f /usr/share/bash-completion/bash_completion ]; then . /usr/share/bash-completion/bash_completion elif [ -f /etc/bash_completion ]; then . /etc/bash_completion fi fi <span style='color: blue; font-weight: bold'>cd /mnt/c/temp</span> </pre> <br /> 이후 bash shell을 시작하면 폴더가 윈도우의 "c:\temp"에 해당하는 경로로 시작합니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > TestUser@MYPC:/mnt/c/temp$ pwd /mnt/c/temp TestUser@MYPC:/mnt/c/temp$ </pre> <br /> <hr style='width: 50%' /><br /> <br /> 참고로, cmd.exe에서 bash를 실행하는 경우 0x80070002 오류가 발생하면서 실행이 안되는 경우가 있습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > c:>bash Error: 0x80070002 </pre> <br /> 다음의 글을 보시면 해답이 나오는데요.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > Problems reinstalling Bash on Ubuntu on Windows Error: 0x80070002 ; <a target='tab' href='http://answers.microsoft.com/en-us/insider/forum/insider_wintp-insider_install/problems-reinstalling-bash-on-ubuntu-on-windows/bb32e0a5-e711-410b-b28b-ebc561d5b4d8?auth=1'>http://answers.microsoft.com/en-us/insider/forum/insider_wintp-insider_install/problems-reinstalling-bash-on-ubuntu-on-windows/bb32e0a5-e711-410b-b28b-ebc561d5b4d8?auth=1</a> </pre> <br /> 제 경우에는 위의 글에서 소개하는 첫 번째 방법인 "Use legacy console" 옵션은 통하지 않았습니다. 대신 관리자 콘솔을 띄운 후 다음과 같이 "lxrun"을 이용해 "Windows Subsystem for Linux"를 재설치하는 것으로 해결되었습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > lxrun /uninstall /full lxrun /install /y </pre> <br /> <hr style='width: 50%' /><br /> <br /> Bash Shell을 실행했는데 사용자 폴더가 다음과 같이 root로 되는 경우가 있습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > root@MYPC:~# <span style='color: blue; font-weight: bold'>pwd</span> /root root@MYPC:~# </pre> <br /> 이건, bash shell을 처음 실행 시 기본 사용자 설정을 하지 않았거나, 또는 lxrun을 이용해 "Windows Subsystem for Linux"를 설치한 경우 그렇게 됩니다.<br /> <br /> 괜찮습니다. ^^ 다음의 글에 따라,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > How to Change Your User Account in Windows 10’s Ubuntu Bash Shell ; <a target='tab' href='http://www.howtogeek.com/261417/how-to-change-your-user-account-in-windows-10s-ubuntu-bash-shell/'>http://www.howtogeek.com/261417/how-to-change-your-user-account-in-windows-10s-ubuntu-bash-shell/</a> </pre> <br /> cmd.exe 창을 띄워 기본 사용자를 설정하거나,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > C:\><span style='color: blue; font-weight: bold'>lxrun /setdefaultuser TestUser</span> 새 UNIX 암호 입력: 새 UNIX 암호 재입력: passwd: password updated successfully Default UNIX user set to: TestUser </pre> <br /> 다시 root 사용자 계정으로 설정할 수도 있습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > C:\><span style='color: blue; font-weight: bold'>lxrun /setdefaultuser root</span> Found UNIX user: root Default UNIX user set to: root </pre> <br /> 현재 사용자의 암호를 변경하고 싶다면 bash shell 내에서 passwd 명령어로 가능합니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > TestUser@MYPC:~$ <span style='color: blue; font-weight: bold'>passwd</span> TestUser에 대한 암호 변경 중 (현재) UNIX 암호: 새 UNIX 암호 입력: 새 UNIX 암호 재입력: passwd: password updated successfully TestUser@MYPC:~$ </pre> <br /> 마지막으로 bash shell 내에서 사용자 인증을 변경하고 싶다면 "su [username]" 명령을 사용하면 됩니다.<br /> </p><br /> <br /><hr /><span style='color: Maroon'>[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]</span> </div>
첨부파일
스팸 방지용 인증 번호
1452
(왼쪽의 숫자를 입력해야 합니다.)