ROKO

Tmux 란 무엇인가? 본문

Artificial Intelligence/Deep Learning

Tmux 란 무엇인가?

RO_KO 2024. 12. 5. 17:46
728x90

 

https://github.com/tmux/tmux/wiki

 

Home

tmux source code. Contribute to tmux/tmux development by creating an account on GitHub.

github.com

 

서버에서 코드를 작업하던 중 네트워크 문제로 서버와 연결이 끊기는 상황이 자주 발생하였다. 학습이라도 돌리고 있는 상황이라면 큰 문제가 발생할 수 있는데, 이럴땐 실행중인 프로세스를 백그라운드로 돌리면 된다. 이를 위해 사용할 수 있는  쉬운 수단이 tmux이다.

 

리눅스에서 그냥 프로세스 백그라운드로 돌리면 되지 왜 굳이 tmux를 써야하는가?

대표적인 장점을 나열해보겠다.

  1. 하나의 터미널을 분할하여 여러 터미널을 실행 할 수 있다.이는 모니터링이나 다양한 작업을 동시에 하는 경우 용이하다.
  2. 터미널의 각 세션에 이름을 붙일수 있다. 기존 리눅스 백그라운드 경우 jobs과 같은 잡다한 명령어를 통해 관리를 하는 반면 tmux는 내가 쓰던 세션을 다시 불러오면 되기에 관리에 용이하다. 또한 다른사람들과 세션을 공유하여 협업도 가능하게 한다.
  3. 단축키를 통해 단순한 조작으로 복잡한 환경을 제어할 수 있다.

이외에도 많은 장점이 있으니 관심이 있다면 아래 글을 참조하자.

https://www.reddit.com/r/tmux/comments/v84prx/can_somebody_explain_to_me_why_i_would_use_tmux/

 

From the tmux community on Reddit

Explore this post and more from the tmux community

www.reddit.com

 

https://stackoverflow.com/questions/53189675/what-is-merit-of-terminal-multiplexer-compared-to-standard-terminal-app-and-job

 

What is merit of terminal multiplexer compared to standard terminal app and job control?

I don't know what is a merit of a terminal multiplexer like screen or tmux compared to combination of a standard terminal application and a job control feature of a shell. Typically good features ...

stackoverflow.com

 

Tmux 구성요소

  1. session
    • tmux의 가장 큰 실행 단위
    • 여러 윈도우로 구성 가능
  2. window
    • 터미널 화면
  3. panel
    • 윈도우 내의 화면 분할되는 각각의 객체

 

Tmux 설치

# linux
sudo apt-get install tmux

# mac
brew install tmux

 

Tmux 명령어 & 단축키

  • tmux의 기본 hotkey는 ctrl+b이기 때문에 먼저 hotkey를 누른뒤 해당하는 추가 key를 입력해야한다.
  • ex) ctrl+b+d 일때 → (ctrl+b)+d (O)   (ctrl+d)+b (X)

세션 생성

# 이름을 지정하지 않는 경우, default name: 0, 1, 2 ...
tmux

이름을 포함한 세션 생성

tmux new -s [session_name]

세션 이름 변경

# prefix key
(ctrl + b) + $

tmux rename-session -t <now_session_name> <new_session_name>

현재 실행중인 세션 리스트

tmux ls

 현재 실행중인 세션 접속

tmux -attach -t <session_name>

세션 종료

# 세션을 background로 전환, 프로세스 종료 x
(ctrl + b) + d

# 세션&프로세스 종료 o
exit

# tmux session 밖에서 세션 종료&프로세스 종료
tmux kill-session -t <session_name>

윈도우 컨트롤 단축키

# 새로운 윈도우 생성
(ctrl + b) + c

# 다음 윈도우로 이동
(ctrl + b) + n

# 이전 윈도우로 이동
(ctrl + b) + p


# 특정 윈도우로 이동
(ctrl + b) + <window_name>

# 해당 윈도우 제거
(ctrl + b) + x

# 해당 윈도우 이름 변경
(ctrl + b) + ,

 

 

이 정도만 알고 있다면 웬만한 작업은 수행 할 수 있다.

더 궁금하다면 아래 페이지 참고

https://github.com/tmux/tmux/wiki/Getting-Started

 

Getting Started

tmux source code. Contribute to tmux/tmux development by creating an account on GitHub.

github.com

https://linux.die.net/man/1/tmux

https://tmuxcheatsheet.com/

 

Tmux Cheat Sheet & Quick Reference | Session, window, pane and more

Master tmux with the comprehensive cheat sheet: session management, examples, installation guide and more for the ultimate terminal multiplexer.

tmuxcheatsheet.com

 

728x90
Comments