通过 SecureCRT(这里使用的是 SecureCRT 7.0.1)连接到 SSH Server:
SecureCRT 的关键配置:
SecureCRT 常用的快捷键如下:
可以使用 Shell 之后,我们还面临的一个问题就是如何把本地的文件上传自 Linux 服务器,这里我们使用 SFTP(SSH file transfer)。在 SecureCRT 中 File -> Connect SFTP Session(或者使用快捷键 Ctrl+F4)打开 SFTP Session,常用的 SFTP 命令如下:
- put -r dir
- put file
第一条命令用于递归的上传本地目录 dir 到远程 Linux 服务器的工作目录下
第二条命令用于上传本地文件 file 到远程 Linux 服务器的工作目录下
- get -r dir
- get file
第一条命令用于递归的下载目录 dir 到本地工作目录下
第二条命令用于下载文件 file 到本地工作目录下
有了 SSH Client,我们就可以执行 Shell 命令,上传下载文件和文件夹了。
编辑代码的工具很多,也有各种不同的做法。一种常见的代码编辑的方式是使用 SSH Client 在远程 Linux 服务器上使用 Vim 或者 Emacs 进行代码编辑。Vim 的基本用法可以参考以下两篇文章:
http://name5566.com/3400.html
http://name5566.com/3402.html
Vim 的基本的配置可以参考:
http://code.google.com/p/name5566-vim-config/
代码构建工具很多,常见的有 make、automake、cmake 等等。读者可以参考云风的关于 make 的相关文章:
http://blog.codingnow.com/2008/09/replacement_of_ide_1.html
http://blog.codingnow.com/2008/09/replacement_of_ide_2.html
http://blog.codingnow.com/2008/09/replacement_of_ide_3.html
http://blog.codingnow.com/2008/09/replacement_of_ide_4.html
http://blog.codingnow.com/2008/09/replacement_of_ide_5.html
http://blog.codingnow.com/2008/09/replacement_of_ide_6.html
一般来说使用 gdb 进行调试,http://name5566.com/4018.html 一文介绍了一些基本的命令来满足我们在调试上的基本需要。
在版本控制工具上,我们常见的主要是 Subversion(SVN)和 git,而后者似乎更加被 Linux 用户所喜爱。这里主要谈一下 SVN 的基本使用。
svn 命令的用法:
- svn <subcommand> [options] [args]
常用的 subcommand 如下:
我们可以设置 vimdiff 为 subversion 的 diff 工具。首先创建一个 Shell 脚本(来源于 http://svnbook.red-bean.com/en/1.4/svn.advanced.externaldifftools.html):
- #!/bin/sh
- # Configure your favorite diff program here.
- DIFF="/usr/bin/vimdiff"
- # Subversion provides the paths we need as the sixth and seventh
- # parameters.
- LEFT=${6}
- RIGHT=${7}
- # Call the diff command (change the following line to make sense for
- # your merge program).
- $DIFF $LEFT $RIGHT
- # Return an errorcode of 0 if no differences were detected, 1 if some were.
- # Any other errorcode will be treated as fatal.
注意修改此 Shell 脚本的权限(u+x)。然后修改 $HOME/.subversion/config 文件:
- [helpers]
- diff-cmd = diff.sh
这里的 diff.sh 为前面所述的 Shell 脚本的路径名。
这里主要介绍一下 Linux 下常用命令的一些最常见用法,实际上,很多命令远比你想象强大,这里并不做详述。
- grep [options] PATTERN [FILE...]
很多命令可能会输出大量信息而其中仅仅一小部分是我们关心的,这时候 grep 是过滤信息的利器,例如:
ls 命令用于显示目录中的内容:
- $ ls -l
- -rw-r--r-- 1 name5566 name5566 0 Nov 2 19:22 file1
- -rw-r--r-- 1 name5566 name5566 0 Nov 2 19:22 file2
- drwxr-xr-x 29 name5566 name5566 4096 Oct 31 17:07 src
- drwxr-xr-x 2 name5566 name5566 4096 Oct 31 16:58 test
假如我们只希望显示目录,可以这么使用:
- $ ls -l | grep ^d
- drwxr-xr-x 29 name5566 name5566 4096 Oct 31 17:07 src
- drwxr-xr-x 2 name5566 name5566 4096 Oct 31 16:58 test
这里的 pattern ^d 含义为行首为 d。再如这样的用法:
- $ ls | grep -i file1
用于判断当前目录下是否存在 file1,这里的 -i 选项表示匹配时忽略大小写。
- $ find . -name file1
用于在当前目录及子目录下查找名字为 file1 的文件。要注意的是,file1 必须是一个完整的文件名而不能是文件名的一部分
- # 查看系统上的所有进程(e 的含义为 every)
- ps -e
- # 输出时使用 full 格式列表(f 的含义为 full)
- ps -ef
- # 输出时使用 long 格式列表(l 的含义为 long)
- ps -el
- # 输出 effective user 为 name 的进程
- ps -u name
- # 使用 full 格式列表
- ps -fu name
- # 向进程 ID 为 pid 的进程发送 SIGTERM 信号
- kill pid
- # 向名称为 name 的所有进程发送 SIGTERM 信号
- killall name
在数据库方面 MySQL 仍然有自己大量的用户。常见的任务: