Chinaunix首页 | 论坛 | 博客
  • 博客访问: 517685
  • 博文数量: 137
  • 博客积分: 3170
  • 博客等级: 中校
  • 技术积分: 1455
  • 用 户 组: 普通用户
  • 注册时间: 2009-03-17 11:47
文章分类

全部博文(137)

文章存档

2015年(2)

2013年(1)

2012年(6)

2011年(5)

2010年(62)

2009年(61)

我的朋友

分类: LINUX

2009-10-19 16:16:31


1.ssh登录
登录方式可以为: ssh -l jacky 192.168.0.100
ssh root@192.168.0.200 在rhel5下是可以的,但是在ubuntu下是不行的,
默认不允许root登录,普通用户是可以的,
ssh jacky@192.168.0.200
2.有时候,出现错误:
ssh: connect to host 192.168.0.200 port 22: Connection refused lost connection
A--no->B,A不能向B拷贝,这时候可以从B向A拷贝,或B自己向自己拷贝,以打通经脉。呵呵,具体原因不知。

ssh错误,登录的另一台主机比如重装系统,我们再用ssh登录,可能会有如下问题:
jacky@jacky-desktop:~$ ssh root@192.168.0.162
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
48:68:8c:ce:42:26:1a:ce:b7:a2:e6:42:df:2a:3a:c9.
Please contact your system administrator.
Add correct host key in /home/jacky/.ssh/known_hosts to get rid of this message.
Offending key in /home/jacky/.ssh/known_hosts:3
RSA host key for 192.168.0.162 has changed and you have requested strict checking.
Host key verification failed.
!!!!删除
/home/jacky/.ssh/文件夹或者/.ssh/known_hosts即可!
2.1 ubuntu9.04保存ssh登录密码,登录rhel5
2.1.1
  ssh-keygen
注意执行命令时,在你自己的localhost提示符下。
jacky@jacky-desktop:~$
ssh-keygen
jsmith@local-host$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/jsmith/.ssh/id_rsa):[Enter key]
注:如果你要保存2个登录server的密码:192.168.0.200,192.168.0.220,这时候你应当在保存第2个密码时,
/home/jsmith/.ssh/id_rsa为另一个文件,比如/home/jsmith/.ssh/id_rsa220
Enter passphrase (empty for no passphrase): [Press enter key]
Enter same passphrase again: [Pess enter key]
Your identification has been saved in /home/jsmith/.ssh/id_rsa.
Your public key has been saved in /home/jsmith/.ssh/id_rsa.pub.
The key fingerprint is:
33:b3:fe:af:95:95:18:11:31:d5:de:96:2f:f2:35:f9 jsmith@local-host
2.1.2执行命令:
ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.0.200
对于
192.168.0.220则拷贝220相应的。
2.1.3直接登录即可 ssh root@192.168.0.200
注意:
以上三步流程,一个地址操作完了再操作第二个,一起执行的没有实验过。
如过中途操作失败,出现错误:
Agent admitted failure to sign using the key
则可以考虑删除~/.ssh 和 /root/.ssh,再不行就重新起动,网上说了很多方法不管用
参考文献:

2.2 rhel5解决ssh登录服务器过慢问题:
修改    /etc/ssh/sshd_config文件,找到UseDNS,修改为no
UseDNS no
重启SSH服务
# /etc/init.d/sshd restart
我试了试用处不是很大。呵呵。
2.3 ubuntu开启ssh服务
安装OpenSSH Ubuntu缺省没有安装SSH Server,使用以下命令安装:
sudo apt-get install openssh-server openssh-client
不过Ubuntu缺省已经安装了ssh client。

完成后重起:
sudo /etc/init.d/ssh restart



3
scp主机之间拷贝文件用法
3.1 拷贝本地
/home/jacky/tstProject/unpv13e/目录,到 192.168.0.200:/home/jacky

scp -r /home/jacky/tstProject/unpv13e/ jacky@192.168.0.200:/home/jacky


如果要保持目录中各文件原有的时间戳,可以加-p参数。
3.2 远程主机到本地,示例
scp -r root@192.168.0.22:/home/jacky/linux_exe  ~/uSrv/exe0_22/
以上所有最末尾文件夹加不加/效果可能会不同,注意查看复制后的结果。
4 sftp主机之间拷贝文件
4.1  从远程主机的  /var/www/fuyatao/目录下将 index.php 下载到本地  /home/fuyatao/目录下。

sftp> get /var/www/fuyatao/index.php /home/fuyatao/

4.2  把本地 /home/fuyatao/downloads/目录下的 linuxgl.pdf文件上传至远程主机/var/www/fuyatao/ 目录下

put /home/fuyatao/downloads/Linuxgl.pdf /var/www/fuyatao/

4.3  查看本地的shell命令为:lcd lpwd ..
     查看远程的主机命令为:cd pwd ..
4.4 mget命令 to download all the files in the remote working directory

sftp> mget ./*

4.5 sftp的不足

If you try to copy a folder using the get or mget commands, sftp will complain that it "Cannot download non-regular file: filename". This is because the basic sftp client doesn't allow for a recursive copy. However, the program scp will allow you to do this. The scp command will not allow you to see what's on the sftp server, so the files need to be located using the sftp client.

Note: the scp command is a Unix command, and needs to be run from the Unix prompt. NOT within the SFTP client.

Usage: scp user@host:remote-path local-path


讲sftp的好文章

5  telnet 命令
telnet 192.168.0.71 port
可以测试远程主机是否开启服
6  ln命令
建立硬链接或软连接
6.1  简单建立一个文件的连接
ln [OPTION]... [-T] TARGET LINK_NAME   (1st form)
6.2  在当前目录建立
TARGET的连接,名字相同
ln [OPTION]... TARGET                  (2nd form)
6.3  在DIRECTORY目录中创建所有TARGET的连接
ln [OPTION]... TARGET... DIRECTORY     (3rd form)
ln [OPTION]... -t DIRECTORY TARGET...  (4th form)
6.4  建立符号连接时一般都要输入目标文件的绝对路径
也可以使用通配符:
ln -s /usr/local/lib/libwx* /usr/lib
删除指向一个目录的软连接
rm -rf link_dir 而不是 rm -rf link_dir/
否则出错删除不掉。
7.addgroup
rhel5下面没有此命令,而是groupadd命令
8.top命令
top默认是3秒刷新一次,按h键进入帮助。

8.1命令行选项:
-b 批处理模式
-c  命令行/程序名字的切换,也就是COMMAND列的显示形式,也可以top后,按c来切换。
-d  显示延迟的时间
8.2
用o可以交互设置相应列的顺序,调整左右位置,对应的列的大写字母向左调整,小写字母向右调整。
用f可以增减相应的列的显示。

'f' (Fields select) or 'o' (Order fields)
8.3 按F键可以进入设置按照一定列降序显示的交互,按R键可以将显示顺序逆转。
8.4 可以按k来删除某进程。
8.5  top命令 写入文件
    top  -b > file.log

9. || && 组合命令
使用 && 控制操作符来组合两个命令,以便仅当 第一个命令返回零退出状态时才运行第二个命令。换句话说,如果第一个命令运行成功,则第二个命令将运行。如果第一个命令失败,则第二个命令根本就不运行。
||制操作符分隔两个命令,并且仅当第一个命令返回非零退出状态时才运行第二个命令。换句话说,如果第一个命令成功,则第二个命令不会运行。如果第一个命令失败,则第二个命令才会 运行。在测试某个给定目录是否存在时,通常使用此操作符,如果该目录不存在,则创建它。
cd prj || mkdir -p prj/a/b && rm -rf prj/a/b
10.free
free -m

     total used free shared buffers cached
Mem: 2025  1709   316   0     85      915
-/+ buffers/cache: 708 1317
Swap: 4094 212 3882

(-buffers/cache) used内存数:708M (指的第一部分Mem行中的used - buffers - cached)
(+buffers/cache) free内存数: 1317M (指的第一部分Mem行中的free + buffers + cached)
可见-buffers/cache反映的是被程序实实在在吃掉的内存,而+buffers/cache反映的是可以挪用的内存总数。
操作来讲是Mem的.buffers/cached 都是属于被使用,所以它认为free只有316.
应用程序来讲是(-/+ buffers/cach).buffers/cached 是等同可用的,因为buffer/cached是为了提高程序执行的性能,当程序使用内存时,buffer/cached会很快地被使用。
参考:http://blog.chinaitlab.com/html/10/56410-160995.html
11.vmstat
参考:
http://blog.chinaunix.net/u2/60332/showart_1316308.html
11.1 查看cpu硬件状况双核,ht超线程。
dmidecode   dmesg   和cat /proc/cpuinfo 综合来判断吧
11.2

阅读(4696) | 评论(0) | 转发(0) |
0

上一篇:虾皮小白菜

下一篇:经典链接

给主人留下些什么吧!~~