LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 07-26-2019, 02:32 AM   #1
weewee
LQ Newbie
 
Registered: Jul 2019
Posts: 3

Rep: Reputation: Disabled
Need a default .bash_profile file


Dear All,
I am new to Linux and I am using Linux mint 18.2 Sonya. While trying to save an environment variable, I overwrote my .bash_profile file instead adding to it. I would appreciate it if anyone can help me
recover the default content of this file. If you are still using the default .bash_profile file, please, kindly share.
Thanks.
 
Old 07-26-2019, 04:03 AM   #2
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by weewee View Post
If you are still using the default .bash_profile file, please, kindly share.
There is no real default .bash_profile, although mint may have added one. Look into /etc/skel to see if there's one there (those are the default files "useradd" add to each user's home directory, after creating it).
A minimal one that works for me is
Quote:
test -r ~/.bashrc && . ~/.bashrc
to add any aliases etc that are in your .bashrc

Last edited by ehartman; 08-06-2019 at 05:32 AM.
 
Old 07-26-2019, 04:13 AM   #3
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
/etc/profile
/etc/skel/*

For things that get added when a new user is created. A good place to start to revert to "defaults". Or to update your defaults should they have changed with an upgrade after your user was created. Otherwise fresh installs on linux take less than an hour in a lot of cases. Another source of something to copy.
 
Old 07-26-2019, 08:04 PM   #4
mrmazda
LQ Guru
 
Registered: Aug 2016
Location: SE USA
Distribution: openSUSE 24/7; Debian, Knoppix, Mageia, Fedora, others
Posts: 5,810
Blog Entries: 1

Rep: Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067
I just upgraded an old 17.3 installation to 18, then to 18.2. Its ordinary user had and has no .bash_profile, and no apparent need for one, same as for superuser, and /etc/skel/. For most users, .bash_profile is an optional file, not missed if not present.
 
Old 08-01-2019, 11:55 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
It may vary somewhat for different distros, but on my Centos 7
Code:
# .bash_profile

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

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH
HTH
 
Old 08-04-2019, 10:33 AM   #6
FlinchX
Member
 
Registered: Nov 2017
Distribution: Slackware Linux
Posts: 666

Rep: Reputation: Disabled
lifehack: create another user, see if it has a default .bash_profile
 
1 members found this post helpful.
Old 08-04-2019, 08:37 PM   #7
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,326
Blog Entries: 28

Rep: Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142
In case it helps, here is the /etc/profile from my Slackware 14.2 install:

Code:
$ cat /etc/profile
# /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
I also have a small customize ~/.bashrc to customized my BASH prompt:

Code:
 $ cat .bashrc
PS1="\u@\H \W/ \$ "
 
Old 08-05-2019, 11:41 AM   #8
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by weewee View Post
I overwrote my .bash_profile file instead adding to it. I would appreciate it if anyone can help me
recover the default content of this file. If you are still using the default .bash_profile file, please, kindly share.
Thanks.
You could try adding a new user on your system. Copy that new account's .bash_profile (if one is created for that account).

I assume that you must have forgotten one of the ">"s and "replaced" rather than "appended" when you thought you were issuing "cat >> .bash_profile". (Most people have done this by accident when they were in a hurry and didn't see that missing character before hitting 'Return'.) Personally, I would never try to append something to my .bash_profile (or .profile or .bashrc) using that command. Use a text editor to make additions/changes to these files. Make a backup copy of them before editing (or use an editor like Emacs that does this for you). Use RCS, Subversion, or Git to keep a history of your important files.

Is it necessary to mention the importance of regular backups?

If your home directory is on a btrfs filesystem, you might be able to find a "pre-corruption" version of the file in a filesystem snapshot.

HTH...
 
Old 08-05-2019, 06:30 PM   #9
Lysander666
Senior Member
 
Registered: Apr 2017
Location: The Underearth
Distribution: Ubuntu, Debian, Slackware
Posts: 2,178
Blog Entries: 6

Rep: Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470Reputation: 2470
Here's mine, it gives you user@host and also colours in your terminal for different folders and files.

Code:
case "$TERM" in
xterm*|rxvt*)
    PS1='\u@\h:\w\$ '
    ;;
*)
    ;;
esac

alias ls='ls --color=auto'
Attached Thumbnails
Click image for larger version

Name:	Screenshot_2019-08-06_00-34-40.png
Views:	65
Size:	88.5 KB
ID:	31037  

Last edited by Lysander666; 08-05-2019 at 06:33 PM.
 
Old 08-06-2019, 04:27 AM   #10
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Nice, maybe we should have a "Show us your .bash_profile" thread.

As far as OP is concerned: weewee hasn't even logged in in 10 days.
 
1 members found this post helpful.
Old 08-14-2019, 05:43 AM   #11
weewee
LQ Newbie
 
Registered: Jul 2019
Posts: 3

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ondoho View Post
Nice, maybe we should have a "Show us your .bash_profile" thread.

As far as OP is concerned: weewee hasn't even logged in in 10 days.

Apologies for my poor follow-up. I have been following the responses without logging in.
There is no need for any "show us your .bash_profile" thread - for now at least.
When I overwrote my .bash_profile file, my terminal lost its color effects. Everything went plain.
I just copied the content of ".profile" file and transferred it to my ".bash_profile" file. Everything seems fine for now. I guess I didn't even much on my former .bash_profile file. I haven't had any issues so far.
Thanks, everyone.
 
1 members found this post helpful.
Old 08-14-2019, 05:50 AM   #12
weewee
LQ Newbie
 
Registered: Jul 2019
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thumbs up

Quote:
Originally Posted by frankbell View Post
In case it helps, here is the /etc/profile from my Slackware 14.2 install:

Code:
$ cat /etc/profile
# /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
I also have a small customize ~/.bashrc to customized my BASH prompt:

Code:
 $ cat .bashrc
PS1="\u@\H \W/ \$ "


Thanks for this. It's exactly what I wanted to see.
 
Old 08-14-2019, 06:43 AM   #13
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Fedora, OpenSUSE, FreeBSD, OpenBSD, macOS (hack). Past: Debian, Arch, RedHat (pre-RHEL).
Posts: 1,335
Blog Entries: 7

Rep: Reputation: 402Reputation: 402Reputation: 402Reputation: 402Reputation: 402
Quote:
Originally Posted by mrmazda View Post
I just upgraded an old 17.3 installation to 18, then to 18.2. Its ordinary user had and has no .bash_profile, and no apparent need for one, same as for superuser, and /etc/skel/. For most users, .bash_profile is an optional file, not missed if not present.
Just FYI, every user does not need an rc or profile, as most distro will have a system wide config: https://www.gnu.org/software/bash/ma...tup-Files.html
zsh IIRC follows as well
 
Old 08-14-2019, 01:28 PM   #14
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Thanks for reporting back, weewee.
Please mark your thread SOLVED now.
 
Old 08-14-2019, 04:45 PM   #15
permaroot
Member
 
Registered: Aug 2019
Location: Arden, NC
Distribution: Arch Linux
Posts: 129

Rep: Reputation: 48
This is definitely a good thing. You just learned to create a backup before editing/manipulating important files!

cp .bash_profile .bash_profile.bak
 
  


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
problem setting up gcc. I think I need to find the bash_profile file? Taylrl Linux - Newbie 5 11-14-2011 11:47 AM
need to change oracle .bash_profile from root user ? shipon_97 Linux - Enterprise 1 08-09-2007 01:27 PM
need root .bashrc .bash_profile darkRoom Slackware 5 04-30-2005 03:24 AM
need .bash_profile example true_atlantis Slackware 2 02-07-2004 06:27 PM
Deleted the /root/.bash_profile, looking for default bparke Linux - Newbie 4 11-19-2003 06:12 PM

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

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