2013-12-22 73 views
0

我試圖將PATH導出到/etc/bash.bashrc文件,但我添加了一些無效的標識符。現在我無法從終端訪問諸如ls,nano,vi,gedit等程序,這就是爲什麼無法更正/etc/bash.bashrc文件的原因。如何在這種情況下編輯它?謝謝!搞砸「/etc/bash.bashrc」無法再編輯

+2

問題可能屬於http://superuser.com/ – BroSlow

+0

我不知道。謝謝!下次會照顧。 – Vaib

回答

1

在我的Ubuntu的納米節目直播中的/ usr/bin中。所以,你可以嘗試

$ sudo /usr/bin/nano /etc/bash.bashrc 
$ sudo /usr/bin/vi /etc/bash.bashrc 
+0

謝謝大家!這種方法有效,但我現在有一個不同的問題。現在,即使刪除了所有包含該文件的行後,這些命令仍然不起作用(沒有完整的路徑)。我應該備份原始文件,但我沒有。你認爲我可以得到該文件的副本嗎?或以其他方式解決這個新問題?再次感謝! – Vaib

+1

你的bashrc的副本?只要把你當前的那個移動到其他地方去備份它並執行'mv /etc/skel/.bashrc〜/ .bashrc && source〜/ .bashrc' – BroSlow

+0

我很感謝這裏的所有人爲他們提供的幫助。當我更正了/etc/bash.bashrc文件並重新啓動時,這些命令開始工作(沒有提供完整的路徑)。 – Vaib

0

你可以在命令行上指定像

$ /usr/bin/nano /etc/bash.bashrc 

完整路徑這樣,你可以拉起來nano和編輯。

1

你可以做兩件事情之一:

1)用vi的完整路徑,編輯/etc/bash.bashrc文件:

/usr/bin/vi /etc/bash.bashrc 

2)更正命令行上的路徑,然後修復:

export PATH=... 
vi /etc/bash.bashrc 
0

您還可以嘗試運行/bin/sh以獲得「標準」shell。

1
$ cat /etc/bash.bashrc 
# System-wide .bashrc file for interactive bash(1) shells. 

# To enable the settings/commands in this file for login shells as well, 
# this file has to be sourced in /etc/profile. 

# If not running interactively, don't do anything 
[ -z "$PS1" ] && return 

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

# 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, overwrite the one in /etc/profile) 
PS1='${debian_chroot:+($debian_chroot)}\[email protected]\h:\w\$ ' 

# Commented out, don't overwrite xterm -T "title" -n "icontitle" by default. 
# If this is an xterm set the title to [email protected]:dir 
#case "$TERM" in 
#xterm*|rxvt*) 
# PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"' 
# ;; 
#*) 
# ;; 
#esac 

# enable bash completion in interactive shells 
#if ! shopt -oq posix; then 
# if [ -f /usr/share/bash-completion/bash_completion ]; then 
# . /usr/share/bash-completion/bash_completion 
# elif [ -f /etc/bash_completion ]; then 
# . /etc/bash_completion 
# fi 
#fi 

# sudo hint 
if [ ! -e "$HOME/.sudo_as_admin_successful" ] && [ ! -e "$HOME/.hushlogin" ] ; then 
    case " $(groups) " in *\ admin\ *) 
    if [ -x /usr/bin/sudo ]; then 
    cat <<-EOF 
    To run a command as administrator (user "root"), use "sudo <command>". 
    See "man sudo_root" for details. 

    EOF 
    fi 
    esac 
fi 

# if the command-not-found package is installed, use it 
if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then 
    function command_not_found_handle { 
      # check because c-n-f could've been removed in the meantime 
       if [ -x /usr/lib/command-not-found ]; then 
      /usr/lib/command-not-found -- "$1" 
        return $? 
       elif [ -x /usr/share/command-not-found/command-not-found ]; then 
      /usr/share/command-not-found/command-not-found -- "$1" 
        return $? 
     else 
      printf "%s: command not found\n" "$1" >&2 
      return 127 
     fi 
    } 
fi 
+0

謝謝!儘管我無法嘗試,但重啓機器解決了我的問題。 – Vaib

+0

它很高興在這裏有這個,我用這幾次來替換我的舊服務器上的「缺失」,這是從哪裏來的(也就是'uname -a + bash --version'的輸出)有助於 :) – osirisgothra