偶经常用到的LINUX命令整理(持续更新)

1.开启samba共享:

1 $ sudo /etc/init.d/samba start


2.打包,压缩,解压缩:

  zip:

1 $ zip -r file.zip file1 file2
2
3 $ unzip file.zip

    tar:

1 $ tar -zxvf /home/user/lee/aa.tar.gz -C /home/user/ma <==解压到指定目录
2 $ tar -cvf /tmp/etc.tar /etc <==仅打包,不压缩
3 $ tar -zcvf /tmp/etc.tar.gz /etc <==打包后,以 gzip 压缩
4 $ tar -jcvf /tmp/etc.tar.bz2 /etc <==打包后,以 bzip2 压缩

  7zip:

1 压缩命令:
 $7za a -t7z -r test.7z /tmp/* //--上面命令将 /tmp 文件夹压缩为 test.7z 文件
2 解压命令:
 $7z x test.7z -o /home/maadiah    //--  这个命令将test.7z 的内容解压到 /home/maadiah目录下
参数含义:
a 代表添加文件/文件夹到压缩包

-t 是指定压缩类型,这里定为7z

-r 表示递归所有的子文件夹




3.patch 与 diff 用法

  patch:

  

 1 $ diff -uN test0 test1 > test1.patch <== 如果是文件夹 用-r来递归
2 $ patch -p0 < test1.patch <== 给test0打上patch
3 $ patch -RE -p0 < test1.patch <== 去除补丁,恢复
4
  总结:
5 单个文件
6 $ diff –uN from-file to-file >to-file.patch
7 $ patch –p0 < to-file.patch
8 $ patch –RE –p0 < to-file.patch
9
10 多个文件
11 $ diff -uNr from-docu to-docu >to-docu.patch
12 $ patch -p0 < to-docu.patch <==在根目录进行
13 $ patch -R -p1 <to-docu.patch

 

  
4.Vim

选中:    冒号提示下,按v,移动光标选中区域
剪切:    d
复制:    y
粘贴:    p

将 Dos 格式转化成 Unix
:%s/^V^M//g
Ctrl + v 表示 ^V ; Ctrl + M 表示 ^M

  


5.系统管理

1 $watch -n 1 free -m 动态内存监视,一秒刷新


6.文件操作

1 $chmod -R a+rw ~/mydir   <==递归更改文件权限
2 $du -sm /home/maadiah <==查看/home/maadiah 文件夹大小,以 M 为单位

7.查找

1 grep   who   /use/local   -r   <==who是pattern,如果含有特殊字符则要加上引号。
2 find . -type f -regex ".*\.c " -print -exec grep "string " {} \;




posted @ 2011-10-14 12:56  maadiah  阅读(252)  评论(0编辑  收藏  举报