【Linux】命令整理(一)

来源:互联网 发布:rsync windows 编辑:程序博客网 时间:2024/06/06 16:42

时间

[root@master home]# date20170927日 星期三 18:54:34 CST[root@master home]# date +%Y/%m/%d2017/09/27[root@master home]# date +%H:%M18:55

日历

[root@master home]# cal      九月 2017     日 一 二 三 四 五 六                1  2 3  4  5  6  7  8  910 11 12 13 14 15 1617 18 19 20 21 22 2324 25 26 27 28 29 30[root@master home]# cal 2009                               2009                                       一月                   二月                   三月        日 一 二 三 四 五 六   日 一 二 三 四 五 六   日 一 二 三 四 五 六             1  2  3    1  2  3  4  5  6  7    1  2  3  4  5  6  7 4  5  6  7  8  9 10    8  9 10 11 12 13 14    8  9 10 11 12 13 1411 12 13 14 15 16 17   15 16 17 18 19 20 21   15 16 17 18 19 20 2118 19 20 21 22 23 24   22 23 24 25 26 27 28   22 23 24 25 26 27 2825 26 27 28 29 30 31                          29 30 31        四月                   五月                   六月        日 一 二 三 四 五 六   日 一 二 三 四 五 六   日 一 二 三 四 五 六          1  2  3  4                   1  2       1  2  3  4  5  6 5  6  7  8  9 10 11    3  4  5  6  7  8  9    7  8  9 10 11 12 1312 13 14 15 16 17 18   10 11 12 13 14 15 16   14 15 16 17 18 19 2019 20 21 22 23 24 25   17 18 19 20 21 22 23   21 22 23 24 25 26 2726 27 28 29 30         24 25 26 27 28 29 30   28 29 30                       31        七月                   八月                   九月        日 一 二 三 四 五 六   日 一 二 三 四 五 六   日 一 二 三 四 五 六          1  2  3  4                      1          1  2  3  4  5 5  6  7  8  9 10 11    2  3  4  5  6  7  8    6  7  8  9 10 11 1212 13 14 15 16 17 18    9 10 11 12 13 14 15   13 14 15 16 17 18 1919 20 21 22 23 24 25   16 17 18 19 20 21 22   20 21 22 23 24 25 2626 27 28 29 30 31      23 24 25 26 27 28 29   27 28 29 30                       30 31        十月                  十一月                 十二月       日 一 二 三 四 五 六   日 一 二 三 四 五 六   日 一 二 三 四 五 六             1  2  3    1  2  3  4  5  6  7          1  2  3  4  5 4  5  6  7  8  9 10    8  9 10 11 12 13 14    6  7  8  9 10 11 1211 12 13 14 15 16 17   15 16 17 18 19 20 21   13 14 15 16 17 18 1918 19 20 21 22 23 24   22 23 24 25 26 27 28   20 21 22 23 24 25 2625 26 27 28 29 30 31   29 30                  27 28 29 30 31[root@master home]# cal 10 2009      十月 2009     日 一 二 三 四 五 六             1  2  3 4  5  6  7  8  9 1011 12 13 14 15 16 1718 19 20 21 22 23 2425 26 27 28 29 30 31

帮助

[root@master home]# man dateDATE(1)                                                                                                                       User Commands                                                                                                                       DATE(1)NAME       date - print or set the system date and timeSYNOPSIS       date [OPTION]... [+FORMAT]       date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]DESCRIPTION       Display the current time in the given FORMAT, or set the system date.       Mandatory arguments to long options are mandatory for short options too.       -d, --date=STRING              display time described by STRING, not 'now'       -f, --file=DATEFILE              like --date once for each line of DATEFILE       -I[TIMESPEC], --iso-8601[=TIMESPEC]              output date/time in ISO 8601 format.  TIMESPEC='date' for date only (the default), 'hours', 'minutes', 'seconds', or 'ns' for date and time to the indicated precision.       -r, --reference=FILE              display the last modification time of FILE       -R, --rfc-2822              output date and time in RFC 2822 format.  Example: Mon, 07 Aug 2006 12:34:56 -0600       --rfc-3339=TIMESPEC              output date and time in RFC 3339 format.  TIMESPEC='date', 'seconds', or 'ns' for date and time to the indicated precision.  Date and time components are separated by a single space: 2006-08-07 12:34:56-06:00       -s, --set=STRING              set time described by STRING       -u, --utc, --universal              print or set Coordinated Universal Time (UTC)       --help display this help and exit       --version              output version information and exit       FORMAT controls the output.  Interpreted sequences are:       %%     a literal %       %a     locale's abbreviated weekday name (e.g., Sun)       %A     locale's full weekday name (e.g., Sunday)       %b     locale's abbreviated month name (e.g., Jan)       %B     locale's full month name (e.g., January)       %c     locale's date and time (e.g., Thu Mar  3 23:05:25 2005)       %C     century; like %Y, except omit last two digits (e.g., 20)       %d     day of month (e.g., 01)       %D     date; same as %m/%d/%y       %e     day of month, space padded; same as %_d       %F     full date; same as %Y-%m-%d       %g     last two digits of year of ISO week number (see %G)       %G     year of ISO week number (see %V); normally useful only with %V       %h     same as %b       %H     hour (00..23) Manual page date(1) line 1 (press h for help or q to quit) [root@master home]# info ps

改变文件属性与权限

  • 改变用户组
    chgrp [-R] groupName dirname/filename
  • 改变文件所有者
    chown [-R] userName[:groupName] dirname/filename
  • 改变文件权限
    使用数字:
    chomd [-R] xyz 目录/文件

    r=4,w=2,x=1 xyz分别的最大值为7

    使用符号:

    chmod u/g/o/a +/-/= r/w/x 文件或目录


    u代表owner,g代表group,o代表others,a代表全部

目录与路径

切换目录

  • cd [相对路径或绝对路径]
  • cd ~ #去到当前登录用户的主目录,等价于直接cd
  • cd - #标识回到前一个工作目录,相当于win的返回
  • cd .. #相当于win的向上

显示当前目录

pwd [-P]
参数:
-P 只显示真实路径,不显示链接的路径

新建一个新的目录

mkdir [-mp] 目录名称
参数:
-m 配置文件的权限
-p 递归的创建文件目录

删除一个空的目录

rmdir [-p] 目录名称
参数:
-p 递归的删除空目录

文件与目录管理

ls [-aAdfFhilnrRSt] 目录名称
ls [- -color={never,auto,always}] 目录名称
ls [- -full-time] 目录名称

[root@master ~]# ls -al总用量 40dr-xr-x---.  3 root root 4096 9月  27 19:20 .dr-xr-xr-x. 17 root root 4096 9月  25 15:48 ..-rw-------.  1 root root 1043 922 00:36 anaconda-ks.cfg-rw-------.  1 root root 3848 927 19:37 .bash_history-rw-r--r--.  1 root root   18 1229 2013 .bash_logout-rw-r--r--.  1 root root  176 1229 2013 .bash_profile-rw-r--r--.  1 root root  176 1229 2013 .bashrc-rw-r--r--.  1 root root  100 1229 2013 .cshrc-rw-------.  1 root root   35 927 19:20 .lesshstdrwxr-x---.  2 root root   39 9月  21 17:17 .oracle_jre_usage-rw-r--r--.  1 root root  129 1229 2013 .tcshrc↑权限    ↑连接↑所有者↑用户组↑大小↑最后修改时间↑文件名    (.文件名代表是隐藏文件)