시작하기 전에
이 글을 시작하기 전에 다음 전제 조건을 완료합니다.
- Windows Update를 가장 최신버전까지 업데이트 받습니다.
들어가며
WSL이란?
WSL은 Windows Subsystem for Linux의 약자로, 윈도우 환경에서 리눅스를 사용할 수 있는 기능을 말합니다.
Part 1. WSL2 사용을 위한 준비
먼저 Windows Power Shell을 관리자 권한으로 실행한 뒤 아래 내용을 진행합니다.
Step 1.1. Linux용 Windows 하위 시스템 기능 활성화
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Step 1.2. 가상 머신 플랫폼 기능 활성화
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Step 1.3. BIOS의 Hyper-V 기능 활성화
bcdedit /set hypervisorlaunchtype auto
여기까지 완료 했다면 활성화된 기능들을 적용하기 위해 PC를 반드시 재부팅 해야합니다.
Step 1.4. WSL2 업데이트
아래 링크를 클릭해서 마이크로소프트 WSL2 업데이트 파일(wsl_update_x64.msi)을 다운받아 설치합니다.
https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
Part 2. Ubuntu 설치
Step 2.1. Ubuntu 앱 설치
Windows 10 이상에서는 Microsoft Store가 기본적으로 설치되어 있습니다. 스토어에 들어가서 검색창에 ubuntu를 검색해서 설치합니다. (다른 버전이 있는것도 있는데 그냥 Ubuntu 를 설치하시면 됩니다.)

Step 2.2. Ubuntu 초기 설정
Sub step 2.2.1. 사용자 계정 생성
최초 실행시에는 Installing, this may take a few minutes...라며 앱을 실행할 준비의 시간이 필요합니다.
잠시 기다렸다가 Enter new UNIX username: 문구가 보이면 아래 내용을 참고하여 Ubuntu에 사용자 계정을 생성합니다.
(저는 lude라는 계정으로 사용자 계정을 만들었습니다.)
Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: lude # 사용할 사용자 계정명 입력
New password: # 계정 비밀번호 입력
Retype new password: # 계정 비밀번호 입력 확인
passwd: password updated successfully
Installation successful!
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
Welcome to Ubuntu 22.04.4 LTS (GNU/Linux 5.10.102.1-microsoft-standard=WSL2 x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Sat Nov 25 10:47:05 KST 2023
System load: 0.0 Processes: 8
Usage of /: 0.5% of 250.98GB Users logged in: 0
Memory usage: 1% IPv4 address for eth0: xxx.xxx.xxx.xxx
Swap usage: 0%
1 update can be applied immediately.
To see these additional updates run: apt list --upgradable
The list of available updates is more than a week old.
To check for new updates run: sudo apt update
This message is shown once a day. To disable it please create the
/home/lude/.hushlogin file.
lude@XXXXX:~$ # 위에서 만든 사용자 계정으로 접속된 것을 확인(사용자 계정 명 : lude)
Sub step 2.2.2. 사용자 계정을 관리자 그룹에 등록
방금 만들어진 사용자 계정을 관리자 그룹에 등록하여 sudo 명령어 및 이후에 설치할 패키지들을 설치할 수 있는 권한을 부여합니다.(root로 해도 되지만 추후 VSCode등을 연계할 때 권한문제로 많이 귀찮아집니다.)
lude@XXXXX:~$ sudo usermod -aG root $USER
[sudo] password for lude: # 앞에서 설정한 패스워드 입력
Sub step 2.2.3. 최신 패키지 업데이트
이제 사용자(lude)는 sudo 명령어를 사용하여 관리자의 커맨드를 실행할 수 있습니다. Ubuntu에 설치된 패키지들을 최신 버전으로 업데이트합니다.
lude@XXXXX:~$ sudo apt-get update && sudo apt-get upgrade -y
Troubleshooting
WSL을 재설치하거나 Ubuntu 를 초기화 및 삭제 후 다시 설치했을 때 다음과 같은 오류가 발생할 수 있습니다.
- 문제1. 디스크를 WSL2에 연결하지 못했습니다. 지정된 파일을 찾을 수 없습니다.
- 해결1. CMD를 관리자 권한으로 실행한 뒤, wsl --unregister Ubuntu 명령을 실행하여 기존에 설치된 Ubuntu를 wsl에서 등록 해제합니다. 그리고 다시 처음부터 설치를 진행합니다.
'개발환경 설정' 카테고리의 다른 글
| 윈도우에 개발환경 구성하기 - 계획 (0) | 2024.01.01 |
|---|