How do I create a new user account on an Ubuntu Hardy server?

2

1

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.

Alex

Posted 2009-11-11T11:29:54.333

Reputation: 1 751

2root is root. why do you want to set alex as root?? – user31894 – 2009-11-11T11:32:24.097

Answers

1

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):

set

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

user53528

Posted 2009-11-11T11:29:54.333

Reputation:

4

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

From man su:

Options:  
     -, -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.

Teddy

Posted 2009-11-11T11:29:54.333

Reputation: 5 504

yeah - su with out the - doesn't do what you might otherwise think it would – warren – 2009-11-11T13:25:29.160

1

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.

Amber

Posted 2009-11-11T11:29:54.333

Reputation: 551

+1 just want to add https://help.ubuntu.com/community/EnvironmentVariables - see about halfway down "Persistent environment variables"

– pjc50 – 2009-11-11T11:46:28.590

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 – 2009-11-11T12:17:47.857

0

You wanted to use the adduser command.

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

user23307

Posted 2009-11-11T11:29:54.333

Reputation: 5 915

0

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.

axel_c

Posted 2009-11-11T11:29:54.333

Reputation: 271

1not the problem described. (good advice tho.) – quack quixote – 2009-11-11T12:14:56.193

0

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).

Mereghost

Posted 2009-11-11T11:29:54.333

Reputation: 592

Or you can set up defaults in /etc/default/useradd and /etc/skel, if enabled (or similar files). – Paused until further notice. – 2009-11-11T14:40:26.897