.bashrc 파일이 없을때 복구하기

IT 등/POGOPLUG 2021. 10. 3. 20:32

가끔 예전 리눅스나 계정 생성 과정을 잘못 만진 경우 계정은 생성되지만 부속 파일들이 세팅되지 않을 경우가 있다. 예를들어 .bash_profile 이나 .bashrc 등.

그냥 잘 쓰다가도 스크립트를 만진다던가, alias 를 만지려할때 저것이 없으면 당황하기 쉽다.

어차피 시스템 공통으로 쓰이는 /etc/bashrc 파일은 존재할테니 각 계정별 파일만 만들어주면 된다.

.bashrc 파일을 생성하고 그 안에 내용을 넣으면 되는데, 가끔 그게 적용이 되지 않을때가 있다. 저 위에서 말한 .bash_profile 파일이 생성되지 않아서이다.
profile 파일의 이름은 시스템마다 다르다.

.bash_profile 인 경우가 있고 .profile 인 경우도 있다.

그때는 해당 파일을 생성하고 아래 내용으로 만들어주면 된다.

# ~/.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

 

설정

트랙백

댓글