Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I log in, appears the following error:

-bash: /etc/profile: line 1: syntax error near unexpected token ('

Inside the file there is the next code:

n# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))\n

# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).\n\nif

[ -d /etc/profile.d ]; then\nfor i in /etc/profile.d/*.sh; do\nif [ -r $i ];

then\n. $i\nfi\ndone\nunset i\nfi\n\nif [ "$PS1" ]; then\nif [ "$BASH" ];

then\nPS1=u@h:w$ \nif [ -f /etc/bash.bashrc ];


/etc/bash.bashrc\nfi\nelse\nif [ "id -u" -eq 0 ];

then\nPS1=# \nelse\nPS1=$ \nfi\nfi\nfi\n\numask

022\nPT5HOME=/opt/pt\nexport PT5HOME

I've searched around on internet but I didn't find something understandable or that matches with my problem (I think), how could fix this, it seems not to trouble anything with the computer, but I'd like to know what it's going on.

share|improve this question
@jw013 that is the way the code is inside the file... – poz2k4444 Sep 17 '12 at 21:06
@jw013 Hope it's ok now – poz2k4444 Sep 17 '12 at 21:08
If that is true, then that is the reason for the error - bash doesn't know what to do with the very garbled formatting. I'd recommend just retyping it. Where did you get this horrendous profile? Did Backtrack really ship with this? – jw013 Sep 17 '12 at 21:12
@jw013 yep, I did not mess up with the file, I reformat a little the code just to see it better, how can I correct it?? – poz2k4444 Sep 17 '12 at 21:18
Replace all the \n with actual newlines and delete the very first n. – jw013 Sep 17 '12 at 21:23
up vote 2 down vote accepted

Fix the formatting, replace the \n by actual newlines and remove the spurious 'n' at the beginning, then it works. Thus:

# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r "$i" ]; then
      . "$i"
  unset i

if [ -n "$PS1" ]; then
  if [ -n "$BASH" ]; then
    PS1='u@h:w$ '
    if [ -f /etc/bash.bashrc ]; then
      . /etc/bash.bashrc
    if [ "`id -u`" -eq 0 ]; then
      PS1='# '
      PS1='$ '
umask 022
export PT5HOME
share|improve this answer
Thanks a lot, it works perfectly, why bash doesn't support \n or why I have to reformat the code? – poz2k4444 Sep 17 '12 at 22:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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