知行合一

使用mac电脑后ssh提示Permission denied (publickey,gssapi-with-mic).

嘟嘟鱼阅读(4359)

此问题困扰我好几天了,起初以为是服务器配置问题,网上搜了很多解决方法都不行,今天叫其他同事测试都没问题,后来问了另一个朋友,告知win不同于linux和osx,linux和osx连接服务器ssh xx.xx.xx.xx相当于 ssh username@xx.xx.xx.xx,隐藏了用户名,而win系统直接就是 ssh xx.xx.xx.xx,所以我电脑的用户名和服务器的用户名不匹配,导致了服务器之间连接提示如下错误:

Permission denied (publickey,gssapi-with-mic).

知道问题的原因就好办了,我使用的是SecureCRT软件,点击Options>Global Options>SSH2,勾选Enable OpenSSH agent forwarding。保存退出软件,重新连接服务器就ok了。特意看了下同事的windows下的SecureCRT默认就是勾选这个的,mac的不是。。。

QQ20140114

mac下创建crontab 失败的问题

嘟嘟鱼阅读(11736)

想弄个计划任务,用crontab -e编辑完之后会提示

crontab: “/usr/bin/vi” exited with status 1

VI的问题,比较简单的解决办法是直接执行

EDITOR=vim crontab -e

然后按i插入数据,保存退出即可,下次编辑直接用
crontab -e
就可以了。

实用手册:130+提高开发效率的vim常用命令

嘟嘟鱼阅读(1112)

基本命令

:e filename Open filename for edition
:w Save file
:q Exit Vim
:q! Quit without saving
:x Write file (if changes has been made) and exit
:sav filename Saves file as filename
. Repeats the last change made in normal mode
5. Repeats 5 times the last change made in normal mode

在文件中移动

k or Up Arrow move the cursor up one line
j or Down Arrow move the cursor down one line
e move the cursor to the end of the word
b move the cursor to the begining of the word
0 move the cursor to the begining of the line
G move the cursor to the end of the file
gg move the cursor to the begining of the file
L move the cursor to the bottom of the screen
:59 move cursor to line 59. Replace 59 by the desired line number.
20| move cursor to column 20.
% Move cursor to matching parenthesis
[[ Jump to function start
[{ Jump to block start

剪切、拷贝和粘贴

y Copy the selected text to clipboard
p Paste clipboard contents
dd Cut current line
yy Copy current line
y$ Copy to end of line
D Cut to end of line

搜索

/word Search word from top to bottom
?word Search word from bottom to top
* Search the word under cursor
/\cstring Search STRING or string, case insensitive
/jo[ha]n Search john or joan
/\< the Search the, theatre or then
/the\> Search the or breathe
/\< the\> Search the
/\< ¦.\> Search all words of 4 letters
/\/ Search fred but not alfred or frederick
/fred\|joe Search fred or joe
/\<\d\d\d\d\> Search exactly 4 digits
/^\n\{3} Find 3 empty lines
:bufdo /searchstr/ Search in all open files
bufdo %s/something/somethingelse/g Search something in all the open buffers and replace it with somethingelse

替换

:%s/old/new/g Replace all occurences of old by new in file
:%s/onward/forward/gi Replace onward by forward, case unsensitive
:%s/old/new/gc Replace all occurences with confirmation
:2,35s/old/new/g Replace all occurences between lines 2 and 35
:5,$s/old/new/g Replace all occurences from line 5 to EOF
:%s/^/hello/g Replace the begining of each line by hello
:%s/$/Harry/g Replace the end of each line by Harry
:%s/onward/forward/gi Replace onward by forward, case unsensitive
:%s/ *$//g Delete all white spaces
:g/string/d Delete all lines containing string
:v/string/d Delete all lines containing which didn’t contain string
:s/Bill/Steve/ Replace the first occurence of Bill by Steve in current line
:s/Bill/Steve/g Replace Bill by Steve in current line
:%s/Bill/Steve/g Replace Bill by Steve in all the file
:%s/^M//g Delete DOS carriage returns (^M)
:%s/\r/\r/g Transform DOS carriage returns in returns
:%s#<[^>]\+>##g Delete HTML tags but keeps text
:%s/^\(.*\)\n\1$/\1/ Delete lines which appears twice
Ctrl+a Increment number under the cursor
Ctrl+x Decrement number under cursor
ggVGg? Change text to Rot13

大小写

Vu Lowercase line
VU Uppercase line
g~~ Invert case
vEU Switch word to uppercase
vE~ Modify word case
ggguG Set all text to lowercase
gggUG Set all text to uppercase
:set ignorecase Ignore case in searches
:set smartcase Ignore case in searches excepted if an uppercase letter is used
:%s/\<./\u&/g Sets first letter of each word to uppercase
:%s/\<./\l&/g Sets first letter of each word to lowercase
:%s/.*/\u& Sets first letter of each line to uppercase
:%s/.*/\l& Sets first letter of each line to lowercase

读写文件

:1,10 w outfile Saves lines 1 to 10 in outfile
:1,10 w >> outfile Appends lines 1 to 10 to outfile
:r infile Insert the content of infile
:23r infile Insert the content of infile under line 23

文件浏览器

:e . Open integrated file explorer
:Sex Split window and open integrated file explorer
:Sex! Same as :Sex but split window vertically
:browse e Graphical file explorer
:ls List buffers
:cd .. Move to parent directory
:args List files
:args *.php Open file list
:grep expression *.php Returns a list of .php files contening expression
gf Open file name under cursor

和 Unix 系统交互

:!pwd Execute the pwd unix command, then returns to Vi
!!pwd Execute the pwd unix command and insert output in file
:sh Temporary returns to Unix
$exit Retourns to Vi

对齐

:%!fmt Align all lines
!}fmt Align all lines at the current position
5!!fmt Align the next 5 lines

选项卡/窗口

:tabnew Creates a new tab
gt Show next tab
:tabfirst Show first tab
:tablast Show last tab
:tabm n(position) Rearrange tabs
:tabdo %s/foo/bar/g Execute a command in all tabs
:tab ball Puts all open files in tabs
:new abc.txt Edit abc.txt in new window

分屏显示

:e filename Edit filename in current window
:split filename Split the window and open filename
ctrl-w up arrow Puts cursor in top window
ctrl-w ctrl-w Puts cursor in next window
ctrl-w_ Maximize current window vertically
ctrl-w| Maximize current window horizontally
ctrl-w= Gives the same size to all windows
10 ctrl-w+ Add 10 lines to current window
:vsplit file Split window vertically
:sview file Same as :split in readonly mode
:hide Close current window
:­nly Close all windows, excepted current
:b 2 Open #2 in this window

自动完成

Ctrl+n Ctrl+p (in insert mode) Complete word
Ctrl+x Ctrl+l Complete line
:set dictionary=dict Define dict as a dictionnary
Ctrl+x Ctrl+k Complete with dictionnary

标记

m {a-z} Marks current position as {a-z}
‘ {a-z} Move to position {a-z}
Move to previous position

缩写

:ab mail mail@provider.org Define mail as abbreviation of mail@provider.org

文本缩进

:set autoindent Turn on auto-indent
:set smartindent Turn on intelligent auto-indent
:set shiftwidth=4 Defines 4 spaces as indent size
ctrl-t, ctrl-d Indent/un-indent in insert mode
>> Indent
<< Un-indent
=% Indent the code between parenthesis
1GVG= Indent the whole file

代码高亮

:syntax on Turn on syntax highlighting
:syntax off Turn off syntax highlighting
:set syntax=perl Force syntax highlighting

Nginx 怎么禁止IP和未绑定的域名访问

嘟嘟鱼阅读(1257)

刚才机房通知有未备案的域名解析到我们用户的服务器上,察看了下是nginx环境。

在服务器上执行

locate nginx.conf

命令可以找到安装路径

一般默认路径是

/usr/local/nginx/conf/nginx.conf

编辑此文件,在原有的server { 上面插入以下代码

server {  
      listen 80 default;  
      return 500;  
   } 

保存,执行

/usr/local/nginx/sbin/nginx

 重启nginx即可,如果重启报如下错误

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

则执行

killall -9  nginx

杀掉进程,重新重启nginx即可。

注释:

listen 80 default;  

表示监听80端口,default参数表示这个是默认虚拟主机。

return 500; 

就是返回500的提示。
比如别人通过ip或者未知域名访问你的网站的时候,你希望禁止显示任何有效内容,可以给他返回500,目前国内很多机房都要求网站主关闭空主机头,防止未备案的域名指向过来造成麻烦。

the NTP socket is in use, exiting

嘟嘟鱼阅读(927)

centos下使用如下命令手动同步服务器时间,出现“the NTP socket is in use, exiting”错误。造成该原因是系统ntpd服务器正在运行中,可以通过 ps aux | grep ntpd 查看,如果还是要手动同步时间,就必须先停止该服务,命令为:

service ntpd stop

然后手工执行自动对时,命令如下:
ntpdate ntp.fudan.edu.cn
或
ntpdate ntp.api.bz
或
ntpdate 210.72.145.44
即可。

linux:/lib/libc.so.6: version `glibc_2.7′ not found

嘟嘟鱼阅读(1643)

刚用户反映服务器rar版本低,下了个4.0的运行提示

/lib/libc.so.6: version `GLIBC_2.7′ not found

升级了centos的glibc库
yum -y update glibc
问题依旧。用命令查看glibc库的信息
rpm -qi glibc
显示系统的glibc库版本为2.5

在CentOS中用更新命令到2.5已经是最新版本了,只好手动下载 glibc 2.7 的源码包编译安装更新:

地址:http://ftp.gnu.org/pub/gnu/glibc/glibc-2.7.tar.gz
cd /usr/local/src
wget http://ftp.gnu.org/pub/gnu/glibc/glibc-2.7.tar.gz
tar zxvf glibc-2.7.tar.gz
glibc-2.7/configure #执行configure命令时不能进到glibc-2.7文件夹里面,否则无法执行
cd glibc-2.7
make && make install

linux系统如何解压大于4G的文件

嘟嘟鱼阅读(1393)

刚才同事分享的,这下方便多了。
http://sourceforge.net/projects/p7zip/
这里下载7z
make
make install
7za x test.zip

pure-ftpd日志记录设置

嘟嘟鱼阅读(2520)

刚帮一个用户查看ftp操作日志,发现没有记录,就帮他设置了下,他用的是pure-ftpd,保存下方法:

1)建立文件/var/log/pureftpd.log

2)修改/etc/syslog.conf

1>在这行的cron.none后面添加 ;ftp.none 使ftp的日志信息成私有
*.info;mail.none;authpriv.none;cron.none              /var/log/messages

*.info;mail.none;authpriv.none;cron.none;ftp.none              /var/log/messages

2>在/etc/syslog.conf文件最后加上

#pureftp日志
ftp.*        /var/log/pureftpd.log

注意: 不要去掉/var前面的号,否则日志会在/var/log/messages与/var/log/purefpd.log里各记录一份. 添加了号,就只会记录在/var/log/purefptd.log内

3)使/etc/syslog.conf生效
[root@www log]# killall -HUP syslogd

到现在设置完毕,重启下pure-ftpd,现在在客户端登陆ftp试下

socks5代理服务器的配置

嘟嘟鱼阅读(3884)

  1。先在北大天网搜索一下socks5的安装包,发现一大堆,最新版本是socks5-v1.0r11.tar.gz,于是下载到我的RH9的服务器上。
  2。解压缩软件包
  #tar xvfz socks5-v1.0r11.tar.gz
  3.开始编译
  #cd socks5-v1.0r11
  #./configure –with-threads
  #make
  #make install
  4.建立/etc/socks5.conf,其实在软件包里已经有现成的examples
  #cd examples
  #cp socks5.conf.singlehomed /etc/socks5.conf (我们挑选一个最简单的配置文件)
  默认配置就是
  # A Socks5 Config file for a normal, single homed server
  permit – – – – – –
  这个配置文件是允许任何人都可以使用这个socks5代理,并不需要验证 (更多…)

CentOS 5.4 发布

嘟嘟鱼阅读(957)

CentOS Linux 是一个依 GPL 规范,及利用 RedHat Enterprise Linux (RHEL) 的源代码 (source code) 来重新编译 (compile) 的 Linux 版本.
CentOS 提供和 RHEL 的 Binary 档案几乎百分之百兼容性,相同的版本 (Release) 和维护 (Maintainence) 更新时间.和 RedHat Enterprise Linux (RHEL) 不同的是,CentOS 依 GPL 的规范,移除了 RedHat 品牌及图片.

下载:CentOS 5.4

更新暂时未知