The terminal shows this when it opens:

bash: /home/atlas/.bashrc: line 73: syntax error near unexpected token `['
bash: /home/atlas/.bashrc: line 73: `if [ -x /usr/bin/dircolors ] ; then '

I've tried to fix it using:

cp /ect/skel/.bashrc ~/

And I get this:

cp: cannot stat `/ect/skel/.bashrc': No such file or directory

I'm unsure of why this is doing this and how to fix it. I had previously been in the .bashrc file messing around and apparently I've messed something up. All I want to do is to restore the .bashrc file to default settings.

5 Answers 5


I think you got the path wrong - it's etc not ect.

In Ubuntu, there is a default version of the .bashrc file in the /etc/skel/ directory, so if you have problems with it you can restore it.

To do so follow the next steps:

  1. Backup your current .bashrc file:

    cp ~/.bashrc ~/.bashrc.bak
  2. Copy the skeleton .bashrc file over yours:

    cp /etc/skel/.bashrc ~/
  3. Afterwards, load the new one:

    source ~/.bashrc
  • 4
    this answer should be marked as correct.
    – llt
    Jun 20, 2013 at 6:23
  • i accidently remove contents of bashrc. +1 for fixed my issue. Feb 11 at 3:54

Copy the contents of https://gist.github.com/marioBonales/1637696/raw/337f7b60d4e3d9e887a0206dec6a737e94cdd26e/.bashrc

to ~/.bashrc. You can use a text editor such as gedit for this.


You don't necessarily need to recreate it, just look at what the error message is telling you. It's saying that you have a syntax error in your file. With what you have, I'd say it's incorrect in key places.

Instead of

if [ -x /usr/bin/dircolors ] ; then

It should be

if [ -x /usr/bin/dircolors ]; then

Note the lack of space between the ] and the ;.

Also, for reference, here's that whole if block:

# 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 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'
  • 2
    That space shouldn't actually matter. The command if [ -x /usr/bin/dircolors ] ; then echo yay; fi outputs yay for me ;) Note the space between ] and ;. Sep 18, 2014 at 8:48

Just search if you have a .bashrc.save at your home folder: ls -la ~/ If yes, remove the corrupted .bashrc file and copy the .save file to a new .bashrc:

cd  ~/
rm .bashrc
cp .bashrc.save .bashrc

WSL Ubuntu solution

This solution takes advantage of a very cool piece of software that has been developed for WSL. I assume your ~/.bashrc file istoast, and you have WSL. If either of my two assumptions are incorrect stop reading; this isn't going to work for you.

  1. First off you are going to need, GWSL, (aka Windows Subsystem Server for Linux). The GWSL server connects Windows to the Linux distro, and gives access to the Linux file system.

    Below is what the menu should look like when you open it up from the task-view buttons on the right side of the taskbar (assuming you have your taskbar located in its default location at the bottom of your desktop).

    enter image description here

  2. Just hit the Linux files button, then select the distro you are using (assuming you have more than one distro to choose from, for 99% of people this will be Ubuntu, or Debian.). If it is the first time I have used the GWSL server in a while, sometimes it will make me select from a 3 menu, where there is another Files option (it didn't pop-up for me this time, so note that its called files something).

    Below is an image of a screenshot taken from my desktop. Your filesystem should like like this.

    IMPORTANT: Make note of the file-path in the Windows filebrowser

    NOTE: The file path should be to the distro that you deleted your ~/.bashrc file from. If it's not, you're going to be fixing (or breaking) a distro, that was never broken in the first place, and you're going to have to do this twice.

    enter image description here

  • I forgot the arrow on this one, but you want to open the etc folder — which is the same as the /etc/... directory when your navigating the file-system from the file-system from a native terminal using your shell, (bash in this case).
  1. Once you pop etc open, open the folderskel. Again, this is the equivalent to etc/skel/.... This directory is copied each time a new user is added to the system, it keeps a defaultly configured ~/.bashrc file, because every user needs one, which is why you're doing this, because you no longer have one.

    Don't just double-click the /etc/skel/.bashrc file. Read step 4 first.

  2. Like I said above, you should see a .bashrc file. right-click it, and open it with an editor. I like to use VS Code personally. It should pop up right as day if you followed the instructions correctly. DON'T EDIT IT, OR COPY & PASTE IT YET.

  3. Go back to your Windows file-navigation window that you opened up your Linux filesystem in, and navigate back to your distros home directory, mine reads \\wsl$\Ubuntu-20.04, if you use the general Ubuntu distro it should read \\wsl$\Ubuntu.

    NOTE: Depending you have Windows configured the path may look different, but when you copy and past it, it should look like the paths I just posted (remember we're in Windows now, so we are using backslashes, rather than forward slashes).

    From your distro's base directory — which in Linux would be a simple forward slash / — open the folder home (in Linux this is /home).

    You should see a folder with the name of your user, open it.

  4. You should now be in \\wsl$\Ubuntu-20.04\home\$YOUR_USER_NAME (obviously $YOUR_USER_NAME is not literal semantics, and should be replaced w/ "your user name".) I have learned over time, that sometimes these small things need to be said, for those with less experience, so I apologize to the experienced users looking for a quick solution.

    Once you're in \\wsl$\Ubuntu-20.04\home\$YOUR_USER_NAME right-click and hover over new in the right-click menu. It should open another menu where you can select a file type select a file type (I select text), any file works, we're going to get rid of the extension anyway. After creating the new file, name it .bashrc, then open it.

    Last but not least:

    Copy and paste the contents from the editor into your new .bashrc file, and you're done.

  • I know I need to edit this, I have some grammatical errors, I am tired, and will do a full edit in the morning. If someone does come along and edit this, thank you for helping. Its hard writing good thorough answers, and editing each others posts makes stack exchange network a much better place to offer solutions, and find solutions.
    – j D3V
    Nov 5, 2021 at 4:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.