Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

logged in as root, environmental variables are great. I typed "set"

I did:

useradd -m alex
su alex

For some reason, everything is gone when I type "set". How do I make it so that alex has all the environmental variables just like root (except as a standard user), when I first logged in?

For example, I want PS1 to be set, just like the root account. All my environmental variables were erased when I created this new user.

**Edit: people are not understanding the question. Right now, "alex" user account is completely blank, with no environmental variables. I just want it to have SIMILAR environmental variables like ROOT. All the directories have no color. The PS1 is just a dollar sign. That's not normal.

share|improve this question

migrated from Nov 11 '09 at 11:45

This question came from our site for professional and enthusiast programmers.

root is root. why do you want to set alex as root?? – user31894 Nov 11 '09 at 11:32
up vote 1 down vote accepted

All your users (assuming you're using bash) will execute /etc/profile on login. You may also need to set up your ~/.profile file. To do that you could copy root's profile or capture the output of (run as root):


and then edit that file to incorporate it into alex's .profile.

share|improve this answer

You want to use su - alex, not su alex.

From man su:

     -, -l, --login  
         make the shell a login shell

The login shell means your shell will process the initial-login scripts properly.

You could do the same thing by logging out and logging back in as your new user.

share|improve this answer
yeah - su with out the - doesn't do what you might otherwise think it would – warren Nov 11 '09 at 13:25

First, check and see what's in /etc/profile.

Next, what shell does your alex user have set in /etc/passwd? Try looking at the appropriate rc file for whichever shell is set - for instance, if using bash, look for the default bashrc file (oftentimes at /etc/bashrc or a similar path). Likewise for other shells and their default startup scripts.

share|improve this answer
+1 just want to add - see about halfway down "Persistent environment variables" – pjc50 Nov 11 '09 at 11:46
good troubleshooting tips but i think this user's trouble is described in teddy's answer. if the trouble persists after a real login, then start with these tips. – quack quixote Nov 11 '09 at 12:17

You don't. Just don't use root for your everyday use. Actually, never login as root. Just use 'sudo' when you need to perform an administrative task.

You may think it's inconvenient and etc, but one day, after you screw up bad, you'll understand. It happens to everyone at some point.

If you need specific environment variables for your user, just set them in your .bash_profile or .bashrc files.

share|improve this answer
not the problem described. (good advice tho.) – quack quixote Nov 11 '09 at 12:14

You can pass a lot more arguments to useradd.

useradd -ms /bin/bash username

This will create a user, its home direrctory and set it's shell to bash (using the default settings stored in /etc/bash.bashrc).

share|improve this answer
Or you can set up defaults in /etc/default/useradd and /etc/skel, if enabled (or similar files). – Dennis Williamson Nov 11 '09 at 14:40

You wanted to use the adduser command.

justin@eee:~$ man useradd|grep DESC -A 1
       useradd is a low level utility for adding users. On Debian, administrators 
       should usually use adduser(8) instead.
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .