linux 一些常命令——注意项

tar 命令:

 Main operation mode:
  -A, --catenate, --concatenate   append tar files to an archive
  -c, --create               create a new archive
  -d, --diff, --compare      find differences between archive and file system
      --delete               delete from the archive (not on mag tapes!)
  -r, --append               append files to the end of an archive
  -t, --list                 list the contents of an archive
      --test-label           test the archive volume label and exit
  -u, --update               only append files newer than copy in archive
  -x, --extract, --get       extract files from an archive

※值得注意几个地方

引用
1)-f后面必须紧跟备份文件,xxx.tar或者xxx.tar.gz
2)使用--delete、-u、-r、-A的时候,后面跟的备份文件都必须为未压缩的,若备份文件已经压缩,需要使用gunzip先解压,操作完后再gzip;
也就是说,不能对tar.gz、tar.bz2等文件直接操作的;
3)备份打包时,默认为相对路径;而排除匹配式默认也是全路径匹配的
所以,在打包时,会提示:“tar: Removing leading `/' from member names”
除非你使用-P参数或特定的参数指定
4)在使用--exclude参数时,需要注意几点:
a)其后可以用“=文件”或“空格 文件”两种方式;
b)其后跟的模式需与前面指定要打包的路径一致,例如:
tar -czvf /tmp/test.tar.gz ./ --exclude ./mysql
tar -czvf /tmp/test.tar.gz * --exclude mysql
tar -czvf /tmp/test.tar.gz /var/lib --exclude /var/lib/mysql
这与find的使用是类同的。
c)若排除的是目录,目录名后面不应该加“/”号,另外,在部分版本的tar中(不同平台或版本较低),需要在目录后面加*号,如“--exclude ./mysql/*”
d)如果要同时排除多个文件或目录,需加入多个--exclude参数,例如:

tar -czvf /tmp/test.tar.gz ./ --exclude ./mysql --exclude ./backup --exclude ./database 

netstat 命令



ls 命令

Mandatory arguments to long options are mandatory for short options too.
  -a, --all                  do not ignore entries starting with .
  -A, --almost-all           do not list implied . and ..
      --author               with -l, print the author of each file
  -b, --escape               print octal escapes for nongraphic characters
      --block-size=SIZE      use SIZE-byte blocks.  See SIZE format below

  -i, --inode                print the index number of each file
  -I, --ignore=PATTERN       do not list implied entries matching shell PATTERN

  -r, --reverse              reverse order while sorting
  -R, --recursive            list subdirectories recursively
  -s, --size                 print the allocated size of each file, in blocks
  -S                         sort by file size
      --sort=WORD            sort by WORD instead of name: none -U,
                             extension -X, size -S, time -t, version -v
      --time=WORD            with -l, show time as WORD instead of modification
                             time: atime -u, access -u, use -u, ctime -c,
                             or status -c; use specified time as sort key
                             if --sort=time
      --time-style=STYLE     with -l, show times using style STYLE:
                             full-iso, long-iso, iso, locale, +FORMAT.
                             FORMAT is interpreted like `date'; if FORMAT is
                             FORMAT1<newline>FORMAT2, FORMAT1 applies to
                             non-recent files and FORMAT2 to recent files;
                             if STYLE is prefixed with `posix-', STYLE
                             takes effect only outside the POSIX locale
  -t                         sort by modification time
  -T, --tabsize=COLS         assume tab stops at each COLS instead of 8
  -u                         with -lt: sort by, and show, access time
                               with -l: show access time and sort by name
                               otherwise: sort by access time
  -U                         do not sort; list entries in directory order
  -v                         natural sort of (version) numbers within text
  -w, --width=COLS           assume screen width instead of current value
  -x                         list entries by lines instead of by columns
  -X                         sort alphabetically by entry extension
  -1                         list one file per line


gzip 命令






评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值