-1

I'm rather new to the whole setting up a server, and hardening a server thing, but I had to start today. I mainly have experience with my ubuntu desktop.

Anyway, I just created a new user, that I intend to use to access the whole website, like this:

As root:

useradd -d /var/www/example.com example
passwd example
... (typing in the pw)

okey. Now, if I try to switch to this user, with

su example

I dont even get a password prompt, but only see a

$

The strange thing is, I apparently dont get a normal commandline like usual, but many things dont work: like syntax highlighting, auto completion with 'TAB', etc - on my ubuntu desktop, I instead get the normal example@...:~# line. What am I doing wrong?

2
  • 1
    Google: /etc/skel.
    – quanta
    Dec 22, 2012 at 13:15
  • You are missing some options that should be used in useradd. Please check the man pages for useradd.
    – mdpc
    Dec 22, 2012 at 16:43

3 Answers 3

3

All is fine sofar. Your new user has a different shell. You can verify with:

echo $SHELL

It is possilbe to change default shell of current user with :

chsh -s /bin/bash

Or with root can change shell of a user :

chsh -s /bin/bash example
1
  • Thank you a lot, worked! I prefer /bin/bash anyway, hehe
    – Katai
    Dec 22, 2012 at 14:37
1

You are not doing anything wrong.

su is essentially an action which creates a shell within your current shell, not so much of switching within the current shell. And depending on the choice of shell being newly loaded now, it will behave differently. This is why when you exit from su, you return to the previous user; you simply exited the inner shell.

Additionally, su will not ask you for password if you do so from root because you are root.

1
  • Thank you, didnt know of that - I always tought it would just switch the user inside the same shell... ah well, still learning ;)
    – Katai
    Dec 22, 2012 at 14:37
0

Some about SU command. If you are logged in as the user's root, you can always become another user without knowing the password. Become a example and stay in the current directory

[root@host ~]#su example

Become a exmaple and go to the user's home directory

[root@host ~]#su - example

Now if you try these commands from a non-privileged user will ask for the password.

What is $? This is shell

For default, in the your operation system used SH (shell wrapper). If you want to use the bash shell, then when the user, specify it:

[root@host ~]# useradd -s /bin/bash exmaple

Not the answer you're looking for? Browse other questions tagged or ask your own question.