Linux 常用命令不间断更新

前提:Linux 命令 大小写敏感

1、mkdir  make directory(ies)  若指定目录不存在则创建目录

  -p, --parents     no error if existing, make parent directories as needed

2、ls  list  列出有关文件的信息(默认为当前目录)

  -a, --all                  do not ignore entries starting with .

  -d, --directory            list directory entries instead of contents,  and do not dereference symbolic links

  -F, --classify             append indicator (one of */=>@|) to entries

     --full-time            like -l --time-style=full-iso

  -h, --human-readable       with -l, print sizes in human readable format  (e.g., 1K 234M 2G)

  -i, --inode                print the index number of each file

  -l                         use a long listing format

  -p, --indicator-style=slash   append / indicator to directories

  -r, --reverse              reverse order while sorting

  -R, --recursive            list subdirectories recursively

  -t                         sort by modification time

3、cd     change directory  更改工作目录

4、pwd      print work directory  打印当前工作目录的名称

  -L        print the value of $PWD if it names the current working directory

  -P        print the physical directory, without any symbolic links

  By default, `pwd' behaves as if `-L' were specified.

5、touch   将每个文件的访问和修改时间更新为当前时间,如果文件不存在则创建空文件,除非提供-c 或 -h选项

  -a                     change only the access time

  -m                     change only the modification time

6、vi  文本编辑器

7、vim  vi 升级版,在vi基础上增强很多功能:多级撤销,多窗口和缓冲区,语法高亮,命令行编辑,自动缩进(shell,python)等

8、echo  将参数写入标准输出

  -n        do not append a newline

  -e        enable interpretation of the following backslash escapes

  `echo' interprets the following backslash-escaped characters:

            new line

            horizontal tab

9、cat  连接文件并在标准输出上打印

  -n, --number             number all output lines

10、xargs  从标准输入构建和执行命令行

  -n  max-args

11、cp  copy  拷贝文件和目录  -p 保留属性 权限,所有者,时间戳,而非使用默认属性

  -a, --archive                same as -dR --preserve=all

  -p                           same as --preserve=mode,ownership,timestamps

  --preserve[=ATTR_LIST]   preserve the specified attributes

                (default: mode,ownership,timestamps),

                 if possible additional attributes: context, links, xattr, all

  -R, -r, --recursive          copy directories recursively

12、rm  remove  删除文件或目录  强调:删除命令要慎用,非常危险,删除前一定要备份

  -f, --force           ignore nonexistent files, never prompt

  -i                    prompt before every removal

  -r, -R, --recursive   remove directories and their contents recursively

13、mv  move  移动(重命名)文件或目录

  -f, --force                  do not prompt before overwriting

  -i, --interactive            prompt before overwrite

14、find  查找

  -maxdepth levels

  -type [bcdpflsD]    f(file) ,d(directory) ,c(character), b(block), s(socket), l(link)

  -name PATTERN

  -atime N

  -ctime N

  -mtime N  (N can be +N or -N or N)  +n n天前,n 第n天,-n 前n天

  -exec COMMAND  用 {} 替代当前查找到的文件名,命令最后加 空格;

  eg:  find ./ -type f -exec mv {} oldboy ;

15、grep  linux三剑客老三

  -E, --extended-regexp     PATTERN is an extended regular expression (ERE)

  -i, --ignore-case         ignore case distinctions

  -v, --invert-match        select non-matching lines

  -n, --line-number         print line number with output lines

  -B, --before-context=NUM  print NUM lines of leading context  除了显示匹配的一行之外,并显示之前的num行

  -A, --after-context=NUM   print NUM lines of trailing context  除了显示匹配的一行之外,并显示之后的num行

  -C, --context=NUM         print NUM lines of output context  除了显示匹配的一行之外,并显示之前之后的num行

  eg:  grep "20" -B 10 a.txt    查看a.txt的20所在行和之前的10行

    grep "20" -A 10 a.txt    查看a.txt的20所在行和之后的10行

    grep "20" -C 10 a.txt    查看a.txt的20所在行和之后和之前的10行

16、head  头  读取文件的前n行,默认前10行

  -n, --lines=[-]K  print the first K lines instead of the first 10; with the leading `-', print all but the last K lines of each file

17、tail     尾  读取文件的后n行,默认后10行

  -n, --lines=K  output the last K lines, instead of the last 10; or use -n +K to output lines starting with the Kth

18、alias  设置别名

19、unalias  取消别名

  定义别名永久生效的方法:1、/etc/profile/  全局生效    2、~/.bashrc  当用户生效

20、seq  sequence  序列

  -s, --separator=STRING   use STRING to separate numbers (default: )

  eg:  seq 1  3 10

21、sed  linux三剑客之老二  stream editor 流编辑器,实现对文件的增删改查替换

  参数 -n 取消默认输出, -i 修改文件内容,-e允许多项编辑

  功能:p   打印,g 和 s联合使用时,表示对当前行全局匹配替换

  常说要查找替换用一个字符替换另一个字符

  sed -i s#aa#bb#g  a.txt

  #是分隔,可以用/@来替换

22、awk  linux三剑客之老大  过滤,输出内容,是一门语言。 NR行号

  -F fs

23、tree

  -a            All files are listed.

  -d            List directories only.

  -f            Print the full path prefix for each file.

  -i            Don't print indentation lines.

  -F            Appends '/', '=', '*', or '|' as per ls -F.

  -L level      Descend only level directories deep.

24、stat  显示文件或文件系统的状态

25、file  确定文件的类型

26、date  在给定的格式中显示当前时间,或设置系统日期

  -s, --set=STRING          set time described by STRING

27、uname  打印系统信息

  -a, --all  print all information, in the following order, except omit -p and -i if unknown:

  -s, --kernel-name  print the kernel name

  -n, --nodename  print the network node hostname

  -r, --kernel-release  print the kernel release

  -v, --kernel-version  print the kernel version

  -m, --machine  print the machine hardware name

  -p, --processor  print the processor type or "unknown"

  -i, --hardware-platform  print the hardware platform or "unknown"

  -o, --operating-system  print the operating system

原文地址:https://www.cnblogs.com/liuxiaowei/p/8203910.html