종료 방법 > Linux 터미널 모드

종료 방법 > Linux 터미널 모드

원격 서버에서 Red Hat Enterprise Linux Server 버전 7.9를 사용하고 있습니다.

source ~/.bashrc명령을 사용한 후 잘 이해되지 않는 일종의 모드에 들어갔습니다. 대신 내가 bash $지금 가지고 있는 것은 디렉토리를 변경하면 계속 변경된다는 것 입니다.bash #bash:~ >bash:/somedirectory >

누군가 무슨 일이 일어나고 있으며 일반 모드로 돌아가는 방법을 설명해 주시겠습니까?

# Generic $dotdir/bashshrc
# Engineering Services (ES)
#
##
# Things the user might wish to set.
export USER_PATH="~/bin"            # Extra paths.
export EDITOR=vi                # Preferred editor.
export PRINTER=lp               # Preferred printer.
export NNTPSERVER=usenet.cisco.com      # Preferred news server.
 

##
# Should the full environment be set up even for non-interactive shells?
# Probably not but here is a variable to control it.
export FULLENV=false                # 'true' or 'false'

##
# Should all paths (even NFS, which might hang) be set up at login?
# The alias "fullpath" is available to setup your full path.  It can
# also be used to change your path by changing USER_PATH above.
export FULLPATH=true                # 'true' or 'false'

###########################################################################
# Everything above this line helps configure the environment.

# This line should not be removed.
dotdir=~/.files; [ -f $dotdir/sys_bashrc ] && . $dotdir/sys_bashrc
[ $FULLENV != "true" ] && [ -z "$PS1" ] && return

###########################################################################
# Everything below this line is run for interactive shells.
# If you wish the full environment even in non-interactive
# shells set FULLENV above to 'true'.

umask 022                        # no write by group or other
export autologout=0              # disable autologout
export FIGNORE=".o"              # don't complete .o files
# export HISTFILE=~/.bash_history  # history file - this setting is now externally enforced by Secops, please don't modify.
# export HISTFILESIZE=500        # history file size - this setting is now externally enforced by Secops, please don't modify.
# export HISTSIZE=128            # save last 128 commands - this setting is now externally enforced by Secops, please don't modify.
export ignoreeof=10              # disable ^D for logout (up to 10)
set -C                           # disable redirect overwrite
set -b                           # enable immediate job notify
export PS1="\h:\w > "            # shell prompt format

##
# Source other rc files after this line.
[ -f ~/.bashrc_LOB ] && . ~/.bashrc_LOB
[ -f ~/.bashrc_BU ] && . ~/.bashrc_BU
[ -f ~/.bashrc_USER ] && . ~/.bashrc_USER

경로를 편집하기 위해 파일을 엽니다. 그러나 쓰기 권한을 확인하기 위한 추가 공간 외에는 변경된 사항이 없습니다.

답변1

비록 >기본값이지만두 번째 알림(변수에 의해 결정됨 $PS2) Bash를 사용하면 상황이 실수로 기본 프롬프트( )를 변경한 것처럼 보입니다 $PS1.

Paul_Pedant가 주석에서 언급한 것처럼, 짝이 맞지 않는 따옴표나 괄호 또는 끝나지 않은 문( if ... then ... fi, case ... esac, ) do ... done이 포함된 명령을 실행하려고 하면 보조 프롬프트가 나타납니다 .

그러나 디렉토리를 변경할 수 있기 때문에 이제 기본 프롬프트가 보조 프롬프트와 유사하게 변경되었을 가능성이 높습니다 ~/.bashrc. 실제로 보조 프롬프트에 있는 경우 입력하는 모든 명령은 미해결 참조를 확장하는 데 사용됩니다. /bracket / 문 블록이 이를 먼저 트리거하고, 완료되지 않은 블록을 완료한 후에만 명령이 실제로 실행됩니다. 이는 실제 보조 프롬프트에 있는 경우 디렉터리를 변경할 수 없음을 의미합니다.

가장 간단한 해결책은 기본 프롬프트를 더 친숙한 값으로 다시 변경하는 것입니다. 예를 들어:

export PS1='bash \$ '

\$기본 프롬프트에는 특별한 의미가 있습니다. 루트 사용자라면 확장되고, 일반 사용자 #라면 확장됩니다.$


변경 사항은 다음 줄로 인해 발생합니다 ~/.bashrc.

export PS1="\h:\w > "            # shell prompt format

hostname:current directory주석 처리하거나 프롬프트의 표시 내용이 유용하다고 판단되면 행을 다음과 같이 변경할 수 있습니다.

export PS1="\h:\w \$ "            # shell prompt format

$프롬프트에 표시된 호스트 이름과 현재 작업 디렉터리를 유지하면서 프롬프트의 / 문자가 이전과 동일한 방식으로 작동하도록 하세요 .#

관련 정보