1.#PATH=$PATH:/opt/lamp/mysql/bin
使用这种方法,只对当前会话有效,也就是说每当登出或注销系统之后,PATH 设置就会失效mysql
2.#vi /etc/profile
在适当位置添加 PATH=$PATH:/etc/apache/bin (注意:= 即等号两边不能有任何空格)这种方法最好,除非你手动强制修改PATH的值,不然将不会被改变sql
但通常状况下咱们不直接在这里面修改,在/etc/profile开头有这样的提示:shell
# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.apache
因此:添加一个customer.sh文本文件到 /etc/profile.d/目录下,打开它并敲入bash
3.#vi ~/.bash_profile
修改PATH行,把/opt/lamp/mysql/bin添加进去这种方法是针对用户起做用的less
注意:想改变PATH,必须从新登录才能生效,如下方法能够简化工做:ide
若是修改了/etc/profile,那么编辑结束后执行source profile 或 执行点命令 ./profile,PATH的值就会当即生效了。这个方法的原理就是再执行一次/etc/profile shell脚本,注意若是用sh /etc/profile是不行的,由于sh是在子shell进程中执行的,即便PATH改变了也不会反应到当前环境中,可是source是在当前 shell进程中执行的,因此咱们能看到PATH的改变。this
通常状况下在用户工做目录下的bin目录会包含在PATH路径中,因此只要把用户本身写的shell脚本放在用户的bin目录下就能够了,不须要修改配置文件。idea