Linux-centos/Linux-centos__works

linux 설정 파일 정리

말하는감자 2019. 7. 8. 14:01

환경 설정은 profile / alias, 함수는 bashrc를 권장한다

~/ 이건 부모 디렉토리의 하위를 이야기함

지금 내가 /home/test 밑에 있다면 /home/test/아래의뭐뭐뭐 를 호출


환경 설정 파일 인식 순서

/etc/profile -> ~/.bash_profile -> ~/.bashrc -> /etc/bashrc


login shell

id와 password를 입력해서 shell을 실행하는 것

ssh로 접속하거나 로컬에서 GUI를 통해 shell을 실행하는 것

.profile, .bash_profile 은 login떄 로드된다

.profile은 꼭 bash가 아니더라도 로그인하면 로드되며, .bash_profile은 bash로 로그인 할 때만 실행된다

 

non login shell

로그인 없이 실행되는 shell

ssh로 접속하고 나서 다시 bash를 실행하는 경우

gui 세션에서 터미널을 띄우는것


.bashrc

-> 이미 로그인 한 상태로 새 터미널 창을 열때마다(non login shell))

 

.bash_profile

->시스템에 로그인 할 때마다

->개별 사용자에 대한 설정

 

.profile

->로그인 할 때


이미 로그인 한 상태로 새 창을 열때마다 .bashrc를 로드하는 방법

.bash_profile에서 로드시키기

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

/etc/profile 전체사용자

# Path manipulation
if [ "$EUID" = "0" ]; then
    pathmunge /usr/sbin
    pathmunge /usr/local/sbin
else
    pathmunge /usr/local/sbin after
    pathmunge /usr/sbin after
fi

HOSTNAME=`/usr/bin/hostname 2>/dev/null`
HISTSIZE=1000
if [ "$HISTCONTROL" = "ignorespace" ] ; then
    export HISTCONTROL=ignoreboth
else
    export HISTCONTROL=ignoredups
fi

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL

# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
    umask 002
else
    umask 022
fi

for i in /etc/profile.d/*.sh /etc/profile.d/sh.local ; do
    if [ -r "$i" ]; then
        if [ "${-#*i}" != "$-" ]; then
            . "$i"
        else
            . "$i" >/dev/null
        fi
    fi
done

unset i
unset -f pathmunge

/etc/bashrc 전체사용자

fi

if ! shopt -q login_shell ; then # We're not a login shell
    # Need to redefine pathmunge, it get's undefined at the end of /etc/profile
    pathmunge () {
        case ":${PATH}:" in
            *:"$1":*)
                ;;
            *)
                if [ "$2" = "after" ] ; then
                    PATH=$PATH:$1
                else
                    PATH=$1:$PATH
                fi
        esac
    }

    # By default, we want umask to get set. This sets it for non-login shell.
    # Current threshold for system reserved uid/gids is 200
    # You could check uidgid reservation validity in
    # /usr/share/doc/setup-*/uidgid file
    if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
       umask 002
    else
       umask 022
    fi

    SHELL=/bin/bash
    # Only display echos from profile.d scripts if we are no login shell
    # and interactive - otherwise just process them to set envvars
    for i in /etc/profile.d/*.sh; do
        if [ -r "$i" ]; then
            if [ "$PS1" ]; then
                . "$i"
            else
                . "$i" >/dev/null
            fi
        fi
    done

    unset i
    unset -f pathmunge
fi
# vim:ts=4:sw=4

/root/.bashrc

# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

/root/.bash_profile

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH

~./bash_profile 해당 사용자

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

~/.bashrc 해당 사용자

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=

# User specific aliases and functions

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!

# <<< conda initialize <<<

~/.bash_logout 해당사용자

# ~/.bash_logout

~./bash_history 해당 사용자가 사용한 명령어 기록

이거저거 진짜 많이 써있음

'Linux-centos > Linux-centos__works' 카테고리의 다른 글

가상단말  (0) 2019.07.09
grep  (0) 2019.07.09
32비트 64비트 확인  (0) 2019.06.14
랜선 정상인데 인터넷 안될때  (0) 2019.06.10
centos git 설치  (0) 2019.06.05