# Root password in term or xterm



## Tbird (Sep 4, 2013)

Hi, I am a newbie, please be gentle. I have just set up FreeBSD 9, then X, then KDE 4. I have set it up so KDE loads automatically. Then in KDE I have started an xterm. It loads with the $ prompt so I type login and try to login as root because I want to install packages and the installs keep failing using the user log in. So at the word login I type root, then enter the root password. It says login incorrect. So several reboots later, and a lot of reading I wonder if my password is too long or some other issue. Back to the manual and I figure out how to change the root password back at the single user login screen. That worked fine. So back into KDE and try xterm. Same message. Are there two places for root passwords? Then I have spent a lot of time looking through forums as I don't not want to waste your time but simply cannot find the solution. Any help please.


----------



## Whattteva (Sep 4, 2013)

Try using su instead of login.


----------



## jrm@ (Sep 4, 2013)

To switch to the root account you can use the su() command (you have to be in the group wheel to switch to the root account with su()).  To run single commands as root, you can install security/sudo.


----------



## ShelLuser (Sep 4, 2013)

Hi there and welcome aboard.



			
				Tbird said:
			
		

> I have started x term. It loads with the $ prompt so I type login and try to login as root because I want to install packages and the installs keep failing using the user log in. So at the word login I type root, then enter the root password. It says login incorrect. So several reboots later, and a lot of reading I wonder if my password is too long or some other issue.


The others already explained how you can circumvent this issue and still obtain root privileges.

I'd like to take it one step further and (try to) explain to you what is happening here because that is in my opinion also important to know.

As you may know the root user (which has uid 0) is a special account; it has _complete_ control over your system. And don't think too lightly of this; one single command while using this account can totally destroy your system.

Therefore it is important to be careful when using this account as well as keep some control over where the account is being used.

And that's where /etc/ttys comes into play. This file does a lot of things; amongst which determine on which (virtual) consoles the root account may login. By default this is on the main console, the virtual consoles ttyv0 to ttyv8, the serial terminals (ttyu0 to ttyu4) and the so called 'dumb' console dcons.

You can check which console you're using by running `tty`.

Now, when I'm logged onto my server (I always use the commandline together with sysutils/tmux) I'm using this one which isn't mentioned in /etc/ttys:


```
smtp2:/home/peter $ tty
/dev/pts/5
smtp2:/home/peter $ grep pts /etc/ttys
smtp2:/home/peter $
```
And that means that I simply cannot login as root while using this console.

So the right approach here, others have already explained as much, is using su or perhaps security/sudo.

Small tip: if you want to 'emulate' a full login as root (meaning so much as: you want your environment (such as your PATH) to be set to that of root) then you should use the `su -` command. If you simply want to obtain root privileges then a mere `su` will suffice.

Hope this gives you some ideas.

Edit:

PS: If you want to know more about those (virtual) consoles then you might want to check out chapter 4.2 of the FreeBSD handbook.


----------



## freethread (Sep 4, 2013)

To make it simple (keeping in mind what @ShelLuser wrote).
Add the user to the wheel group: `$ pw usermod [i]username[/i] -G wheel`, see pw(8) for more information.
Promote to the _root_ user in the shell: `$ su -` and enter the _root_ password.


----------



## Tbird (Sep 4, 2013)

Thanks guys for your responses, that's my homework for tonight. Fantastic.


----------

