LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-13-2012, 01:55 AM   #1
cricketlong
Member
 
Registered: Dec 2008
Posts: 52

Rep: Reputation: 15
Why there is a "command not found" prompt every time I open the Terminal?


the prompt looks like:
bash: $'\357\273\277#': commands not found.

[root@localhost ~]# cat .bashrc
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias vi='vim'

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
 
Old 04-13-2012, 03:36 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,879

Rep: Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317
looks like your prompt settings is not ok.
see http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x279.html
 
Old 04-13-2012, 09:47 AM   #3
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Member response

Hi,

This is a sample setup for both .bashrc & .bash_profile(which is used to source the .bashrc) for users home;
Code:
sample .bash_profile for proper sourcing with users home;
 ~$ cat .bash_profile
#.bash_profile file begins here
 # .bash_profile to source .bashrc
 #08-30-06 12:21
 # Source .bashrc
 if [ -f ~/.bashrc ]; then
         . ~/.bashrc
 fi                     #file ends here
Code:
 sample .bashrc;

 :~$ cat .bashrc
  
 #.bashrc begins here
 #08-30-06 12:20  
  
 # Add bin to path
  
 export PATH="$PATH:/sbin:/usr/sbin:$HOME/bin"
  
 #export PATH="$PATH:$HOME/bin"
  
 # Dynamic resizing
 shopt -s checkwinsize
  
 # Custom prompt
 #PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
 
#08-29-06 11:40
if [ `id -un` = root ]; then
    PS1='\[\033[1;31m\]\h:\w\$\[\033[0m\] '
  else
    PS1='\[\033[1;32m\]\h:\w\$\[\033[0m\] '
fi
 #
 # Add color
 eval `dircolors -b`

 # User defined aliases
 alias cls='clear'
 alias clls='clear; ls'
 alias ll='ls -l'
 alias lsa='ls -A'
 alias lsg='ls | grep'
 alias lsp='ls -1 /var/log/packages/ > package-list'
 alias na='nano'
 alias web='links -g -download-dir ~/ www.google.com'
  
 #08-29-06 11:50
  
 #To clean up and cover your tracks once you log off
 #Depending on your version of BASH, you might have to use
 # the other form of this command
    trap "rm -f ~$LOGNAME/.bash_history" 0
 
#The older KSH-style form
#   trap 0 rm -f ~$LOGNAME/.bash_history
The .bashrc & .bash_profile are very useful for users!
HTH!
 
Old 04-13-2012, 02:54 PM   #4
cricketlong
Member
 
Registered: Dec 2008
Posts: 52

Original Poster
Rep: Reputation: 15
Thanks. but it seems that .bashrc is fine.
I edited my .bashrc:

1 #Cricket .bashrc
2
......

Then I open a new terminal or a new tab in terminal, it prompts:
bash: $'\357\273\277#Cricket': commands not found.

There is nothing to do with the rest content of my .bashrc.
But I don't still know where the first three letters come from.
weird...
 
Old 04-13-2012, 03:29 PM   #5
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Hi,

Quote:
Originally Posted by cricketlong View Post
the prompt looks like:
bash: $'\357\273\277#': commands not found.

[root@localhost ~]# cat .bashrc
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias vi='vim'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
Remove this form your ~.bashrc;
Code:
# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
and place it in ~.bash_profile. So you will be sourcing .bashrc from the users ~.bash_profile.
 
Old 04-17-2012, 05:25 AM   #6
cricketlong
Member
 
Registered: Dec 2008
Posts: 52

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by onebuck View Post
Hi,



Remove this form your ~.bashrc;
Code:
# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
and place it in ~.bash_profile. So you will be sourcing .bashrc from the users ~.bash_profile.
thanks, but I am sure there is nothing to do with these three lines.
 
Old 04-17-2012, 07:26 AM   #7
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Is $PROMPT_COMMAND set?
 
Old 04-19-2012, 06:26 AM   #8
cricketlong
Member
 
Registered: Dec 2008
Posts: 52

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by catkin View Post
Is $PROMPT_COMMAND set?
[root@localhost ~]# echo $PROMPT_COMMAND
printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"
 
Old 04-19-2012, 07:56 AM   #9
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,879

Rep: Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317
I tried the following:
PS1=`bla`, the result was:
bash: bla: command not found

so try to set PS1 to '>' or some simple string....
 
Old 04-19-2012, 09:01 AM   #10
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
The sequence \357\273\277 is the octal representation of the Byte Order Mark of UTF-8 character encoding. Here is a comparative table:
Code:
Hex |       EF        BB        BF
Dec |      239       187       191
Oct |      357       273       277
Bin | 11101111  10111011  10111111
Most likely your terminal is not UTF-8 capable and it tries to interpret these three characters literally. Which terminal are you running? And which (Linux) OS is this? You have two possibilities:

1. make your terminal UTF-8 capable
2. convert all the UTF-8 files to another encoding, e.g. plain ASCII

Another question: what is the output of the following commands?
Code:
echo $PS1 | od -c
echo -e $PS1 | od -c
 
Old 04-20-2012, 04:18 AM   #11
cricketlong
Member
 
Registered: Dec 2008
Posts: 52

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by colucix View Post
The sequence \357\273\277 is the octal representation of the Byte Order Mark of UTF-8 character encoding. Here is a comparative table:
Code:
Hex |       EF        BB        BF
Dec |      239       187       191
Oct |      357       273       277
Bin | 11101111  10111011  10111111
Most likely your terminal is not UTF-8 capable and it tries to interpret these three characters literally. Which terminal are you running? And which (Linux) OS is this? You have two possibilities:

1. make your terminal UTF-8 capable
2. convert all the UTF-8 files to another encoding, e.g. plain ASCII

Another question: what is the output of the following commands?
Code:
echo $PS1 | od -c
echo -e $PS1 | od -c
thanks, I am using gnome-terminal under Fedora 16.
How to make my terminal UTF-8 capable?

Here are the output:
[root@localhost ~]# echo $PS1 | od -c
0000000 [ \ u @ \ h \ W ] \ $ \n
0000015
[root@localhost ~]# echo -e $PS1 | od -c
0000000 [ \ u @ \ h \ W ] \ $ \n
0000015
 
Old 04-20-2012, 06:09 AM   #12
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Quote:
Originally Posted by cricketlong View Post
thanks, I am using gnome-terminal under Fedora 16.
How to make my terminal UTF-8 capable?
It should be already enabled. What is the output of the following?
Code:
locale
I notice you run the commands as root. Does the problem happen as normal user or as root, as well? You should run all the suggested commands as the user whose prompt is
Code:
bash: $'\357\273\277#': commands not found.
Please, use CODE tags around the code you copy/paste from your terminal. To use CODE tags put [CODE] and [/CODE] before and after the code, respectively. Thank you.
 
Old 04-20-2012, 08:41 AM   #13
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by cricketlong View Post
[root@localhost ~]# echo $PROMPT_COMMAND
printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"
That's a strange use of PROMPT_COMMAND. From the GNU bash reference:
Quote:
PROMPT_COMMAND
If set, the value is interpreted as a command to execute before the printing of each primary prompt ($PS1).
It looks as if somebody has set it on your system to provide the prompt.

What happens if you unset it and set a simple PS1 prompt as pan64 suggested:
Code:
unset PROMPT_COMMAND
export PS1='> '
 
Old 04-20-2012, 08:43 AM   #14
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Quote:
Originally Posted by catkin View Post
That's a strange use of PROMPT_COMMAND.
Indeed. However, it is used by the gnome-terminal to set the window title!
 
Old 04-28-2012, 03:14 AM   #15
cricketlong
Member
 
Registered: Dec 2008
Posts: 52

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by colucix View Post
It should be already enabled. What is the output of the following?
Code:
locale
I notice you run the commands as root. Does the problem happen as normal user or as root, as well? You should run all the suggested commands as the user whose prompt is
Code:
bash: $'\357\273\277#': commands not found.
Please, use CODE tags around the code you copy/paste from your terminal. To use CODE tags put [CODE] and [/CODE] before and after the code, respectively. Thank you.
Code:
[root@localhost JRDJ]# locale
LANG=de_DE.UTF-8
LC_CTYPE="de_DE.UTF-8"
LC_NUMERIC="de_DE.UTF-8"
LC_TIME="de_DE.UTF-8"
LC_COLLATE="de_DE.UTF-8"
LC_MONETARY="de_DE.UTF-8"
LC_MESSAGES="de_DE.UTF-8"
LC_PAPER="de_DE.UTF-8"
LC_NAME="de_DE.UTF-8"
LC_ADDRESS="de_DE.UTF-8"
LC_TELEPHONE="de_DE.UTF-8"
LC_MEASUREMENT="de_DE.UTF-8"
LC_IDENTIFICATION="de_DE.UTF-8"
LC_ALL=
This error appears only when I login as root.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] When I type "sudo grub" it says "command not found" in Ubuntu 9.10 Live CD. msbstar Linux - Newbie 10 04-01-2020 11:54 PM
[SOLVED] Errors executing shell script: "command not found" and "no such file or directory" eko000 Linux - Newbie 1 01-14-2011 07:54 AM
LFS6.3 livecd "ls : command not found" error after "su - lfs" rotu Linux From Scratch 2 06-19-2008 03:59 PM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM
"segmentation error" when issuing "useradd" command through terminal with RH 9.0 kaihuang Linux - General 0 10-21-2003 11:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration