Bash의 새 사용자에 대해 프롬프트 문자열이 올바르게 설정되지 않았습니다.

Bash의 새 사용자에 대해 프롬프트 문자열이 올바르게 설정되지 않았습니다.

나는 내 코스 중 하나에서 Kali Linux를 사용하고 있으며 첫 번째 과제의 일부는 기본 kali 로그인 대신 우리 이름을 사용하여 사용자 정의 사용자 계정을 만드는 것입니다. 그러나 이렇게 하면 터미널과 혼동됩니다.

기본 Kali 터미널은 다음과 같습니다. 여기에 이미지 설명을 입력하세요.

이것은 사용자 터미널입니다.

여기에 이미지 설명을 입력하세요.

색상 외에도 케이스도 사용하기가 더 어렵습니다. 제안 사항도 없고 자동 완성도 없으며 스크롤이나 입력 이외의 어떤 것도 허용되지 않습니다. 사용자 터미널을 기본 kali 터미널처럼 보이게 만드는 방법을 모르겠습니다. 복사 .bashrc를 시도했지만 아무 것도 바뀌지 않은 것 같습니다./home/kali/home/jeff

복사된 텍스트 .bashrc:

 ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar

# make less more friendly for non-text input files, see lesspipe(1)
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm-color|*-256color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
        # We have color support; assume it's compliant with Ecma-48
        # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
        # a case would tend to support setf rather than setaf.)
        color_prompt=yes
    else
        color_prompt=
    fi
fi

if [ "$color_prompt" = yes ]; then
    prompt_color='\[\033[;32m\]'
    info_color='\[\033[1;34m\]'
    prompt_symbol=㉿
    if [ "$EUID" -eq 0 ]; then # Change prompt colors for root user
        prompt_color='\[\033[;94m\]'
        info_color='\[\033[1;31m\]'
        prompt_symbol=

답변1

질문의 정보에 따르면 귀하가 겪고 있는 결과를 초래할 수 있는 몇 가지 요인이 있습니다.

기억해야 할 주요 원칙은 Linux에는 dash, csh, bash 및 zsh와 같은 여러 가지 다른 셸을 사용할 수 있다는 것입니다. 쉘은 프롬프트를 제공하고, 명령을 받아들이고, 출력을 반환하는 모든 프로그램입니다. "표준" 셸은 모두 유사하지만 기능과 구성 방법이 다릅니다.

또한 모든 배포판에서는 새로운 사용자를 위한 기본 셸을 선택하는데, 이는 일반적으로(항상은 아니지만) Bash입니다. 이는 일반적으로 성능을 선호하고 비표준 확장을 더 적게 선호하는 배포판에 선택됩니다 sh(보통 다른 쉘에 대한 심볼릭 링크를 생성한 다음 sh 호환 모드에서 해당 쉘을 실행함).

/etc/passwdKali가 jeff 사용자에 대한 쉘을 기본값으로 사용한다는 설명 중 하나의 출력에서 ​​볼 수 있습니다 sh. 성능은 매우 좋지만 이 옵션에는 구성 가능한 프롬프트 및 명령 완성과 같은 기능이 부족합니다.

따라서 문제를 해결하는 첫 번째 단계는 다음과 같은 명령을 실행하는 것입니다.

sudo chsh -s /bin/bash jeff

댓글에서 이미 논의한 것처럼 나머지 문제는 권한에 달려 있는 것 같습니다. 각 사용자의 쉘 ​​구성 파일 등은 ~/.bashrc사용자가 읽어야 합니다.

/etc/defaults/useradd디렉토리를 편집(또는 추가)하여 새로운 사용자에 대해 쉘 기본값을 시스템 전체에서 변경할 수 있습니다 /etc/skel/.

광산 /etc/defaults/useradd(Void Linux용)에는 다음이 포함됩니다.

# useradd defaults file
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=no

/etc/skel이 명령을 실행하면 해당 파일이 새 사용자의 홈 디렉터리에 복사됩니다 useradd.

답변2

모든 것을 올바르게 구성했는데도 동일한 문제가 발생합니다. 무슨 일이 일어났는지는 확실하지 않습니다. 하지만:

sudo shutdown /r

간단한 재부팅으로 작동하게 되었습니다.

관련 정보