我一直在尝试在 Eclipse 上安装 Android 开发人员工具,并按照此视频中的信息进行操作。
正如视频所说,我在.bashrc
文件中添加了以下两行代码:
export PATH=$(PATH):-/android-sdk/tools/
export PATH=$(PATH):-/android-sdk/platform-tools/
Run Code Online (Sandbox Code Playgroud)
然而,这似乎并没有帮助我在 Eclipse 上安装 Android 文件,因为我仍然遇到问题。更何况,现在好像我不能在终端中发出任何命令而不出现重大错误!每次我尝试在终端中执行命令时,都会收到以下消息:
无法定位该命令,因为 PATH 环境变量中未包含“/usr/bin”。
有没有办法恢复.bashrc
到默认值?
sou*_* c. 144
理念:有存在的备份副本.bashrc
,.profile
等等。在/etc/skel/
。因此,人们可以.bashrc
简单地通过从那里进行机智来替换腐败者。
注意: 如果您用新的.bashrc
文件替换该文件,它将删除您对其所做的任何其他修改。例如,一个可以添加别名,自定义函数或PATH在.bashrc
。当您替换文件时,所有这些修改都将丢失。更好的是,您可以.bashrc
在替换之前保留修改后的副本。稍后,您可以小心地从中提取所需的部分。要.bashrc
在您的主目录中使用名称保留修改后的备份副本,请my_bashrc
在终端中使用以下命令,
/bin/cp ~/.bashrc ~/my_bashrc
Run Code Online (Sandbox Code Playgroud)
为什么/bin/cp
:如果您$PATH
在更改时弄乱了变量,则~/.bashrc
所有可执行文件都将无法从您的终端使用,并且cp
不再起作用。因此cp
,/bin/cp
当您尝试复制带有腐败的内容时,建议使用其完整路径进行调用~/.bashrc
。
最后,在终端中使用以下命令将 替换~/.bashrc
为新副本,
/bin/cp /etc/skel/.bashrc ~/
Run Code Online (Sandbox Code Playgroud)
它会~/.bashrc
用一个新的来取代你的腐败。之后,您需要获取源~/.bashrc
以便立即进行更改,在终端中写入,
. ~/.bashrc
Run Code Online (Sandbox Code Playgroud)
或者,
source ~/.bashrc
Run Code Online (Sandbox Code Playgroud)
或者,如果这不起作用,您可以关闭终端并再次打开它。
mur*_*uru 10
.bashrc
根据需要进行编辑。/etc/skel
,按CtrlH显示隐藏文件。复制.bashrc
到您的主文件夹以将其恢复为默认值。gedit .bashrc
,然后按Enter。根据需要进行编辑。/bin/cp /etc/skel/.bashrc ~/
给出的命令将其恢复为默认值。打开终端,忽略你没有外壳。去编辑?偏好?简介:
创建新配置文件或编辑当前配置文件以更改命令:
使用/bin/bash --norc
或/bin/bash --rcfile=/etc/skel/.bashrc
。
使用自定义命令运行 SSH,这应该可以帮助您绕过.bashrc
:
ssh -t <host> dash
Run Code Online (Sandbox Code Playgroud)
该dash
外壳(又名/bin/sh
)是最小的,但足以恢复.bashrc
。
启动到恢复模式(如何启动到恢复模式?),这将为您提供一个 root shell。查找/home
您用户的主目录。
通过 TTY
您可以通过按ctrl+ alt+输入 TTY f1,您必须使用您的用户名和密码登录。ctrl+ alt+f7将带给你回到你的GUI版本。
现在,复制现有的原料.bashrc
从/etc/skel
通过到你的home目录
cp /etc/skel/.bashrc ~/
Run Code Online (Sandbox Code Playgroud)
如果您不确定自己.profile
是否也已更改,甚至可以将其余部分带过来。
cp /etc/skel/.profile ~/
Run Code Online (Sandbox Code Playgroud)
现在要.bashrc
立即生效,您可能希望使用以下方法获取它:
source ~/.bashrc
Run Code Online (Sandbox Code Playgroud)
如果您确实更换了您的.profile
,则需要重新启动才能使其生效。
我尝试了上述答案,但由于某种原因,我的/etc/skel/
目录中没有正确的文件。
我在Mario Bonales 的 GitHub Gist~/.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
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace
# 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
# 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*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# 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 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 ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
Run Code Online (Sandbox Code Playgroud)