LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-16-2010, 06:55 PM   #1
nasridine
Member
 
Registered: Jan 2010
Posts: 52

Rep: Reputation: 15
what happen to my shell


I don't remember what I did. But this afternoon, when I log on to the machine, none of the commands works, ls, top, cd, ssh, nothing. Has this happened to anyone before and what could be the reason? Thanks in advance.
 
Old 02-16-2010, 07:02 PM   #2
nasridine
Member
 
Registered: Jan 2010
Posts: 52

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by nasridine View Post
I don't remember what I did. But this afternoon, when I log on to the machine, none of the commands works, ls, top, cd, ssh, nothing. Has this happened to anyone before and what could be the reason? Thanks in advance.
what's weirder is that those terminals I opened earlier which have been not logged out still works. Only if I open up a new terminal and ssh to that machine, it is doing that.
 
Old 02-16-2010, 07:20 PM   #3
Refractor
Member
 
Registered: Oct 2008
Location: Rousse, Bulgaria
Distribution: Slackware
Posts: 89

Rep: Reputation: 24
Hello, nasridine!
Could you please post the results of
Code:
 echo $PATH
from one of the old terminals and a newly opened one.
 
Old 02-16-2010, 07:41 PM   #4
nasridine
Member
 
Registered: Jan 2010
Posts: 52

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Refractor View Post
Hello, nasridine!
Could you please post the results of
Code:
 echo $PATH
from one of the old terminals and a newly opened one.
The old one

/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/opt/apbs/bin:/usr/NX/bin:/home/nasridine/bin:/sbin:/home/nasridine/tinker5:/home/nasridine/software/tinker-bin:/home/nasridine/gdma-2.2.01/bin:/usr/local/src/amber10/bin:/home/nasridine/bin:/sbin:/home/nasridine/tinker5:/home/nasridine/software/tinker-bin:/home/nasridine/gdma-2.2.01/bin:/usr/local/src/amber10/bin:/home/nasridine/software/apbs-1.2-ia32/bin

The new one

/home/nasridine/bin:/sbin:/home/nasridine/tinker5:/home/nasridine/software/tinker-bin:/home/nasridine/gdma-2.2.01/bin:/usr/local/src/amber10/bin:/home/nasridine/software/apbs-1.2-ia32/bin

The path printed out with the new terminal is exactly what I have in .bash_profile.

So I added what is missing to the bash_profile and it works now.

That reminds me that I was messing with the path thing as root earlier, but I don't remember deleting anything. I looked /etc/profile and couldn't find the path /opt/apbs/bin. Where else could it be?
 
Old 02-16-2010, 07:43 PM   #5
r3sistance
Senior Member
 
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,133

Rep: Reputation: 97
Are you sure "cd" failed? it is a built-in shell function for bash so that command should not have failed from a path issue.

Also are you sure you didn't make any accidental edits and saved them by mistake?

Last edited by r3sistance; 02-16-2010 at 07:46 PM.
 
Old 02-16-2010, 07:53 PM   #6
Refractor
Member
 
Registered: Oct 2008
Location: Rousse, Bulgaria
Distribution: Slackware
Posts: 89

Rep: Reputation: 24
/etc/profile 's content in different distributions is different, but I know that it sets the general program paths ( /usr/local/bin:/usr/bin:/bin:/usr/games ). For custom tweaks in the PATH environment I use ~/.bashrc and ~/.bash_profile.
The path /opt/apbs/bin is not a standard Linux path, so you can't expect to find it in the default bash settings. My advice is to always keep the PATH starting in the order /usr/local/bin:/usr/bin:/bin:/opt/bin:YOUR_PATHS_HERE, unless you know what you're doing. And by the way, if you want/need to tweak root's PATHs, use /root/.bash_profile and /root/.bashrc.
Hope this answers your question.

EDIT: Perhaps when you tweaked the PATH as root earlier, you erased the initial content by using
Code:
 PATH=/your/path/here
or
Code:
 export PATH=/your/path/here
This will erase any content from $PATH and register only your path in it. To avoid this you can always use
Code:
 export PATH=$PATH:/your/path/here
This will append your path to the existing value of $PATH.

Last edited by Refractor; 02-16-2010 at 07:57 PM.
 
Old 02-16-2010, 07:59 PM   #7
nasridine
Member
 
Registered: Jan 2010
Posts: 52

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by r3sistance View Post
Are you sure "cd" failed? it is a built-in shell function for bash so that command should not have failed from a path issue.

Also are you sure you didn't make any accidental edits and saved them by mistake?
I noticed that I added another path at the bottom of /etc/profile and export it. Maybe it overwrites the other paths in the file?

As for "cd" I can't remember, maybe you are right.
 
Old 02-16-2010, 08:01 PM   #8
nasridine
Member
 
Registered: Jan 2010
Posts: 52

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Refractor View Post
/etc/profile 's content in different distributions is different, but I know that it sets the general program paths ( /usr/local/bin:/usr/bin:/bin:/usr/games ). For custom tweaks in the PATH environment I use ~/.bashrc and ~/.bash_profile.
The path /opt/apbs/bin is not a standard Linux path, so you can't expect to find it in the default bash settings. My advice is to always keep the PATH starting in the order /usr/local/bin:/usr/bin:/bin:/opt/bin:YOUR_PATHS_HERE, unless you know what you're doing. And by the way, if you want/need to tweak root's PATHs, use /root/.bash_profile and /root/.bashrc.
Hope this answers your question.

EDIT: Perhaps when you tweaked the PATH as root earlier, you erased the initial content by using
Code:
 PATH=/your/path/here
or
Code:
 export PATH=/your/path/here
This will erase any content from $PATH and register only your path in it. To avoid this you can always use
Code:
 export PATH=$PATH:/your/path/here
This will append your path to the existing value of $PATH.
You are absolutely right, that was exactly what I did.

So in case this happens again and I do not have any old terminals open, what should I do to fix it?
 
Old 02-16-2010, 08:07 PM   #9
Refractor
Member
 
Registered: Oct 2008
Location: Rousse, Bulgaria
Distribution: Slackware
Posts: 89

Rep: Reputation: 24
You can use
Code:
 source /etc/profile
to load the default bash settings or you could use
Code:
 export PATH=/usr/local/bin:/usr/bin:/bin:$PATH
to add the essential programs to your PATH. By the way, even if the standard programs are not in your path, you can still invoke them with the full path to the program, for example you can use /bin/ls ( or /usr/bin/ls depending on your distro ) to invoke the ls command even if /bin ( or /usr/bin ) is not in your PATH.
 
Old 02-16-2010, 08:08 PM   #10
nasridine
Member
 
Registered: Jan 2010
Posts: 52

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Refractor View Post
You can use
Code:
 source /etc/profile
to load the default bash settings or you could use
Code:
 export PATH=/usr/local/bin:/usr/bin:/bin:$PATH
to add the essential programs to your PATH. By the way, even if the standard programs are not in your path, you can still invoke them with the full path to the program, for example you can use /bin/ls ( or /usr/bin/ls depending on your distro ) to invoke the ls command even if /bin ( or /usr/bin ) is not in your PATH.
Thanks a lot. That was very helpful!
 
Old 02-16-2010, 08:10 PM   #11
r3sistance
Senior Member
 
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,133

Rep: Reputation: 97
I would advise possibly remembering that vi is usually easily locatable at "/bin/vi", then just pull up the file you edited to cause the problem in the first place.

Or whatever other editor you prefer using, nano I believe is at /usr/bin/nano if you prefer that... but it depends. /bin/vi is the best one to remember for emergency purposes.

Last edited by r3sistance; 02-16-2010 at 08:11 PM.
 
Old 02-17-2010, 12:08 AM   #12
nasridine
Member
 
Registered: Jan 2010
Posts: 52

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by r3sistance View Post
I would advise possibly remembering that vi is usually easily locatable at "/bin/vi", then just pull up the file you edited to cause the problem in the first place.

Or whatever other editor you prefer using, nano I believe is at /usr/bin/nano if you prefer that... but it depends. /bin/vi is the best one to remember for emergency purposes.
Very good advice, thanks.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
how does a rpm build happen + shell script help sailu_mvn Linux - Software 38 07-21-2006 03:40 AM
How can this happen? jacki Linux - Certification 1 07-17-2006 10:04 AM
What will actually happen if i issue rm -rf / in Shell? hkl8324 General 7 06-27-2005 11:35 PM
what do you think would happen if.... blitzen Linux - Hardware 1 04-17-2004 09:53 AM
Why does this happen? BajaNick General 1 09-09-2003 11:33 PM


All times are GMT -5. The time now is 09:07 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration