LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 10-02-2017, 02:36 AM   #1
Kai Lee
LQ Newbie
 
Registered: Oct 2017
Posts: 2

Rep: Reputation: Disabled
Corrupted bash profile - want to reset


Hi,
I was trying to set python path,
and I think I accidentally misplaced an export command
currently my terminal begins like this

Last login: Mon Oct 2 16:28:18 on ttys000
-bash: export: `/abin': not a valid identifier
-bash: PYTHONPATH: command not found
export: Command not found.
export: Command not found.

can I get some help?
Can I reset the bash profile /profile/ bashrc to go back to the beginning?
 
Old 10-02-2017, 02:56 AM   #2
jsbjsb001
Senior Member
 
Registered: Mar 2009
Location: Earth, unfortunately...
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881

Rep: Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063
Quote:
Originally Posted by Kai Lee View Post
Hi,
I was trying to set python path,
and I think I accidentally misplaced an export command
currently my terminal begins like this

Last login: Mon Oct 2 16:28:18 on ttys000
-bash: export: `/abin': not a valid identifier
-bash: PYTHONPATH: command not found
export: Command not found.
export: Command not found.

can I get some help?
Can I reset the bash profile /profile/ bashrc to go back to the beginning?
Unless you have made a backup copy of your bashrc file, the only other way I can think of to restore it would be;

Load/Install a copy of the *same* Linux distro into a virtual machine and copy the bashrc file from that, to your 'real' system.

Best of luck with it.
 
Old 10-02-2017, 03:29 AM   #3
!!!
Member
 
Registered: Jan 2017
Location: Fremont, CA, USA
Distribution: Trying any&ALL on old/minimal
Posts: 997

Rep: Reputation: 381Reputation: 381Reputation: 381Reputation: 381
Welcome to LQ!!! Try the -vx shell switches, to debug what exactly is happening.

Can you post the relevant exerpt from whatever file you changed? (http://termbin.com may help post info)
 
Old 10-02-2017, 03:35 AM   #4
aragorn2101
Member
 
Registered: Dec 2012
Location: Mauritius
Distribution: Slackware
Posts: 567

Rep: Reputation: 301Reputation: 301Reputation: 301Reputation: 301
Hi, welcome to LQ,

Please just post a copy of your bash profile here using the CODE construct and we will certainly be able to help you better. Make sure you give precisions about the file. Is it the system-wide profile in /etc or is it your home profile?
 
Old 10-02-2017, 05:14 AM   #5
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,452

Rep: Reputation: 1061Reputation: 1061Reputation: 1061Reputation: 1061Reputation: 1061Reputation: 1061Reputation: 1061Reputation: 1061
-bash: indicates it is the login shell and that primarily reads .bash_profile if present, otherwise .profile.
Some Linux vendors put something in the system-wide /etc/profile that includes .bashrc, so this might be used secondary.

Last edited by MadeInGermany; 10-02-2017 at 05:15 AM.
 
Old 10-02-2017, 08:06 AM   #6
Kai Lee
LQ Newbie
 
Registered: Oct 2017
Posts: 2

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by aragorn2101 View Post
Hi, welcome to LQ,

Please just post a copy of your bash profile here using the CODE construct and we will certainly be able to help you better. Make sure you give precisions about the file. Is it the system-wide profile in /etc or is it your home profile?
I cannot open my bash_profile using nano command, and when I try to open on finder, it just shows few lines, which I don't think is the whole part

it only shows

if [-f ~/.bashrc]; then
source ~/.bashrc
fi

when I do echo $PATH it shows double path, like this

[Cogs-iMac:~] coglab% echo $PATH
$ath:/Users/coglab/abin:/Users/coglab/abin
 
Old 10-02-2017, 08:14 AM   #7
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 20,226

Rep: Reputation: 6834Reputation: 6834Reputation: 6834Reputation: 6834Reputation: 6834Reputation: 6834Reputation: 6834Reputation: 6834Reputation: 6834Reputation: 6834Reputation: 6834
if you want to restore the "official" default - you may try to create another user and use that .bashrc.
But it looks like your PATH variable is not set properly, you need to fix only that.
 
Old 10-02-2017, 08:33 AM   #8
michaelk
Moderator
 
Registered: Aug 2002
Posts: 24,368

Rep: Reputation: 5457Reputation: 5457Reputation: 5457Reputation: 5457Reputation: 5457Reputation: 5457Reputation: 5457Reputation: 5457Reputation: 5457Reputation: 5457Reputation: 5457
Which file did you originally modify .bash_profile or .bashrc?

Obviously it depends on the distribution but your looks normal. Below is the default .bash_profile from CentOS. As posted the system wide defaults are located in /etc and user specific environment is defined in your ~/.bash_profile.
Without knowing exactly what you did to mess things up try logging out and back in.

Code:
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
	. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
 
Old 10-02-2017, 11:48 AM   #9
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051
Quote:
Originally Posted by michaelk View Post
Which file did you originally modify .bash_profile or .bashrc?
that is the crucial question.
there's also a few more files that might be responsible, e.g. ~/.profile
and all 3 files mentioned have systemwide counterparts in /etc.
 
Old 10-02-2017, 01:13 PM   #10
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 4,716

Rep: Reputation: 2191Reputation: 2191Reputation: 2191Reputation: 2191Reputation: 2191Reputation: 2191Reputation: 2191Reputation: 2191Reputation: 2191Reputation: 2191Reputation: 2191
The original versions of files that get installed when your account is created are typically found in /etc/skel.
 
Old 10-02-2017, 01:47 PM   #11
!!!
Member
 
Registered: Jan 2017
Location: Fremont, CA, USA
Distribution: Trying any&ALL on old/minimal
Posts: 997

Rep: Reputation: 381Reputation: 381Reputation: 381Reputation: 381
Hi again....have faith: the LQ'ers will 'get you there'; we just need to find out what got changed, out of the several files involved in logging-in. (Feel free to web-research for the sequence.) Which distro? MacOS?

IF your shell 'lost' its path, you can explicitly run cmds with their full path, like:
/usr/bin/nano (or /bin/cat; there's also sbin) (or maybe MacOS doesn't have nano)

If your internet is working, you can use that 'pipe to nc port 9999'
(cmd1;cmd2;...)|netcat termbin.com 9999, to just post 4char (link)

Those 'code' tags keep $:path :P smileys away. Unix is case-sensitive.

Look for relevant file that has: abin plus another 'typo' in it, around where ?you? (or py?) put abin (maybe; is abin a typo?)

Last edited by !!!; 10-02-2017 at 02:07 PM.
 
Old 10-02-2017, 01:59 PM   #12
urbanwks
Member
 
Registered: Sep 2003
Distribution: Slackware64-Current, FreeBSD 12.1, Alpine 5.4, Manjaro 19, Alpine on WSL [Win10]
Posts: 194

Rep: Reputation: 213Reputation: 213Reputation: 213
Just want to point out that OP appears to be using a Mac/OS X. Granted, bash and these config files should work roughly the same way (I know they have for me), but for more specific support you might want to reach out to a Mac forum, or at the very least a BSD forum... just in case your problem has something to do with OS X and not bash specifically.
 
Old 10-02-2017, 04:15 PM   #13
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,452

Rep: Reputation: 1061Reputation: 1061Reputation: 1061Reputation: 1061Reputation: 1061Reputation: 1061Reputation: 1061Reputation: 1061
Quote:
Originally Posted by Kai Lee View Post
I cannot open my bash_profile using nano command, and when I try to open on finder, it just shows few lines, which I don't think is the whole part

it only shows

if [-f ~/.bashrc]; then
source ~/.bashrc
fi

when I do echo $PATH it shows double path, like this

[Cogs-iMac:~] coglab% echo $PATH
$:path:/Users/coglab/abin:/Users/coglab/abin
If this is your .bash_profile, then the code does include your .bashrc
I.e.you must look at your .bashrc to find more(most) code.

Last edited by MadeInGermany; 10-02-2017 at 04:39 PM.
 
Old 10-03-2017, 03:20 AM   #14
aragorn2101
Member
 
Registered: Dec 2012
Location: Mauritius
Distribution: Slackware
Posts: 567

Rep: Reputation: 301Reputation: 301Reputation: 301Reputation: 301
Quote:
Originally Posted by Kai Lee View Post
I cannot open my bash_profile using nano command, and when I try to open on finder, it just shows few lines, which I don't think is the whole part

it only shows

if [-f ~/.bashrc]; then
source ~/.bashrc
fi

when I do echo $PATH it shows double path, like this

[Cogs-iMac:~] coglab% echo $PATH
$ath:/Users/coglab/abin:/Users/coglab/abin
Normally your home bash_profile will be at ~/.bash_profile. As you see, from your investigation, it sources ~/.bashrc. So look in that direction. If .bashrc sources another script, follow the lead until you find out what line from which file specifically is breaking your PATH variable.
 
  


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
a way to reset main profile to blank but keep everything else ? Shadowmeph Linux - Newbie 8 03-23-2016 03:16 PM
Ubuntu Login Profile Corrupted cannot use ROOT as guest Cocolate Linux - Desktop 2 07-08-2015 03:42 PM
serial communication reset /etc/profile wowy Programming 4 04-30-2015 02:16 AM
Help me to reset user profile sittings ? rahuldevalone Linux - Enterprise 1 10-09-2007 01:19 PM
help me in User profile reset. rahuldevalone Linux User Groups (LUG) 3 10-09-2007 12:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:02 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