分页: 1 / 2

�[问题]重构用户后竟然发生这样的事情(有了思路了,仍未解决)。。。。。。。。。。

发表于 : 2008-07-26 11:37
2ine
在root下重构了自己的用户,然后用usermod修正了权限。
但是这个时候打开终端,发现原本应该显示
用户名@计算机名:"$
我这里显示的是$
看的别扭,这个怎么改回去。。

发表于 : 2008-07-26 11:47
JangMunho
学习一下环境变量PS1吧。
echo $PS1
你那里显示的应该就是一个$
输入这个:
PS1="\u@"$hostname"'$' "
再输入bash,看看是不是好了,如果好了就把PS1="\u@"$hostname"'$' "写入~/.bashrc

发表于 : 2008-07-26 11:47
冲浪板
$PS1就是管理这个事的
echo $PS1看看

发表于 : 2008-07-26 11:59
2ine
明白了。。
不过我把PS1="\u@"$hostname"'$' "写入~/.bashrc文件尾,为什么不管用呢?

发表于 : 2008-07-26 12:26
JangMunho
2ine 写了:明白了。。
不过我把PS1="\u@"$hostname"'$' "写入~/.bashrc文件尾,为什么不管用呢?
重新打开终端

发表于 : 2008-07-26 12:37
2ine
重新打开了,也没有出现~
我的方法是这样的:
sudo mousepad ~/.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
[ -z "$PS1" ] && return

# don't put duplicate lines in the history. See bash(1) for more options
export HISTCONTROL=ignoredups
# ... and ignore same sucessive entries.
export HISTCONTROL=ignoreboth

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

# 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) 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
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"'
;;
*)
;;
esac

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

#if [ -f ~/.bash_aliases ]; then
# . ~/.bash_aliases
#fi

# enable color support of ls and also add handy aliases
if [ "$TERM" != "dumb" ] && [ -x /usr/bin/dircolors ]; then
eval "`dircolors -b`"
alias ls='ls --color=auto'
#alias dir='ls --color=auto --format=vertical'
#alias vdir='ls --color=auto --format=long'

#alias grep='grep --color=auto'
#alias fgrep='fgrep --color=auto'
#alias egrep='egrep --color=auto'
fi

# some more ls aliases
#alias ll='ls -l'
#alias la='ls -A'
#alias l='ls -CF'

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi

PS1="\u@"$hostname"'$' "

发表于 : 2008-07-26 12:39
BigSnake.NET

代码: 全选

cp /etc/skel/.* ~/

发表于 : 2008-07-26 12:59
2ine
楼上的命令,有什么意义呢??

发表于 : 2008-07-26 13:03
2ine
又小白了~
才反应过来~/就是自己的家目录。。
不过之前的家目录备份过,发现其中的.bashrc是一样的
那么二楼给的方法,很可能不成立~

发表于 : 2008-07-26 13:25
2ine
顶~

发表于 : 2008-07-26 13:26
BigSnake.NET
2ine 写了:楼上的命令,有什么意义呢??
你自己看看 /etc/skel 就知道

发表于 : 2008-07-26 13:38
2ine
BigSnake.NET 写了:
2ine 写了:楼上的命令,有什么意义呢??
你自己看看 /etc/skel 就知道
这个怎么了~和我原先的文件完全一样
替换后也是那样

发表于 : 2008-07-26 13:41
BigSnake.NET
你的“重构用户”什么意思?

这里已经有 PS1 的设置了

代码: 全选

if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt 

发表于 : 2008-07-26 13:46
2ine
这是个问题。。。
重构用户,就是先userdel再useradd最后usermod

话说楼上那句我也看到了~但是很纳闷的,为什么不加载呢?
难道我RP不好。。

发表于 : 2008-07-26 14:26
2ine
接着顶