Adding users via command line

Hi guys

I have this old laptop 10gb HDD 128mb ram and decided to see if i could get anything running on it eventually after many failures i managed to get Vector Linux installed with LXDE desktop but it’s like swimming through treacle so I decided to use it with openbox and learn some command line

When I installed it i didn’t set up any users so I have to log in as Root so I’m trying to set up a user account preferably with sudo privileges

I’ve tried

useradd graeme

but that doesn’t let me log in because I don’t have a home directory I’ve tried

useradd -m graeme 

that lets me log in with an error message

"Your session lasted less than 10 seconds, if you have not logged out yourself, this could mean that ther is some installation problem or that you may be out of diskspace , try logging in with one of the failsafe sessions to see if you can fix the problem"

Any ideas what I’m doing wrong ?

Graeme

Here’s how I create a new user account (including creating the home folder) and add him to a bunch of groups.

I’m creating an account for username
graeme
(obvioulsy you’ll want to replace “graeme” in the next 2 commands with whatever username you’re creating an account for)

Run:

sudo useradd -s /bin/bash -m graeme -G adm,dialout,fax,cdrom,floppy,tape,sudo,audio,dip,video,plugdev,netdev,fuse,lpadmin,scanner,sambashare

OK, now you need to give that user account a password … run:

sudo passwd graeme

You’ll be prompted for the password twice, then told the password was updated changed

Done :slight_smile:


Hint -

To see which groups your current user belongs to, run:

groups

but remember to enter them as comma seperated values in the useradd command


HTH :slight_smile:

Hi Mark

Thanks for that

I managed to add user via a JWM session (cheating I know but I’ll get there) I want to add myself to lpadmin so I can add my printer in my username I think the command is usermod but I’ll work on that and let you know if I have problems

sudo useradd -s /bin/bash -m graeme -G adm,dialout,fax,cdrom,floppy,tape,sudo,audio,dip,video,plugdev,netdev,fuse,lpadmin,scanner,sambashare

I understand most of your command except “-s /bin/bash” can you tell me what that is doing as I never saw it on any of the tutorials I looked at.

Slightly off topic
This laptop wont run anything with a decent DE even LXDE runs like treacle but Openbox and JWM runs fine, however Openbox shows a different desktop depending on whether i’m in Root or User ie in root there is no wallpaper,desktop icons or panel just an empty screen the menu is invoked by right clicking anywhere on the screen but in my user account I have wallpaper, desktop icons and a panel/menu etc is that normal ?

Graeme

Yeah that’s normal for openbox … you could always copy the openbox configs from your home to the /root directory.


-s /bin/bash

sets the shell for the account … if you miss that out it should get the default SHELL variable from /etc/default/useradd but that quite often reads “/bin/sh” which under certain circumstances can occasionally leave you with a non functional terminal for that account … so I like to specify the shell manually.

If you’re wondering what it’s GUI equivalent is, take a look in Peppermint
menu > System Tools > Users and Groups
highlight a user account and click the “Advanced Settings” button … then the “Advanced” tab … then see the “Shell:” setting

Slightly off-topic - have you considered trying Puppy Linux? It’s very lightweight (pick the Slacko version) with a decent functional GUI. Originally designed to run from USB stick only, more recent versions will allow install to HDD for a proper speed experience.

Slightly off-topic - have you considered trying Puppy Linux?

Yes I did in fact I had Tahrpup running on it and it flew even you tube videos played smoothly I was amazed then for some unknown reason it refused to boot so I thought rather than reinstall it all again I’d try something else, to be honest what I really should do is upgrade the ram and run Peppermint or some other lightweight conventional distro, but I’m just using it for learning for now

Graeme

Crunchbang would have been ideal for this setup, minimal install and fully functional openbox desktop.
When I run it on the AA1 the ram usage was around 60mb, so your 128 would be plenty.
Unfortunately Crunchbang is no more, but a replacement is brewing. Check out Bunsenlabs.
It is based on the Debian 8 (stable) netinstall with scripted install/configuration see here.
If you want to learn some cli along the way then have a go, nowt to lose but gain experience.

Thanks SeZo

I did think about Crunchbang but as you pointed out is no longer and their site is closed down

I’ve never heard of Bunsenlabs but I’ll keep it in mind

At the moment I’m getting on fine with Vector which seems to work best in the JWM window manager even openbox struggles at times, it comes pre-installed with Firefox which just wont run in any of the window managers but it also has Netsurf which is lightening fast but for some reason won’t open localhost:631 it just opens a search page so I’ll probably be back looking for some help with that.

But so far I really like Vector and although it’s not Debian/Ubuntu based it is similar the package manager for example is very alike (slapt-get instead of apt-get) and i expect most terminal commands will be the same throughout most Linux distributions, but there’s a lot to learn and although I’ll never be a command line guru like you and Mark hopefully i can improve

Many thanks

Graeme