linux之profile、bash_profile、bashrc

profile、bash_profile、bashrc文件

  1. profile (/etc/profile`)

用于设置系统级的环境变量和启动程序,在这个文件下配置会对所有用户生效。当用户登录(login)时,文件会被执行。

  1. bashrc (/etc/bashrc)

这个文件用于配置函数或别名。bashrc文件有两种级别:系统级的位于/etc/bashrc、用户级的~/.bashrc,两者分别会对所有用户和当前用户生效。

  1. bash_profile (~/.bash_profile)

bash_profile只有单一用户有效,文件存储位于~/.bash_profile,该文件是一个用户级的设置,可以理解为某一个用户的profile目录下。这个文件同样也可以用于配置环境变量和启动程序,但只针对单个用户有效。

profile文件类似,bash_profile也会在用户登录(login)时生效,也可以用于设置环境变理。但与profile不同,bash_profile只会对当前用户生效。

设置alias别名

  1. 编辑.bashrc文件

vim ~/.bashrc

  1. 设置别名

alias ll='ls -l'

注意:等号两边不能有空格

保存退出

  1. 使配置文件生效

source ~/.bashrc

  1. 测试设置的命令是否生效

链接

github:https://github.com/pandaomeng/blog

博客:https://pandaomeng.com

你可能感兴趣的:(linux之profile、bash_profile、bashrc)