tmux之基本使用

一、tmux安装

不同版本的Linux/Unix系统请使用不同的软件包管理工具,主流的发行版仓库都有tmux二进制软件包。您还可以选择使用源码安装,到tmux的官网http://tmux.sourceforge.net/下载最新的1.6版本安装(截止20120807),安装时需要解决依赖包( libevent 1.4 or 2.0 and ncurses)。全文以ubuntu为例。

安装

apt-get install tmux -y

查看版本

root@node2:~# tmux -V
tmux 1.6

二、运行tmux

创建一个会话

tmux new -s basic

或者tmux new-session -s basic

退出回话直接exit就可以了

效果图

开启一个tmux回话之后,运行htop。

创建一个后台会话

tmux new -s backrun -d

三、连接和断开会话

创建/断开会话

前面所述tmux new -s basic 开启回话,使用exit退出回话。还有一种简单的快捷的键的方式使用ctrl+d断开连接。

d是detach的缩写。

重新连接回话,查看会话情况。

查看会话

tmux list-sessions

或者tmux ls

root@node2:~# tmux ls
s0: 1 windows (created Tue Aug  7 14:21:00 2012) [125x33] (attached)
s45: 1 windows (created Tue Aug  7 14:21:27 2012) [125x33] (attached)
windows: 1 windows (created Tue Aug  7 14:14:46 2012) [125x33] (attached)
root@node2:~# tmux list-sessions
s0: 1 windows (created Tue Aug  7 14:21:00 2012) [125x33] (attached)
s45: 1 windows (created Tue Aug  7 14:21:27 2012) [125x33] (attached)
windows: 1 windows (created Tue Aug  7 14:14:46 2012) [125x33] (attached)
root@node2:~

连接会话

tmux attach -t s45

杀死会话

tmux kill-session -t s45

四、使用窗口

窗口本人认为就是类似vim一样做窗口分割。

创建一个会话叫做windows,有两个窗口。

tmux new -s windows -n shell   # n参数命名第一个窗口叫做shell

 

 

 

 

 

posted @ 2012-08-07 13:55  changliwei  阅读(610)  评论(0)    收藏  举报