~/.bashrc 未在 12.04 lts 中自动获取

Pet*_*ter 1 bashrc 12.04

正如这篇文章所说,它~/.bashrc是在我使用的 Ubuntu 12.04 LTS 服务器中自动获取的。我不知道他从哪里得到这些信息,但由于它还没有被否决,我相信这是真的。

我用这个脚本来检查它是否来源:

if [ -f ~/.bashrc ]; then
   echo "Not sourced!";
fi
Run Code Online (Sandbox Code Playgroud)

仅供参考:目前的权限是 775,所有者是我。

那么为什么我的~/.bashrc不是来源?

ant*_*tel 6

正如我们发现的那样,您家中没有.profile文件。在此处查看bash 手册以获取 Bash 启动文件。

为自己创建一个 .profile:

nano ~/.profile

将此文本插入该文件(从 Debian Squeeze 复制):

# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi
Run Code Online (Sandbox Code Playgroud)

提示:如果您要创建新用户,请使用-m开关将其设为目录,并放置默认文件,例如:sudo useradd example -m -d /home/example