본문 바로가기
메모/코딩

VSCode를 이용하여 윈도우와 WSL 리눅스 간 파일 이동하기

by 붕붕=33 2024. 1. 14.

 

VS Code 공식 문서를 참조하여 윈도우와 WSL 간 파일 이동을 해 볼 것이다.

 

Developing in the Windows Subsystem for Linux with Visual Studio Code

Using Visual Studio Code Remote Development with the Windows Subsystem for Linux (WSL)

code.visualstudio.com

 


1. 설치

아래의 항목들이 pc에 설치되어 있어야 한다.

  • WSL
  • VS Code (WSL이 아닌 윈도우에 설치)
  • (VS Code에서) WSL extension
 

Visual Studio Code - Code Editing. Redefined

Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications.  Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows.

code.visualstudio.com

 

Windows WSL 및 Anaconda 3 설치

Microsoft에서 제공하는 공식 문서를 참조하여 Windows에 WSL2 설치 후 우분투에 Anaconda 3 설치를 진행한다. WSL 설치 wsl --install 명령을 사용하여 Linux용 Windows 하위 시스템을 설치합니다. Ubuntu, Debian, SUSE

ricespoon.tistory.com

 

2. WSL distribution 연결

WSL 터미널에서 열기

  1. WSL 터미널 열기 (윈도우 검색창에 'wsl' 검색하여 열기 가능)
  2. VS Code를 열고자 하는 폴더로 이동
  3. 터미널 프롬프트에 code . 입력

VS Code에서 열기

  1. VS Code 열기
  2. F1 키를 누른 후 'wsl' 키워드 검색
  3. WSL:Connect to WSL 선택하여 디폴트 우분투 distribution 연결 (또는 WSL:Connect to WSL using Distro 선택하여 특정 distribution 연결)

 

3. 폴더 또는 workspace 열기

툴바의 File 메뉴 또는 왼쪽 바 Explorer 아이콘 클릭하여 WSL 시스템 내 폴더 및 파일을 열 수 있다.

윈도우에서 WSL로 파일 이동

  1. Explorer를 클릭하여 폴더 내 파일 목록 열기
  2. 윈도우에 있는 파일을 드래그해 Explorer 창에 놓아 파일 이동

WSL에서 윈도우로 파일 이동

  1. Explorer를 클릭하여 폴더 내 파일 목록 열기
  2. 이동하려는 파일 우클릭 후 Download... 클릭

 

4. WSL 연결 해제 및 시스템 종료

System distribution (Ubuntu) 닫으려면 VS Code 창 왼쪽 아래 초록색 버튼 클릭 후 검색창 드롭다운의 Close Remote Connection 클릭

초록색 status bar

댓글