(十六)命令别名与历史命令
alias 命令别名
设置 alias 取消 unalias
1 [root@localhost ~]# alias //查看所有的命令别名 2 alias cp='cp -i' 3 alias l.='ls -d .* --color=auto' 4 alias ll='ls -l --color=auto' 5 alias ls='ls --color=auto' 6 alias mv='mv -i' 7 alias rm='rm -i' 8 alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' 9 [root@localhost ~]# alias lm='ls -al' //设置ls -al的别名为lm 10 [root@localhost ~]# lm 11 总用量 21616 12 dr-xr-x---. 6 root root 4096 10月 20 22:39 . 13 dr-xr-xr-x. 24 root root 4096 10月 22 10:00 .. 14 drwxr-xr-x. 2 root root 4096 8月 28 02:17 123.log 15 -rw-r--r--. 1 root root 0 10月 20 22:39 a.html 16 -rw-------. 1 root root 2454 8月 10 21:36 anaconda-ks.cfg 17 -rw-------. 1 root root 5824 10月 21 19:42 .bash_history 18 -rw-r--r--. 1 root root 18 5月 20 2009 .bash_logout 19 -rw-r--r--. 1 root root 176 5月 20 2009 .bash_profile 20 -rw-r--r--. 1 root root 176 9月 23 2004 .bashrc 21 -rw-r--r--. 1 root root 100 9月 23 2004 .cshrc 22 -rw--w-rw-. 1 root users 52211 8月 10 21:36 install.log 23 -rw-r--r--. 1 root root 14312 8月 10 21:34 install.log.syslog 24 -rw-------. 1 root root 28 10月 20 16:37 .mysql_history 25 -rw-r--r--. 1 root root 8073290 10月 22 09:39 phpMyAdmin-4.0.10.10-all-languages.tar.gz 26 -rw-r--r--. 1 root root 13865121 10月 21 14:29 phpwind_UTF8_8.7.zip 27 drwxr-xr-x. 2 root root 4096 8月 12 02:43 qq 28 -rw----r--. 1 root root 52211 8月 12 22:29 qq.log 29 -rw-r--r--. 1 root root 129 12月 4 2004 .tcshrc 30 drwxr-xr-x. 2 root root 4096 8月 12 02:49 test1 31 drwxr-xr-x. 2 root root 4096 8月 12 02:49 test2 32 -rw-r--r--. 1 root root 0 8月 12 22:28 zxc 33 [root@localhost ~]# alias 34 alias cp='cp -i' 35 alias l.='ls -d .* --color=auto' 36 alias ll='ls -l --color=auto' 37 alias lm='ls -al' 38 alias ls='ls --color=auto' 39 alias mv='mv -i' 40 alias rm='rm -i' 41 alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' 42 [root@localhost ~]# unalias lm //取消命令别名 43 [root@localhost ~]# alias 44 alias cp='cp -i' 45 alias l.='ls -d .* --color=auto' 46 alias ll='ls -l --color=auto' 47 alias ls='ls --color=auto' 48 alias mv='mv -i' 49 alias rm='rm -i' 50 alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' 51 [root@localhost ~]#
查看文件在哪个目录下
1 [root@localhost ~]# which dir 2 /usr/bin/dir 3 [root@localhost ~]# type -a dir 4 dir is /usr/bin/dir
历史命令 history
history n
history [-crw]
- -c 将当前shell中的所有历史命令清除
- -r 将histfile中的内容读到shell的命令记忆中
- -w 将当前历史记忆内容写到histfile中
- !number :执行第几个指令
- !Command:执行以command开头的指令
思维导图:



浙公网安备 33010602011771号