LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Arch
User Name
Password
Arch This Forum is for the discussion of Arch Linux.

Notices


Reply
  Search this Thread
Old 09-17-2011, 02:05 PM   #1
kasl33
Member
 
Registered: Oct 2004
Location: USA
Distribution: Ubuntu-Server, Mac OS X, Arch Linux
Posts: 356

Rep: Reputation: 48
Problems in bash


I'm not sure what happened, but here's the situation:

All of a sudden, my bash prompts are giving me wierd messages and commands are not being found. Here is the message I get when I su - to become root:

Code:
[kris@myhost ~]$ su -
Password: 
-bash: n#: command not found
-bash: thennfor: command not found
-bash: dontest: command not found
-bash: thenn.: command not found
[root@myhost ~]#
Now if I try to load a kernel module, here's the message I get:

Code:
[root@myhost ~]# modprobe coretemp
-bash: modprobe: command not found
[root@myhost ~]#
This seems to have happened after I added a few aliases to my .bashrc file (for only my user - not root):

Code:
#
# ~/.bashrc
#

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

PS1='[\u@\h \W]\$ '

alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias pacman='pacman-color'
alias sudo='sudo '
I tried commenting them all out and logging out/in but that didn't help.

Here is my user's path:
Code:
[kris@myhost ~]$ echo $PATH
/bin:/usr/bin
Here is root's path:
Code:
[root@myhost ~]# echo $PATH
/usr/ucb:/bin:/usr/bin:/etc
Now that I'm looking at root's path, I'm noticing /usr/ucb and have ABSOLUTELY NO IDEA how that got there. So I change it to /usr/sbin:/bin:/usr/bin:/etc by doing this command:
Code:
PATH="/usr/sbin:/bin:/usr/bin:/etc"
export PATH
Now I echo $PATH:
Code:
[root@myhost ~]# echo $PATH
/usr/sbin:/bin:/usr/bin:/etc
Now I try to modprobe coretemp and get "command not found." So I check my $PATH again and it looks fine (until I exit the root account and then su back to the root account - then it becomes /usr/ucb again). The modprobe command (among many others) still doesn't work though. I know there's a file somewhere to change this but I forget which one... I tried grep -i "/usr/ucb" / and it didn't find it.

What the heck is going on? Is this a bug in a recent update? Everything WAS fine after a fresh install...

Last edited by kasl33; 09-17-2011 at 02:08 PM.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 09-17-2011, 03:26 PM   #2
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
There is something wrong with root's .bashrc, .bash_profile, or .profile.
 
Old 09-17-2011, 03:44 PM   #3
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
modprobe is in /sbin, add that to your root's path.
 
2 members found this post helpful.
Old 09-17-2011, 03:56 PM   #4
kasl33
Member
 
Registered: Oct 2004
Location: USA
Distribution: Ubuntu-Server, Mac OS X, Arch Linux
Posts: 356

Original Poster
Rep: Reputation: 48
Quote:
Originally Posted by AlucardZero View Post
There is something wrong with root's .bashrc, .bash_profile, or .profile.
Here is root's .bashrc (which is unmodified and I copied from the /etc/skel directory:
Code:
#
# ~/.bashrc
#

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

alias ls='ls --color=auto'
PS1='[\u@\h \W]\$ '
Here is .bash_profile:
Code:
#
# ~/.bash_profile
#

[[ -f ~/.bashrc ]] && . ~/.bashrc
 
Old 09-17-2011, 06:50 PM   #5
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
Code:
grep dontest ~/.*
gives you what? as root and as your normal user
 
Old 09-17-2011, 06:58 PM   #6
kasl33
Member
 
Registered: Oct 2004
Location: USA
Distribution: Ubuntu-Server, Mac OS X, Arch Linux
Posts: 356

Original Poster
Rep: Reputation: 48
Quote:
Originally Posted by AlucardZero View Post
Code:
grep dontest ~/.*
gives you what? as root and as your normal user
Um... absolutely nothing for either. What is dontest?
 
Old 09-17-2011, 10:15 PM   #7
kasl33
Member
 
Registered: Oct 2004
Location: USA
Distribution: Ubuntu-Server, Mac OS X, Arch Linux
Posts: 356

Original Poster
Rep: Reputation: 48
I believe I may have found the problem. I looked in /etc/profile (glad I finally remembered where to look) and the file has a bunch of jibberish. Here is what the file looks like (no line spacing, escaped newline characters, etc:

Code:
\n# /etc/profile\n\n#Set our umask\numask 022\n\n# Set our default path\nPATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"\nexport PATH\n\n# Load profiles from /etc/profile.d\nif test -d /etc/profile.d/; then\nfor profile in /etc/profile.d/*.sh; do\ntest -r "$profile" && . "$profile"\ndone\nunset profile\nfi\n\n# Source global bash config\nif test "$PS1" && test "$BASH" && test -r /etc/bash.bashrc; then\n. /etc/bash.bashrc\nfi\n\n# Termcap is outdated, old, and crusty, kill it.\nunset TERMCAP\n\n# Man is much better than us at figuring this out\nunset MANPATH\nPT5HOME=/usr/local/PacketTracer5\nexport PT5HOME
Would anybody be willing to paste the contents of their /etc/profile file so I can see the difference - as well as replace mine? I'd be greatful!
 
Old 09-18-2011, 02:14 AM   #8
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
This is from Slackware 13.37, but it should be somewhat similar on Arch.
Code:
# /etc/profile: This file contains system-wide defaults used by
# all Bourne (and related) shells.

# Set the values for some environment variables:
export MINICOM="-c on"
export MANPATH=/usr/local/man:/usr/man
export HOSTNAME="`cat /etc/HOSTNAME`"
export LESSOPEN="|lesspipe.sh %s"
export LESS="-M"

# If the user doesn't have a .inputrc, use the one in /etc.
if [ ! -r "$HOME/.inputrc" ]; then
  export INPUTRC=/etc/inputrc
fi

# Set the default system $PATH:
PATH="/usr/local/bin:/usr/bin:/bin:/usr/games"

# For root users, ensure that /usr/local/sbin, /usr/sbin, and /sbin are in
# the $PATH.  Some means of connection don't add these by default (sshd comes
# to mind).
if [ "`id -u`" = "0" ]; then
  echo $PATH | grep /usr/local/sbin 1> /dev/null 2> /dev/null
  if [ ! $? = 0 ]; then
    PATH=/usr/local/sbin:/usr/sbin:/sbin:$PATH
  fi
fi

# I had problems with the backspace key using 'eval tset' instead of 'TERM=',
# but you might want to try it anyway instead of the section below it.  I
# think with the right /etc/termcap it would work.
# eval `tset -sQ "$TERM"`

# Set TERM to linux for unknown type or unset variable:
if [ "$TERM" = "" -o "$TERM" = "unknown" ]; then
 TERM=linux
fi

# Set ksh93 visual editing mode:
if [ "$SHELL" = "/bin/ksh" ]; then
  VISUAL=emacs
#  VISUAL=gmacs
#  VISUAL=vi
fi

# Set a default shell prompt:
#PS1='`hostname`:`pwd`# '
if [ "$SHELL" = "/bin/pdksh" ]; then
 PS1='! $ '
elif [ "$SHELL" = "/bin/ksh" ]; then
 PS1='! ${PWD/#$HOME/~}$ '
elif [ "$SHELL" = "/bin/zsh" ]; then
 PS1='%n@%m:%~%# '
elif [ "$SHELL" = "/bin/ash" ]; then
 PS1='$ '
else
 PS1='\u@\h:\w\$ '
fi
PS2='> '
export PATH DISPLAY LESS TERM PS1 PS2

# Default umask.  A umask of 022 prevents new files from being created group
# and world writable.
umask 022

# Notify user of incoming mail.  This can be overridden in the user's
# local startup file (~/.bash.login or whatever, depending on the shell)
if [ -x /usr/bin/biff ]; then
 biff y 2> /dev/null
fi

# Append any additional sh scripts found in /etc/profile.d/:
for profile_script in /etc/profile.d/*.sh ; do
  if [ -x $profile_script ]; then
    . $profile_script
  fi
done
unset profile_script

# For non-root users, add the current directory to the search path:
if [ ! "`id -u`" = "0" ]; then
 PATH="$PATH:."
fi
 
1 members found this post helpful.
Old 09-18-2011, 10:19 AM   #9
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
"dontest" is part of the gibberish you were getting when powering up to root.

Found it in your /etc/profile:
Code:
do\ntest
So your /etc/profile is indeed corrupted.
 
Old 09-18-2011, 02:55 PM   #10
kasl33
Member
 
Registered: Oct 2004
Location: USA
Distribution: Ubuntu-Server, Mac OS X, Arch Linux
Posts: 356

Original Poster
Rep: Reputation: 48
Quote:
Originally Posted by AlucardZero View Post
"dontest" is part of the gibberish you were getting when powering up to root.

Found it in your /etc/profile:
Code:
do\ntest
So your /etc/profile is indeed corrupted.
Gotcha - makes sense now. Thanks!

Quote:
Originally Posted by TobiSGD View Post
~ [/etc/profile code]
I suppose Slackware is a BSD style distribution and that it should work. I'll try it. If it doesn't work out, I realized I could just go to Archbang's website and get a config file from them; they post them for people whose files break. I'm using regular Arch but it should work.
 
Old 09-18-2011, 03:12 PM   #11
kasl33
Member
 
Registered: Oct 2004
Location: USA
Distribution: Ubuntu-Server, Mac OS X, Arch Linux
Posts: 356

Original Poster
Rep: Reputation: 48
Okay I used the Slackware file and it obviously works, but if anybody has an Arch or Archbang /etc/profile file, I would appreciate it if you would paste it in here. Different distro's do have their differences.
 
Old 09-18-2011, 03:38 PM   #12
kasl33
Member
 
Registered: Oct 2004
Location: USA
Distribution: Ubuntu-Server, Mac OS X, Arch Linux
Posts: 356

Original Poster
Rep: Reputation: 48
I feel like a jackass. the "echo -e" command came to the rescue (Thanks to Karol at Arch Forums):

Code:
echo -e "\n# /etc/profile\n\n#Set our umask\numask 022\n\n# Set our default path\nPATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"\nexport PATH\n\n# Load profiles from /etc/profile.d\nif test -d /etc/profile.d/; then\nfor profile in /etc/profile.d/*.sh; do\ntest -r "$profile" && . "$profile"\ndone\nunset profile\nfi\n\n# Source global bash config\nif test "$PS1" && test "$BASH" && test -r /etc/bash.bashrc; then\n. /etc/bash.bashrc\nfi\n\n# Termcap is outdated, old, and crusty, kill it.\nunset TERMCAP\n\n# Man is much better than us at figuring this out\nunset MANPATH\nPT5HOME=/usr/local/PacketTracer5\nexport PT5HOME"
Outputted the correct formatting:

Code:
# /etc/profile

#Set our umask
umask 022

# Set our default path
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
export PATH

# Load profiles from /etc/profile.d
if test -d /etc/profile.d/; then
for profile in /etc/profile.d/*.sh; do
test -r  && . 
done
unset profile
fi

# Source global bash config
if test [\u@\h \W]\$  && test /bin/bash && test -r /etc/bash.bashrc; then
. /etc/bash.bashrc
fi

# Termcap is outdated, old, and crusty, kill it.
unset TERMCAP

# Man is much better than us at figuring this out
unset MANPATH
PT5HOME=/usr/local/PacketTracer5
export PT5HOME
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Bash Problems - Random Headers when starting bash in X androidd Slackware 3 01-13-2011 04:29 PM
Two Bash problems David the H. Linux - General 9 03-14-2006 01:44 PM
Bash and ls problems wapcaplet Linux - Software 2 01-19-2004 03:44 PM
bash problems tobymiller Programming 2 01-28-2003 09:18 PM
BASH problems subnet_rx Linux - General 3 11-17-2001 03:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Arch

All times are GMT -5. The time now is 10:33 AM.

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