常用命令

常用命令符

学习linux的过程中掌握各种常用的命令符对我们也是非常重要的。完全掌握命令符可以使我们的学习更加的轻松。以下为各种常用的命令符。

操作命令

操作命令符是linux最基础的一些操作命令,包括输出文字,查看内容等信息。

  1. echo命令
    echo是在终端输出字符变量提取后的值。echo是在终端输出字符变量提取后的值。
  用法:
  [root@localhost ~]# echo hello
  hello
  1. date命令
    date命令是用于显示时间或者设置日期格式。
    在使用date时需要在date后面输入相应的格式达到需要日期的格式求。可以使用—help调出date的所有格式,进行选择使用。
  用法:
  [root@localhost ~]# date --help
  Usage: date [OPTION]... [+FORMAT]
   or:  date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
  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)
  %I   hour (01..12)
  %j   day of year (001..366)
  %k   hour, space padded ( 0..23); same as %_H
  %l   hour, space padded ( 1..12); same as %_I
  %m   month (01..12)
  %M   minute (00..59)
  %n   a newline
  %N   nanoseconds (000000000..999999999)
  %p   locale's equivalent of either AM or PM; blank if not known
  %P   like %p, but lower case
  %r   locale's 12-hour clock time (e.g., 11:11:04 PM)
  %R   24-hour hour and minute; same as %H:%M
  %s   seconds since 1970-01-01 00:00:00 UTC
  %S   second (00..60)
  %t   a tab
  %T   time; same as %H:%M:%S
  %u   day of week (1..7); 1 is Monday
  %U   week number of year, with Sunday as first day of week (00..53)
  %V   ISO week number, with Monday as first day of week (01..53)
  %w   day of week (0..6); 0 is Sunday
  %W   week number of year, with Monday as first day of week (00..53)
  %x   locale's date representation (e.g., 12/31/99)
  %X   locale's time representation (e.g., 23:13:48)
  %y   last two digits of year (00..99)
  %Y   year
  %z   +hhmm numeric time zone (e.g., -0400)
  %:z  +hh:mm numeric time zone (e.g., -04:00)
  %::z  +hh:mm:ss numeric time zone (e.g., -04:00:00)
  %:::z  numeric time zone with : to necessary precision (e.g., -04, +05:30)
  %Z   alphabetic time zone abbreviation (e.g., EDT)
  用法:
  [root@localhost ~]# echo hello
  hello
  [root@localhost ~]# date +%F
  2018-12-26
  [root@localhost ~]# date +%M
  17
  [root@localhost ~]# date +%Y%m%d
  20181226
  1. history命令
    history命令用于显示所有执行过的命令。
    • history -c —清空历史命令的记录,但并为清除文件中的历史命令。
    • history -r —从文件读取历史命令道历史列表中。
    • history -w —从历史列表中命令追加到历史文件中。
    • history !# — 再次执行历史列表的第#条命令。
    • history !! — 再次和执行历史列表中的最后一条命令。
  用法:
  [root@localhost ~]# history
    1  grep ‘root' /etc/passwd
    2  grep 'root' /etc/passwd
    3  grep 'bash$' /etc/passwd
    4  gedit
    5  vi
    6  nano
    7  touch file1
    8  ln file1 file2
    9  ln -s file1 file3
   10  ls -l
   11  ls -li
   12  echo "hello" >>file1
   13  cat file1
   14  cat file2
   15  cat file3
   16  rm -f file1
   17  cat file2
   18  cat file3
   19  ll -l
   20  groupadd hr
   21  useradd hr01 -G hr
   22  useradd hr02 -G hr
   23  mkdir /home/hr
   24  chown .hr /home/hr
   25  chmod 770 /home/hr
   26  ll -l
   27  ll /home/hr
   28  ll -d /home/hr
   29  tail -5 /etc/passwd
   30  date
   31  date --help
   32  echo hello
   33  date +%F
   34  date +%M
   35  date +%Y%m%d
   36  type ls
   37  type help
   38  type cd
   39  ls
   40  touch file1
   41  ls
   42  ls -l
   43  man
   44  man date
   45  cat /etc/sysconfig
   46  cat file1
   47  vi file1
   48  cat file1
   49  history
  [root@localhost ~]# history -c
  [root@localhost ~]# history
    1  history
  [root@localhost ~]# echo HISTORY
    HISTORY
  [root@localhost ~]# echo $HISTORY
  [root@localhost ~]# history
    1  history
    2  echo HISTORY
    3  echo $HISTORY
    4  history
    [root@localhost ~]# history -r
    [root@localhost ~]# history
    1  history
    2  echo HISTORY
    3  echo $HISTORY
    4  history
    5  history -r
    6  grep ‘root' /etc/passwd
    7  grep 'root' /etc/passwd
    8  grep 'bash$' /etc/passwd
    9  gedit
   10  vi
   11  nano
   12  touch file1
   13  ln file1 file2
   14  ln -s file1 file3
   15  ls -l
   16  ls -li
   17  echo "hello" >>file1
   18  cat file1
   19  cat file2
   20  cat file3
   21  rm -f file1
   22  cat file2
   23  cat file3
   24  ll -l
   25  groupadd hr
   26  useradd hr01 -G hr
   27  useradd hr02 -G hr
   28  mkdir /home/hr
   29  chown .hr /home/hr
   30  chmod 770 /home/hr
   31  ll -l
   32  ll /home/hr
   33  ll -d /home/hr
   34  tail -5 /etc/passwd
   35  history
 [root@localhost ~]# history !6
 history grep ‘root' /etc/passwd

  1. type命令
    type命令用于判断命令为内部命还是外部命令
  用法:
  [root@localhost ~]# type ls
  ls is aliased to `ls --color=auto'
  [root@localhost ~]# type help
  help is a shell builtin
  [root@localhost ~]# type cd
  cd is a shell builtin
  1. cd命令
    cd命令用于切换各个工作路径。
  2. pwd命令
    pwd命令用于显示用户当前所处的路经。
  3. ls命令
    ls命令用于显示目录文件信息,但执行ls时仅能显示非隐藏文件的文件名。
    • ls -a —显示所有文件,包括隐藏文件。
    • ls -A —显示所有文件,但不包括当前目录和上级目录。
    • ls -l —查看文件详细的信息。
    • ls -lt —显示列表并以文件最后的修改时间进行排序。
    • ls -lg ----列表显示,但不显示文件所属者。
    • ls -li —列出每个文件的inode。
   用法:
   [root@localhost ~]# ls
   anaconda-ks.cfg  file2  file3
   [root@localhost ~]# touch file1
   [root@localhost ~]# ls
   anaconda-ks.cfg  file1  file2  file3
   [root@localhost ~]# ls -a
   .   anaconda-ks.cfg  .bash_logout   .bashrc  file1  file3     .tcshrc
   ..  .bash_history    .bash_profile  .cshrc   file2  .lesshst
   [root@localhost ~]# ls -l
   total 8
   -rw-------. 1 root root 1548 Dec 24 15:02 anaconda-ks.cfg
   -rw-r--r--. 1 root root    0 Dec 26 19:35 file1
   -rw-r--r--. 1 root root    6 Dec 25 20:40 file2
   lrwxrwxrwx. 1 root root    5 Dec 25 20:38 file3 -> file1
   [root@localhost ~]# ls -lt
   total 12
   -rw-r--r--. 1 root root    6 Dec 26 19:57   file1
   -rw-r--r--. 1 root root    6 Dec 25 20:40 file2
   lrwxrwxrwx. 1 root root    5 Dec 25 20:38 file3 -> file1
   -rw-------. 1 root root 1548 Dec 24 15:02 anaconda-ks.cfg
   [root@localhost ~]# ls -g
   total 12
   -rw-------. 1 root 1548 Dec 24 15:02 anaconda-ks.cfg
   -rw-r--r--. 1 root    6 Dec 26 19:57 file1
   -rw-r--r--. 1 root    6 Dec 25 20:40 file2
   lrwxrwxrwx. 1 root    5 Dec 25 20:38 file3 -> file1
   [root@localhost ~]# ls -li
   total 12
   16797775 -rw-------. 1 root root 1548 Dec 24 15:02 anaconda-ks.cfg
   16797821 -rw-r--r--. 1 root root    6 Dec 26 19:57 file1
   16797792 -rw-r--r--. 1 root root    6 Dec 25 20:40 file2
   16797813 lrwxrwxrwx. 1 root root    5 Dec 25 20:38 file3 -> file1
   [root@localhost ~]# ls -s
   total 12
   4 anaconda-ks.cfg  4 file1  4 file2  0 file3
  1. cat命令
    cat命令用于查看文件的内容。
   用法:
   [root@localhost ~]# cat /etc/sysconfig
   cat: /etc/sysconfig: Is a directory
   [root@localhost ~]# cat file1
   [root@localhost ~]# vi file1
   [root@localhost ~]# cat file1
   hello
  1. more命令
    more命另用于查看所有的纯文本文件。
  2. passwd 命令
    passwd用于设置用户口令命令。
   用法:
  [root@localhost ~]# passwd -S root
  root PS 1969-12-31 0 99999 7 -1 (Password set, SHA512 crypt.)
  [root@localhost ~]# passwd -S mary
  mary LK 2018-12-27 0 99999 7 -1 (Password locked.)
  [root@localhost ~]# passwd -u mary
  Unlocking password for user mary.
  passwd: Warning: unlocked password would be empty.
  passwd: Unsafe operation (use -f to force)
  [root@localhost ~]# passwd -u -f mary
  Unlocking password for user mary.
  [root@localhost ~]# passwd -l mary
  Locking password for user mary.
  passwd: Success
  1. head
    head用于查看文件的前指定行数。
  2. last命令
    last命令用于列出目前与过去登入系统的用户相关信息。
    • last -a —显示出何处登录系统的名称或ip地址。
    • last -d —将IP地址转换成主机的名称。
    • last -R —不显示登入系统的主机名或IP地址。
    • last -n —设置列出名单显示列数。
  用法:
  [root@localhost ~]# last
   root     pts/1        192.168.44.1     Thu Dec 27 17:11   still logged in
   root     pts/1        192.168.44.1     Thu Dec 27 17:10 - 17:10  (00:00)
   root     pts/0        192.168.44.1     Thu Dec 27 16:48   still logged in
   root     tty1                          Thu Dec 27 16:48   still logged in
   reboot   system boot  3.10.0-862.el7.x Thu Dec 27 16:47 - 19:03  (02:16)
   root     pts/0        192.168.44.1     Wed Dec 26 19:09 - crash  (21:38)
   root     pts/0        192.168.44.1     Wed Dec 26 15:39 - 19:08  (03:29)
   root     tty1                          Wed Dec 26 15:37 - crash (1+01:09)
   reboot   system boot  3.10.0-862.el7.x Wed Dec 26 15:36 - 19:03 (1+03:26)
   root     pts/0        192.168.44.1     Tue Dec 25 19:51 - 21:33  (01:41)
   root     tty1                          Tue Dec 25 19:41 - crash  (19:54)
   reboot   system boot  3.10.0-862.el7.x Tue Dec 25 19:40 - 19:03 (1+23:22)
   reboot   system boot  3.10.0-862.el7.x Mon Dec 24 15:07 - 19:03 (3+03:56)

   wtmp begins Mon Dec 24 15:07:06 2018
  [root@localhost ~]# last -a
   root     pts/1        Thu Dec 27 17:11   still logged in      192.168.44.1
   root     pts/1        Thu Dec 27 17:10 - 17:10  (00:00)     192.168.44.1
   root     pts/0        Thu Dec 27 16:48   still logged in    192.168.44.1
   root     tty1         Thu Dec 27 16:48   still logged in
   reboot   system boot  Thu Dec 27 16:47 - 19:03  (02:16)     3.10.0-862.el7.x86_64
   root     pts/0        Wed Dec 26 19:09 - crash  (21:38)     192.168.44.1
   root     pts/0        Wed Dec 26 15:39 - 19:08  (03:29)     192.168.44.1
   root     tty1         Wed Dec 26 15:37 - crash (1+01:09)
   reboot   system boot  Wed Dec 26 15:36 - 19:03 (1+03:27)    3.10.0-862.el7.x86_64
   root     pts/0        Tue Dec 25 19:51 - 21:33  (01:41)     192.168.44.1
   root     tty1         Tue Dec 25 19:41 - crash  (19:54)
   reboot   system boot  Tue Dec 25 19:40 - 19:03 (1+23:22)    3.10.0-862.el7.x86_64
   reboot   system boot  Mon Dec 24 15:07 - 19:03 (3+03:56)    3.10.0-862.el7.x86_64

   wtmp begins Mon Dec 24 15:07:06 2018
   [root@localhost ~]# last -d
   root     pts/1        192.168.44.1     Thu Dec 27 17:11   still logged in
   root     pts/1        192.168.44.1     Thu Dec 27 17:10 - 17:10  (00:00)
   root     pts/0        192.168.44.1     Thu Dec 27 16:48   still logged in
   root     tty1         0.0.0.0          Thu Dec 27 16:48   still logged in
   reboot   system boot  0.0.0.0          Thu Dec 27 16:47 - 19:03  (02:16)
   root     pts/0        192.168.44.1     Wed Dec 26 19:09 - crash  (21:38)
   root     pts/0        192.168.44.1     Wed Dec 26 15:39 - 19:08  (03:29)
   root     tty1         0.0.0.0          Wed Dec 26 15:37 - crash (1+01:09)
   reboot   system boot  0.0.0.0          Wed Dec 26 15:36 - 19:03 (1+03:27)
   root     pts/0        192.168.44.1     Tue Dec 25 19:51 - 21:33  (01:41)
   root     tty1         0.0.0.0          Tue Dec 25 19:41 - crash  (19:54)
   reboot   system boot  0.0.0.0          Tue Dec 25 19:40 - 19:03 (1+23:23)
   reboot   system boot  0.0.0.0          Mon Dec 24 15:07 - 19:03 (3+03:56)

   wtmp begins Mon Dec 24 15:07:06 2018
  [root@localhost ~]# last -n
   last: option requires an argument -- 'n'
   Usage: last [-num | -n num] [-f file] [-t YYYYMMDDHHMMSS] [-R] [-adioxFw] [username..] [tty..]
  [root@localhost ~]# last -R
   root     pts/1        Thu Dec 27 17:11   still logged in
   root     pts/1        Thu Dec 27 17:10 - 17:10  (00:00)
   root     pts/0        Thu Dec 27 16:48   still logged in
   root     tty1         Thu Dec 27 16:48   still logged in
   reboot   system boot  Thu Dec 27 16:47 - 19:03  (02:16)
   root     pts/0        Wed Dec 26 19:09 - crash  (21:38)
   root     pts/0        Wed Dec 26 15:39 - 19:08  (03:29)
   root     tty1         Wed Dec 26 15:37 - crash (1+01:09)
   reboot   system boot  Wed Dec 26 15:36 - 19:03 (1+03:27)
   root     pts/0        Tue Dec 25 19:51 - 21:33  (01:41)
   root     tty1         Tue Dec 25 19:41 - crash  (19:54)
   reboot   system boot  Tue Dec 25 19:40 - 19:03 (1+23:23)
   reboot   system boot  Mon Dec 24 15:07 - 19:03 (3+03:56)

   wtmp begins Mon Dec 24 15:07:06 2018
  1. tail命令
    tail用于查看文件的后指定行数
  [root@localhost /]# tail -5 /etc/passwd
  nobody:x:99:99:Nobody:/:/sbin/nologin
  vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin
  saslauth:x:499:76:Saslauthd user:/var/empty/saslauth:/sbin/nologin
  postfix:x:89:89::/var/spool/postfix:/sbin/nologin
  sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
  1. ln命令
    ln命令用于给文件创建软连接或者硬链接。
    • 创建的软连接当原文件删除后,创建的软连接将无法使用。
    • 创建的硬链接,删除原文件不影响链接文件的使用。
  用法:
  [root@localhost ~]# touch file1
  [root@localhost ~]# ln file1 file2
  [root@localhost ~]# ln -s file1 file3
  [root@localhost ~]# ls -l
  total 4
  -rw-------. 1 root root 1548 Dec 24 15:02 anaconda-ks.cfg
  -rw-r--r--. 2 root root    0 Dec 27 19:32 file1
  -rw-r--r--. 2 root root    0 Dec 27 19:32 file2
  lrwxrwxrwx. 1 root root    5 Dec 27 19:33 file3 -> file1
  [root@localhost ~]# echo "I am file1">>file1
  [root@localhost ~]# cat file1
  I am file1
  [root@localhost ~]# cat file2
  I am file1
  [root@localhost ~]# cat file3
  I am file1
  [root@localhost ~]# rm file1
  rm: remove regular file ‘file1’? y
  [root@localhost ~]# cat file2
  I am file1
  [root@localhost ~]# cat file3
  cat: file3: No such file or directory
  1. tr命令
    tr命令用于替换文本文件中的字符。
  2. alias命令
    alias用于显示所有的命令的别名。
  • alias name=‘command’ —为name定义别名。
  • unalias name —删除name的别名。
  • \ls —在执行中别名优先。
   用法:
   [root@localhost ~]# alias
   alias cp='cp -i'
   alias egrep='egrep --color=auto'
   alias fgrep='fgrep --color=auto'
   alias grep='grep --color=auto'
   alias l.='ls -d .* --color=auto'
   alias ls='ls --color=auto'
   alias mv='mv -i'alias rm='rm -i'
   alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
   [root@localhost ~]# alias ll='lll'
   [root@localhost ~]# alias
   alias cp='cp -i'
   alias egrep='egrep --color=auto'
   alias fgrep='fgrep --color=auto'
   alias grep='grep --color=auto'
   alias l.='ls -d .* --color=auto'
   alias ll='lll'
   alias ls='ls --color=auto'
   alias mv='mv -i'
   alias rm='rm -i'
   alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
  1. diff命令
    diff命令用于比较多个文本文件的差异。
  2. touch命令
    touch命令用于创建空白文本文件夹或者设置时间格式
   用法:
  [root@localhost ~]# touch f1
  [root@localhost ~]# touch f2
  [root@localhost ~]# touch f{3,4}
  [root@localhost ~]# ls -l
  total 8
  -rw-------. 1 root root 1548 Dec 24 15:02 anaconda-ks.cfg
  -rw-r--r--. 1 root root    0 Dec 27 19:59 f1
  -rw-r--r--. 1 root root    0 Dec 27 19:59 f2
  -rw-r--r--. 1 root root    0 Dec 27 19:59 f3
  -rw-r--r--. 1 root root    0 Dec 27 19:59 f4
  -rw-r--r--. 1 root root   11 Dec 27 19:34 file2
  lrwxrwxrwx. 1 root root    5 Dec 27 19:33 file3 -> file1
  1. mkdir命令
    mkdir命令用与新建空白目录。
   用法:
  [root@localhost ~]# mkdir dir1
  [root@localhost ~]# mkdir dir2
  [root@localhost ~]# mkdir dir{3,4}
  [root@localhost ~]# ls -l
  total 8
  -rw-------. 1 root root 1548 Dec 24 15:02 anaconda-ks.cfg
  drwxr-xr-x. 2 root root    6 Dec 27 20:01 dir1
  drwxr-xr-x. 2 root root    6 Dec 27 20:01 dir2
  drwxr-xr-x. 2 root root    6 Dec 27 20:01 dir3
  drwxr-xr-x. 2 root root    6 Dec 27 20:01 dir4
  1. cp命令
    cp命令用于复制文件或者目录。
    • cp -i —交互式复制,即覆盖之前提醒用户。
    • cp -f —强制覆盖目标文件。
    • cp -r —递归复制目录。
   用法:
  [root@localhost ~]# cp f1 dir1
  [root@localhost ~]# cp f1 dir1
  cp: overwrite ‘dir1/f1’? y
  [root@localhost ~]# cp -f f1 dir1
  cp: overwrite ‘dir1/f1’? y
  [root@localhost ~]# cp -rf dir1 dir2
  [root@localhost ~]# ls dir1
  f1
  [root@localhost ~]# ls dir2
  dir1
  1. mv命令
    mv命令用于剪贴或者将文件重命名。
   用法:
  [root@localhost ~]# mv f1 dir3
  [root@localhost ~]# cd dir3
  [root@localhost dir3]# ls
  f1
  [root@localhost dir3]# mv f1 f2
  [root@localhost dir3]# ls
  f2

17.grep命令
grep命令用于过滤文本。

  • grep -i —忽略大小写。
  • grep -o —近显示匹配到的字符串本省。
  • grep - v —显示不能被模式匹配到的行。
  • grep - A# —显示后#行。
  • grep -B# —显示前#行。
   用法:
  [root@localhost ~]# grep "UUID" /etc/fstab
  UUID=9ed80616-655d-490e-8159-2ad6b3d9a876 /boot    xfs    defaults    0 0
  [root@localhost ~]# grep -i "Root" /etc/passwd
  root:x:0:0:root:/root:/bin/bash
  operator:x:11:0:operator:/root:/sbin/nologin
  [root@localhost ~]# grep "Root" /etc/passwd
  [root@localhost ~]# grep "r..t" /etc/passwd
  root:x:0:0:root:/root:/bin/bash
  operator:x:11:0:operator:/root:/sbin/nologin
  ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
  1. ifconfig命令
    获取网卡配置与网络状态。
  2. 管道 | 和tee命令
    | 将上一个命令的输出当作写一个命令的输入,和其他命令配合使用。
    tee 将执行结果即可以输入道终端也可以保存至制定的文件。
  [root@localhost /]# ls -l | grep lib
 dr-xr-xr-x.  8 root root  4096 Mar 20 03:11 lib
 dr-xr-xr-x.  7 root root 12288 Mar 10 02:12 lib64
 [root@localhost ~]# ip addr|grep 'inet' |tee ip.txt 
     inet 127.0.0.1/8 scope host lo
     inet6 ::1/128 scope host 
     inet 192.168.44.129/24 brd 192.168.44.255 scope global eth0
     inet6 fe80::20c:29ff:fe3a:a941/64 scope link 
 [root@localhost ~]# cat ip.txt
     inet 127.0.0.1/8 scope host lo
     inet6 ::1/128 scope host 
     inet 192.168.44.129/24 brd 192.168.44.255 scope global eth0
     inet6 fe80::20c:29ff:fe3a:a941/64 scope link 
  1. who命令
    用以查询登录系统的用户信息。
  • -b 指出最近系统启动的时间和日期。
  • -l 列出任何登录进程。
  • -m 仅显示关于当前终端的信息,即当前登录用户信息。
  • -p 列出任何当前活动的和以前已由 init 生成的活动进程
  • -r 显示当前进程的运行级别。
  • -s 仅列出名字、线路和时间字段。
  • -t 显示 root 用户上一次用 date 命令对系统时钟做的更改。
  • -u 显示每个当前用户的用户名、tty、登录时间、线路活动和进程标识。
  [root@localhost /]# who -b
          system boot  2019-03-22 03:24
 [root@localhost /]# who -l
 LOGIN    tty3         2019-03-22 03:24              1364 id=3
 LOGIN    tty2         2019-03-22 03:24              1362 id=2
 LOGIN    tty4         2019-03-22 03:24              1366 id=4
 LOGIN    tty5         2019-03-22 03:24              1368 id=5
 LOGIN    tty6         2019-03-22 03:24              1370 id=6
 [root@localhost /]# who -m
 root     pts/0        2019-03-22 03:29 (192.168.44.1)
 [root@localhost /]# who -p
 [root@localhost /]# who -r
          run-level 3  2019-03-22 03:24
 [root@localhost /]# who -s
 root     tty1         2019-03-22 03:28
 root     pts/0        2019-03-22 03:29 (192.168.44.1)
 [root@localhost /]# who -u
 root     tty1         2019-03-22 03:28 00:35        1360
 root     pts/0        2019-03-22 03:29   .          1405 (192.168.44.1)
  1. ps命令
    ps命令用于显示系统进程瞬间的运行动态。
  • -A 所有的进程均显示出来;
  • -a 显示现行终端机下的所有进程,包括其他用户的进程;
  • -u 以用户为主的进程状态 ;
  • x 通常与 a 这个参数一起使用,可列出较完整信息。
  1. top命令
    用于监控系统处理器的状态。
  2. rm命令
    rm删除文件,但操作时需谨慎。防止误删文件。
  • -f 强制删除文件,忽略不存在的文件;
  • -i 交互式删除,删除时给出提醒;
  • -r 递归删除目录以及目录下的文件。
  [root@localhost tmp]# rm file1
  rm: remove regular file ‘file1’? y
  [root@localhost tmp]# rm -rf file2
  [root@localhost tmp]# 

以上仅为一些常用的命令符,linux的命令符有很多,需要我们在学习的过程中不断的去运用、多练、多记、多积累。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值