0

After messing up the .bashrc and then sourcing it when I was installing ROS, my ubuntu system is ruined. Now the terminal is missing. Doing Ctrl + Alt + T does nothing. No left or top bar. There is nothing but the desktop. I can't even do a right click on the desktop. Everything is missing except for the console, it appears when I do Ctrl + Alt + F1 but I can't exit from it. I have tried the solution posted here but it didn't work.

I'm using ubuntu 14.04.4

  • 3
    Do you remember what you changed in your .bashrc? You should be able to go to the ctrl+alt_f1 terminal, log in, and re-edit your .bashrc to undo the damage. You could also log in as Guest and make sure the rest of the system is operable. – heynnema Jan 20 '17 at 17:51
  • but i can't write commands in the terminal,there is a message that keeps popping up in the terminal saying "return: can only 'return' from a function or sourced script" ,i tried everything to get a new prompt but i couldn't please tell me how get this message to quit – B.andalous Jan 21 '17 at 22:12
  • can i log in from the guest account and make changes in my account, i m refresh to ubuntu – B.andalous Jan 21 '17 at 22:16

2 Answers2

0

If truly all you did was change .bashrc, you can log in via a terminal and fix it. Here is an unaltered .bashrc from 14.04 for you to use.

# ~/.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) 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 ! 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
Organic Marble
  • 23,641
  • 15
  • 70
  • 122
  • 2
    A clean bashrc should also be present at /etc/skel/.bashrc – Kaz Wolfe Jan 20 '17 at 19:09
  • i know what i have added in the .bashrc but i can't stop a message from popping up,i tried everything , Can i change my user accout from guest session?? – B.andalous Jan 22 '17 at 08:35
0

To reset your .bashrc to the default, do the following:

In the ctrl+alt+f1 terminal...

  • pwd # confirm that is shows /home/rayane
  • cd /home/rayane # if the pwd returned the wrong answer
  • pwd # confirm that it now shows /home/rayane
  • mv .bashrc .bashrc.old # rename, note the periods at the beginning of the filenames
  • cp /etc/skel/.bashrc /home/rayane/ # copy a default file, thanks @KazWolfe
  • reboot # reboot and log in normally
heynnema
  • 70,711
  • I can't try your commands because i can't get a new prompt, I tried everything ctrl+C, ctrl+Z even q but i couldn't stop a message from popping up.I can'i post a pic here but this what the message says "out of memorry......; killed process.......; /home/rayane/.bashrc:line1 2524 killed ~/.bashrc; and /home/rayane/.bashrc:line9 return:can only'return' from a function or sourced script. Please can you tell me what to do to be able to type commands again – B.andalous Jan 22 '17 at 08:26
  • At the ctrl+alt+f1 terminal, can you log into root instead of your normal login? If so, the above commands should still work. If not, let me know. Start new comments directed at me with @heynnema or I may miss them. – heynnema Jan 22 '17 at 14:22
  • when doing mv command it tells me No such file or directory and please what did you mean by rename maybe i did the command wrong @heynnema – B.andalous Jan 24 '17 at 20:19
  • You only need to type the commands highlighted in blue. Everything after the # is just a comment for you. When you did the 2nd pwd command, did it return /home/rayane? When you did the mv did you remember to put in the periods? If you still have trouble, edit your answer with copy/paste of the text of the commands that you're entering, and any errors that are printed out, so I can see what's going wrong. – heynnema Jan 24 '17 at 20:44
  • mv: cannot stat ‘/home/rayane/.bashrc’: No such file or directory this is my error, please tell me what to do@ heynnema – B.andalous Jan 26 '17 at 19:53
  • Do all of the commands that I gave you, but skip the mv command. Report back. – heynnema Jan 26 '17 at 19:59