Link to home
Start Free TrialLog in
Avatar of Pampa
Pampa

asked on

Profiles, Very easy!!!

I'am new in Linux, I'am using RedHat 6.0.

I create a file .profile in the default user directory.

When I start a session with the username None of the things I insert in the .profile works.  

How should I do this?

PD 2:
How can I make a default profile so the new users can use it?, or I have to copy the /etc/profile manually?
       
Avatar of ahoffmann
ahoffmann
Flag of Germany image

> I create a file .profile in the default user directory.
Then you have to login with the user who uses this directory.

> When I start a session with the username None of the things I insert in the .profile works.
A lot of possible reasons:
  - you have not source this .profile
  - you errors in this .profile
  - you use a shell which does not understand .profile (but probably .cshrc)

> .. or I have to copy the /etc/profile manually?
NO
simply make shure that the user uses a shell (see /etc/passwd) which understands .profile, like sh, ksh
then create a ~/.profile as you like
Avatar of bcoleman
bcoleman

if you are using bash the profile file should be called .bash_profile in the users default directory.
The file "/etc/profile" is a global file and should work for all users.  The file ".bash_profile" in the user's home directory is for that specific user.  If you are modifying the "profile" file in the "/etc" check to be sure you have set the path correctly for any programs you are trying to run.  You would be best off to specify the full path for each command you give.  To easily find the full path type "whereis command".  For example to find the full path of the mount command, type "whereis mount".  What commands are you running?  Can you give a sample of commands you are trying, that are not working?
hmm, hope you all know the differences between .profile, .bash_profile, .bash_login etc.
*and* you know when, and in which order they are called. Hope you also know which shell uses which of these resource files.
Also beware of trusting commands like whereis and which, they are giving just hints, which might be the truth, sometimes ...

Pampa, you need yourself make used to user profiles. Otherwise you may get confused about what you want to achieve.
Are your users login in from a console, or is there a GUI for login (xdm). Second, as mentioned before, you need to know which is the login shell, and where are the home directories (both see /etc/passwd)
Then we may give more detailed suggestions.
To answer the first part of your question, it all depends on what commands you are trying to run at login.  Most commands are started from .bashrc (IE: alias commands and initializing ls colors).  To answer the second part, there is a directory called /etc/skel/ this directory is what the adduser commands uses to create new users so any file in this directory will be copied to the new users directory.
Avatar of Pampa

ASKER

sfurr:
I'am using bash so the first question was answered with bcoleman comment.

About the second question:
I couldn't find the directory you told me "/etc/skel"

ahoffmann says about it:
"simply make shure that the user uses a shell (see /etc/passwd) which understands .profile, like sh, ksh "

I SAW THE /etc/passwd AND POINTS TO BASH

"then create a ~/.profile as you like"

I DO NOT UNDERSTAND THIS COMMENT PLEASE I NEED AN "SPECIFIC" EXPLANATION ABOUT THIS POINT.

Do I have to modify the etc/profile and this would work for every new user???

>  I'am using bash so the first question was answered with bcoleman comment.
> "then create a ~/.profile as you like"
Ok, it's bash, please read man bash 'cause bash has the most complicated algorithm which resource files are read.
I highly recommend that you
  1'st read man bash
  2'nd remove all .profile .bash* .login .cshrc etc. from the users home dir
  3'rd create new ones
(see my last comment too)

> Do I have to modify the etc/profile and this would work for every new user???
i.g. NO
Just do this if you realy know what you're doing, and what you whant to achieve (as newbie, as you said in your question, I highly recommend to leave the files in /etc untouched !!)

If  you get your changes working, I can give you hints how to make it work for several different users.
bcoleman had the right answer the first time.  You needed to modify the .bash_profile in the user's home directory.  You were making your own .profile in the user's home directory.
The /etc/profile affects every user on the system and every shell type.  The .bash_profile when put in the default user directory will be the new users profile whenever you create a new user.  If you or they want to edit thier/your individual profile they will need to edit /home/<username>/.bash_profile
This file will affect only them/you.
ASKER CERTIFIED SOLUTION
Avatar of ahoffmann
ahoffmann
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Pampa

ASKER

I would like to accept ahoffman answer.