20161109

来源:互联网 发布:起名网络中国 编辑:程序博客网 时间:2024/05/01 03:11

htop 是Linux系统中的一个互动的进程查看器,一个文本模式的应用程序(在控制台或者X终端中),需要ncurses。

与Linux传统的top相比,htop更加人性化。它可让用户交互式操作,支持颜色主题,可横向或纵向滚动浏览进程列表,并支持鼠标操作。

与top相比,htop有以下优点:

可以横向或纵向滚动浏览进程列表,以便看到所有的进程和完整的命令行。htop还可以查看cpu占用率之类的详细信息,总之我觉得htop比top好用。 
htop的界面如下:

这里写图片描述

htop的安装比较简单,直接可以用apt-get安装:

<code class="hljs bash has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;"><span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">sudo</span> apt-get install htop</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right; opacity: 0.516629;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

2.zsh

Ubuntu默认的shell是bash,但是zsh是一个更加强大的shell,但是因为配置太复杂,虽然很好用但是用的人不多,直到有一个叫做oh-my-zsh的开源项目,它把使用zsh的难度降了下来,接下来我们看看zsh怎么安装和配置。 
Mac默认直接有zsh的,但是Ubuntu默认没有安装zsh,需要我们自己安装:

<code class="hljs bash has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;"><span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">sudo</span> apt-get install zsh</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right; opacity: 0.516629;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

然后安装oh-my-zsh:

<code class="hljs avrasm has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;">git clone git://github<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.com</span>/robbyrussell/oh-my-zsh<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.git</span> ~/<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.oh</span>-my-zsh<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">cp</span> ~/<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.oh</span>-my-zsh/templates/zshrc<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.zsh</span>-template ~/<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.zshrc</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right; opacity: 0.516629;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>

更改默认shell:

<code class="hljs bash has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;">chsh <span class="hljs-operator" style="box-sizing: border-box;">-s</span> /bin/zsh</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right; opacity: 0.516629;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

然后退出重新进入shell,就可以使用zsh。zsh的补全功能非常强大,切换目录时甚至可以不用cd直接输入想要切换的目录,当然了zsh的功能远不止此,具体使用可以参阅终极 Shell,里面有更详细的zsh功能介绍。

3.tmux

tmux是一个优秀的终端复用软件,即使非正常掉线,也能保证当前的任务运行,这一点对于 远程SSH访问特别有用,网络不好的情况下仍然能保证工作现场不丢失!此外,tmux完全使用键盘 控制窗口,实现窗口的切换功能。来看一个tmux的使用截图:

这里写图片描述

这里,我把窗口切分为三个窗口,一个打开vim,其他的进行浏览文件,运行调试程序之用。当然了,如果你乐意,你可以把窗口切分成任意个,只要你屏幕足够大。在没用tmux之前我一直是在图形界面上开一堆终端窗口,然后等到使用时半天找,tmux极大地方便了我们使用shell。 
tmux另外一个非常赞的功能是保存工作现场,如果你用shh连接服务器工作,网络不是那么好,有时会掉线,掉线之后之前进行的工作可能就丢失了,有了tmux之后你就不用担心了,掉线之后tmux依然在后台运行,重新连接之后你只要运行tmux attach,工作现场就回来了。 
当然,tmux还有其他一些功能,同样的你也可以个性化定制自己使用tmux的习惯,只需要配置~/.tmux.conf文件,具体的使用方法请参阅tmux的使用方法和个性化配置

0 0