Linux常用基础命令(二)

目录

1.查看命令类型:

2.命令别名:

3.which:

4.whereis:

5.who:

6.w:

注:本系统环境为centos 7 。

1.查看命令类型:

命令类型:
外部命令、shell内部命令

命令格式:type COMMAND:
                   内部:builtin(内置)
                   外部:显示为命令文件路径;
                   注意:命令可以有别名;
                              别名可以与原名相同,此时原名被隐藏;此时如果要运行原命令,则使用\COMMAND
                              在使用一些不熟悉的命令的时候,应该先type COMMAND;
                              然后help COMMAND或COMMAND --help, 
                              来获取命令的帮助文档;或者使用man COMMAND.

2.命令别名:

获取所有可用别名的定义:
如下所示,为系统默认的别名设置。

~]#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'

定义别名:
注意:这种定义别名的方法,仅对当前shell进程有效

~]# alias NAME='COMMAND'

如果要长期有效,可以在用户的家目录,编辑这个文件:
 

~]#cat .bashrc 
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

撤销别名:

~]# unalias NAME

3.which:

which - shows the full path of (shell) commands
which [options] programname [...]
                --skip-alias:忽略别名

~]#which cp
alias cp='cp -i'
	/usr/bin/cp
~]#which --skip-alias cp
/usr/bin/cp

4.whereis:

whereis - locate the binary, source, and manual page files for a command
whereis [options] name...
                -b: 仅搜索二进制程序路径;
                -m:仅搜索使用手册文件路径;

~]#whereis cp
cp: /usr/bin/cp /usr/share/man/man1/cp.1.gz /usr/share/man/man1p/cp.1p.gz
~]#whereis -b cp
cp: /usr/bin/cp
~]#whereis -m cp
cp: /usr/share/man/man1/cp.1.gz /usr/share/man/man1p/cp.1p.gz

5.who:

who - show who is logged on
 who [OPTION]...
                 -b: 系统此次启动的时间;
                 -r: 运行级别;

~]#who -r
         运行级别 5 2018-12-03 10:09

6.w:

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

猜你喜欢

转载自blog.csdn.net/weixin_39924535/article/details/84754796
今日推荐