linux中./profile
时间: 2023-10-11 16:12:23 浏览: 40
在Linux中,`.profile`文件是一个登录shell的配置文件。当用户登录时,系统会读取该文件并执行其中的命令。用户可以在其中设置环境变量、别名、函数等。具体来说,`.profile`文件位于用户的home目录下,其完整路径为`~/.profile`。如果该文件不存在,则用户可以手动创建该文件并添加自己需要的配置。需要注意的是,`.profile`文件只会在用户登录时执行一次,如果需要在每次打开终端时执行,可以将相关配置写入`.bashrc`文件中。
相关问题
我要一份linux中./etc.profile文件中的内容
以下是一个典型的Linux系统中/etc/profile文件的示例:
```
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
if [ "`id -u`" -eq 0 ]; then
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
fi
export PATH
if [ "`id -u`" -eq 0 ]; then
umask 002
else
umask 022
fi
if test -z "$MAIL" -a -f /usr/bin/biff; then
biff y
fi
if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi
```
这个文件主要设置了环境变量 PATH,umask,和加载了 /etc/profile.d/ 目录下的其他脚本。
.bashrc 和./profile有什么区别
.bashrc和./profile都是在Unix/Linux系统中用于配置环境变量和设置用户个性化环境的文件,但是它们的作用是不同的。
.bashrc文件是在bash shell启动时自动读取的,它主要用于定义用户的个性化bash环境,如alias、环境变量等。它只对当前用户的bash shell有效。
./profile文件是在用户登录时读取的,它主要用于定义用户的全局环境变量,如PATH、PS1等。它对当前用户所有的shell都有效。
所以,如果你想定义个性化的bash环境变量,你应该把它们放在.bashrc文件中。如果你想定义全局的环境变量,你应该把它们放在./profile文件中。