Chinaunix首页 | 论坛 | 博客
  • 博客访问: 431146
  • 博文数量: 85
  • 博客积分: 3580
  • 博客等级: 中校
  • 技术积分: 970
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-09 14:09
文章分类

全部博文(85)

文章存档

2011年(7)

2010年(78)

我的朋友

分类: LINUX

2010-05-17 14:49:06

lsb_release -a
/proc/version
uname -a
/etc/issue
查看版本

grep -F MASQUERADE -R /path
find /your/path -type f -print | xargs grep MASQUERADE
查找文件

ls|while read line ; do mv $line $line.txt; done

dmidecode |more
查看硬件配置

echo 222222|passwd –stdin root
linux下非交互情况修改密码

cp ./*/*attch* /testout_attch/
使用通配符对文件操作

paste -d "\n" *.txt > z
合并所有txt文档到z文件(采用\n分割)

pkill -kill -t pts/3
踢掉用户

xargs
对输入执行命令操作
find /tmp -name core -type f -print | xargs /bin/rm -f
Find  files  named  core  in or below the directory /tmp and delete them.  Note that this will work incorrectly if there are any filenames containing newlines or spaces.
find /tmp -name core -type f -print0 | xargs -0 /bin/rm -f
Find files named core in or below the directory /tmp and delete  them,  processing  filenames  in  such a way that file or directory names containing spaces or newlines are correctly handled.
find -type f -mtime 0|xargs -i cp {} /check/
ls|xargs -i rm -rf {} 
删除文件
ls|xargs -i mv {} {}.old
文件改名

cut
对管道进行切割
cut -d '分隔符' -f fields
#echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/lib/ccache:/usr/local/sbin:/usr/local/bin:/sbin:/bin
#echo $PATH |cut -d ':' -f 2,4
/usr/kerberos/bin:/usr/local/sbin
以:分割,去第二个第四个
cut -c 字符范围
cut -c 12- 取第12字符到结尾
cut -c 12-25 取12到25字符
cut -c 0-12 取前12字符
 
sort
uniq
对管道进行排序,去重
cat xx.file | sort | uniq > xxx
对xx.file文件排序后去重保存到xxx

head/tail
列举文件头尾信息
tail -100 messages|head 10
messages文件中后100行中前10行
head -n100 messages|tail -10
messages文件中前100行中后10行
tail -f
刷新显示

diff
文件(夹)比较
diff -ruN /tmp/file1.txt /tmp/file2.txt > /tmp/file.diff
生成了一个 file2 相对 file1 的差异文件(补丁)
打补丁:cd /tmp; patch -p1 < file.diff
diff -ruN /tmp/path1 /tmp/path2 > /tmp/path.diff
目录比较
diff -rq -x .svn dirA/ dirB/
diff中递归比较带子目录的源码使用-r选项,只打印文件名使用-q选项。要排除一些目录或者文件,不参与比较,可以使用-x选项。比如通常我们不比较版本代码中的.svn中的文件。

rpm
rpm -qa | grep
查看是否安装
rpm -ivh (–nodeps) x.rpm
安装x软件包
rpm -e(--erase) --test -vv --force
卸载软件包
rpm -Uvh x.rpm
rpm -Fvh x.rpm
升级安装 Uvh 未安装则安装,安装过则升级;Fvh 未安装则不安装,安装过则升级

–nodeps 取消关联性 --test测试 -vv显示过程 --force强制

history
(export HISTTIMEFORMAT='%F %T '增加环境变量显示时间)
history -c

du
检测文件空间
du --max-depth=N -h(--human-readable)
du -a(all)b(bytes) = ll

find
查找
find -anewer
寻找比xx新的文件(touch -d xx)
find -exec command "{}"
配合find运行command (find .-name '*.zip' -exec unzip "{}"\;)

grep -rn "string"


查找特定字符串的文件

tar命令
-c:压缩
      -x:解压
      -t:查看内容
      -r:向压缩归档文件末尾追加文件
      -u:更新原压缩包中的文件
-z:有gzip属性的
      -j:有bz2属性的
      -Z:有compress属性的
      -v:显示所有过程
      -O:将文件解开到标准输出
tar -zxvf
压缩
tar -zcvf xx.tar.gz xx/
解压
tar -zcvPf /webback/$stmp/web.tar.gz /var/www/html/web/
备份
tar -zcvf test.tar.gz --exclude=c --exclude=d./path
or
tar -zcvf test.tar.gz --exclude=path/c --exclude=pach/d ./path
打包path目录中出去文件c和d
tar cvzpf - somedir | split -d -b 500m
tar分卷压缩:-d不是split的选项,是shell的选项,表示将tar命令的输出作为split的输入
cat x* > mytarfile.tar.gz
tar多卷合并

ls --full-time
显示文件被修改的详细时间,包括年月日时分秒,还有时区

mysqldump
mysqldump --opt phsfront -u root -psig1000|gzip>/webback/$stmp/phsfront.gz
mysqldump --opt phsurl -u root -psig1000|gzip>/webback/$stmp/phsurl.gz
mysql备份

yast2
SUSE

ftp
常用命令     
>   open   addr >   user  >   pass  >   ls   >   dir   >   pwd   >   lcd   >   mput   >   mget   >   bye.
restart 12384
上传续传
put file
下传续传
$reget remote-file [local-file]
如果local-file存在,则从上次传输中断处续传
#!/bin/bash
HOST='xx.xx.xx.xx'
USER='user'
PASSWD='passwd'
FILE='yourfile'
ftp -n $HOST << END_SCRIPT
quote USER $USER
quote PASS $PASSWD
bin
prompt
get(/put) $FILE
quit
END_SCRIPT
exit 0
在shell中使用ftp,避免交互
 
===============================================
pgrep
netstat -na
netstat -tunlp
tcpdump -i eth1 host 1.1.1.1
openssl enc -des -e -a -in install.log -out install.log.des
while [ 1 ]; do ifconfig eth0|grep -o 'TX bytes:[0-9]\{9\}'; sleep 10;done
阅读(1624) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~