centos

sys.3.1 linux 基础命令

一、Linux系统上的文件类型
1> – : 常规文件,即f
2> d : directory , 目录文件
3> b : block device , 块设备文件,支持以“block”为单位进行随机访问
4> c : character device , 字符设备文件,支持以“character”为单位进行线性访问

major number : 主设备号,标识设备类型,可以确定要加载的驱动程序
minor number : 次设备号,标识同一类型的不同设备

5> l : symbolic link , 符号链接文件
6> p : pipe , 命名管道
7> s : socket , 套接字文件

二、Linux命令类型
1> 外部命令
2> shell内嵌命令(内部命令)
PS 1: 查看命令类型,type COMMAND
PS 2: 命令可以有别名,别名可以与原命令名相同,此时原命令名被隐藏;如果要运用原命令,则使用\COMMAND
PS 3: 查看当前系统有哪些命令有别名,以及别名信息:

[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='ls -l --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'

PS 4: 定义别名; ~]# alias NAME=’COMMAND’ ; 此操作仅对当前shell进程有效;
PS 5: 撤销别名; ~]# unalias NAME

三、几个基础命令
which ; whereis ; who ; w .

which – shows the full path of (shell) commands.
说明:which命令显示命令的全路径

命令格式:which [options] [--] programname [...]
options:
--skip-alias : 忽略需要查找的命令的别名
[root@localhost ~]# which --skip-alias ls
/usr/bin/ls
[root@localhost ~]# which ls
alias ls='ls --color=auto'
  /usr/bin/ls
[root@localhost ~]#

whereis – locate the binary, source, and manual page files for a command.
说明:显示命令的二进制文件、源文件、man手册页的路径

命令格式: which [options] [--] programname [...]
[root@localhost ~]# whereis ls
ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz /usr/share/man/man1p/ls.1p.gz
[root@localhost ~]# 
options:
-b : 仅搜索二进制程序路径;
-m : 仅搜索使用手册文件路径;
[root@localhost ~]# whereis -b ls
ls: /usr/bin/ls
[root@localhost ~]# 
[root@localhost ~]# whereis -m ls
ls: /usr/share/man/man1/ls.1.gz /usr/share/man/man1p/ls.1p.gz
[root@localhost ~]#

who – show who is logged on
说明:显示登录当前系统的用户信息;

命令格式:who [OPTION]... [ FILE | ARG1 ARG2 ]
OPTIONS:
-b : 系统此次启动的时间;
-r : 显示当前系统的运行级别;
-u : 列出用户登录信息(比 'who' 多了如下信息:用户登录系统多长时间,以及进程号)

[root@localhost ~]# who
root     tty1         2017-12-27 05:43
root     pts/0        2018-03-10 11:23 (192.168.206.1)
root     pts/1        2018-03-11 16:57 (192.168.206.1)
root     pts/2        2018-03-18 10:42 (192.168.206.1)
root     pts/3        2018-03-18 10:56 (192.168.206.1)
[root@localhost ~]# 

[root@localhost ~]# who -b
         system boot  2017-12-27 05:43
[root@localhost ~]# 

[root@localhost ~]# who -r
         run-level 3  2017-12-27 05:43
[root@localhost ~]# 

[root@localhost ~]# who -u
root     tty1         2017-12-27 05:43 00:25         684
root     pts/0        2018-03-10 11:23  old        92790 (192.168.206.1)
root     pts/1        2018-03-11 16:57  old       117666 (192.168.206.1)
root     pts/2        2018-03-18 10:42 00:08      119970 (192.168.206.1)
root     pts/3        2018-03-18 10:56   .        120106 (192.168.206.1)
[root@localhost ~]#

w – Show who is logged on and what they are doing.

命令格式:w [options] user [...]
[root@localhost ~]# w
 11:11:14 up 2 days,  3:14,  5 users,  load average: 0.00, 0.01, 0.05
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
root     tty1                      27Dec17 28:58   1.03s  1.03s -bash
root     pts/0    192.168.206.1    10Mar18  6days  0.33s  0.33s -bash
root     pts/1    192.168.206.1    11Mar18  6days  0.29s  0.29s -bash
root     pts/2    192.168.206.1    10:42   42.00s  0.04s  0.00s less -s
root     pts/3    192.168.206.1    10:56    2.00s  0.04s  0.02s w
[root@localhost ~]#

 

Leave a Reply

Your email address will not be published. Required fields are marked *