to myself 的分类学习日志

做自己想做的事
posts - 232, comments - 6, trackbacks - 0, articles - 0

linux命令小记

Posted on 2010-05-06 16:46 kongkongzi 阅读(352) 评论(0)  编辑 收藏 引用 所属分类: linux
lsof -i:<port>
ps 
-Lf <pid> 可以查看进程的线程数

查看自己的外网ip(公网ip)
方法一: wget http://whatismyip.org
         cat index.html 
方法二: curl http://whatismyip.org

netstat -anp|grep 7898 |sort -rnk2 |head -n 5 
Netstat –ano|findstr “
<端口号>”,
tasklist|findstr “
<PID>

同时修改日期时间,注意要加双引号,日期与时间之间有一空格,输入:date -s "2010-07-20 16:30:00"
修改完后,记得输入:clock -w 
把系统时间写入CMOS 

减少shell窗口开启的个数:
& 将指令丢到后台中去执行
[ctrl]+z 將前台任务丟到后台中暂停
jobs 查看后台的工作状态
fg %jobnumber 将后台的任务拿到前台来处理
bg %jobnumber 将任务放到后台中去处理
kill 管理后台的任务.

硬链接(Hard Link)
硬链接说白了是一个指针,指向文件索引节点,系统并不为它重新分配inode。
可以用:ln命令来建立硬链接。
引用
ln [options] existingfile newfile
ln [options] existingfile
-list directory

用法:
第一种为”existingfile”创建硬链接,文件名为”newfile”。
第二种在”directory”目录中,为” existingfile
-list”中包含的所有文件创建一个同名的硬链接。
常用可选[options]:
-f 无论”newfile”存在与否,都创建链接。-n 如果”newfile”已存在,就不创建链接。

软链接(Soft 
Link)
软链接又叫符号链接,这个文件包含了另一个文件的路径名。可以是任意文件或目录,可以链接不同文件系统的文件。和win下的快捷方式差不多。
可以用:ln 
-s 命令来建立软链接。
引用
ln 
-s existingfile newfile
ln 
-s existingfile-list directory

ls -> out.file 2>&1 &
解释
:
ls 
-> out.file //将ls的输出重定向到文件out.file
2>&1 //在shell中,文件描述符通常是:STDIN,STDOUT,STDERR,:0,1,2,由此可以看出,它将ls -> out.file在输出过程中产生的错误信息也放在了STDOUT,:1中.
最后的
& ,不用说,是放在后台运行.

nohup ssh root@192.168.0.175 'cmd' > /dev/null 2>&1 &