Why is the .bash_profile not created?

I am trying to install the oracle 10g software. Before running Oracle Universal Installer, I need to prepare the oracle user's environment. So I first created following accounts and groups:

groupadd netman
groupadd dba

useradd -g dba -G netman -d /oracle/oracle -m -s /bin/bash oracle
useradd -g netman -G dba -m -d /opt/netadmin -s /bin/bash netadmin

After creating, I need to edit the oracle user's login file on the database server so that the environment will be configured automatically on login. The users should be "orcale" and "netadmin" I just created. The login file should be ".bash_profile". However, in either user's login directory, I could not find the ".bash_profile" file. What I have found are the following files:


The ".profile" is supposed for Bourne or Korn shell. Also what are the three local files for?
Who is Participating?
TintinConnect With a Mentor Commented:
local.cshrc and local.login are the default templates for csh, you'd need to remove the 'local' from the filename to make them active (for csh/tcsh).

Same deal for local.profile, but for sh, ksh and bash.
bash will use .profile if it exists, but it will prefer .bash_profile, so if you have both, it will use .bash_profile only

So just use .profile

You can also add ORACLE config params into /etc/profile so it is global to the system, if that works for your policies, it usually works for me. I set ORACLE_SID, ORACLE_HOME, PATH and LD_LIBRARY_PATH globally and only need to do it once. Typically any users with logins to my Oracle servers will need the oracle config.

Otherwise, if you have custom profiles you want useradd to make use of, create it under /etc/skel and useradd will copy it to the new user directory (assuming you used -m option)

You can also use -k in conjunction with -m, if you want to maintain multiple skeletons (DBA vs NON-DBA users)

useradd -m -k /etc/skel_dba ...

useradd -m -k /etc/skel_nondba ...

Then you can use separate profiles under each that will get copied depending on which skeleton you specify. This is really overkill if you just have a small system.

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

gs_kanataAuthor Commented:
The ".profile" file did not exist as the new created home directory was not there before creation. I deleteed the user "oracle" with command "userdel -r oracle" to make sure that its home directory removed as well. Then I created it again, but it is same, there is no ".base_profile".
osintsevConnect With a Mentor Commented:
When your create a new account everythign in the skeleton directories is copied to user's homedir. This is why you have all the default login environment files.

The skeleton path on most systems is /etc/skel. By default, a set of initialization files for each of the shells are copied from the /etc/skel directory into a user account's $HOME directory and renamed, list of these files are not dependent on the user's shell you specify with useradd.

local.cshrc, local.login and local.profile files are templates, you can delete them without any consequences.
I assume that was a typo and you meant .bash_profile instead of .base_profile

You are correct, useradd won't create .bash_profile default.  You need to do it manually or put it into /etc/skel or a unique skeleton directory as shown by mrjoltcola.
Did you try my suggestion? useradd will copy whatever is in /etc/skel, and it does on most Linux systems by default, out of the box. If it does not do this on your system, likely it was removed, or it is a distribution with which I am not familiar.

ls -la /etc/skel

Does this show .bash_profile? If not, please try the suggestion, create /etc/skel/.bash_profile and put your content in it, then test useradd again. I am positive it will create the .bash_profile in the new user after this.

Clarification, every recent Linux system in past years I have setup has /etc/skel/.bash_profile
you can find .bash_profile in the /home/oracle

and you can see it after showing the hidden files
As far as I can see, the system is similar to Sun Solaris, so the existence of /etc/skel/.bash_profile by default for me is not so obvious.
What is your operating system?
.absh_profile is present only on Linux, for others it is usually .profile
@osintsev: Good point, I had to re-read the thread to find how I assumed Linux was the OS. I don't know where I got Linux from, I'm sure I glanced at the zones and "saw" Linux, but now after re-reading, I see it is not, and I also see the OP did not say, and I injected that bit myself.

My apologies. So I still contend the solution is the same, but not that it is obvious. If the OP wants .bash_profile created, he creates on in the skel, or works with .profile.

When I've used the GNU add-on CDs or built bash manually for other OSes (Solaris, AIX) I just use .profile. I suppose using .bash_profile is good for using extended syntax that bourne might not handle?
Actually there are parts of ksh syntax bash is not good at. It is better to keep it simple on any system if you ever have to change.
I prefer pdksh - autocomplete, history, and standard syntax.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.