adduser username
useradd username
Story:
######## Stage 1. Stuck & Confused ############
I'm was trying to set up my Rackspace server and I ran into some questions during my created user account.
From root, I added a user with "useradd alice". When I discovered that
~/
failed, I had to sudo mkdir /home/alice.Q0: It's so strange that the user home dir has to be manually created
Then I logged in as alice, but found that the prompt is not customized and lacks color. Since useradd copied /etc/skel/.bashrc from root to alice, I thought that I can just "cp /etc/skel/.bashrc ~/.bashrc", but when I did that (with sudo), "echo $PS1" still shows the old original prompt settings.
Q1: How come the ~/.bashrc, identical in root and user alice, does not work in alice?
I even uncommented out "force_color_prompt=yes", but its still not working.
Q2: How come user alice needs sudo to edit ~/.bashrc in the first place when its permissions are (from ls -l):
alice@simba:~$ ls -l ~/.bashrc
-rw-r--r-- 1 root root 141 2011-10-20 05:19 /home/alice/.bashrc
Answer: Because the user and group of /home/alice/.bashrc are both set to "root" (The user is the one that matters here)
Then I tried to "sudo chown alice:alice ~/.bashrc", but was denied permission because I was on alice.
######### Stage 2. Found good resource ############
Then I read this informative article and learned:
useradd -D
shows the defaults of useradd. You can change the shell to bash by specifying useradd -D -s /bin/bash
. Then you can use useradd alice
followed by passwd alice
to set its password. BUT!! This still doesn't automatically make /home/alice for you######## Stage 3. Problems solved! ################
adduser alice
worked beautifully0: home dir created automatically :D
1: bashrc and xterm-color both work :D
2: home dir's files are automatically made with alice as the user
# adduser alice Adding user `alice' ... Adding new group `alice' (1001) ... Adding new user `alice' (1001) with group `alice' ... Creating home directory `/home/alice' ... Copying files from `/etc/skel' ... Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully Changing the user information for alice Enter the new value, or press ENTER for the default Full Name []: Alice P Hacker Room Number []: Work Phone []: Home Phone []: Other []: Is the information correct? [Y/n] y... Why does it care about the room number? haha
No comments:
Post a Comment