53

环境变量PATH-菜鸟的成长之路-51CTO博客

 6 years ago
source link: http://blog.51cto.com/12777709/2067107
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

环境变量PATH

which 查看绝对路径
which ls查看ls的绝对路径
[root@localhost ~]# which ls
alias ls='ls --color=auto'
/usr/bin/ls
echo $PATH 查看规则目录
[root@localhost ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
他只会在这几个目录里面寻找
alias 是一个可以把长命令改为别名的命令,格式为 alias 要改变=‘命令’
直接输入alias可以直接查看是哪些命令使用了‘别名’
但是只是在当前终端生效

需要写在。bashrc下
vim ~/.bashrc 或者直接vim .bashrc 写了之后就可以在所有的终端下生效
[root@localhost ~]# vim /etc/profile
#.bashrc

User specific aliases and functions

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

Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

PATH=$PATH:/目录/ 只能在当前端口可用。
添加到profile就可以全局使用了。
vim /etc/profile
profile是添加变量的,但是需要重启
还有一个命令是及时生效的,source /etc/profile

©著作权归作者所有:来自51CTO博客作者ys杨国纬的原创作品,谢绝转载,否则将追究法律责任

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK