useradd [ -c comment ] [ -d dir ] [ -e expire ]
[ -f inactive ] [ -g group ] [ -G group [, group...]]
[ -m [ -k skel_dir ]]
[ -u uid [ -o]] [ -s shell ] login
SYNOPSIS
useradd [ -c comment ] [ -d dir ] [ -e expire ]
[ -f inactive ] [ -g group ] [ -G group [, group...]]
[ -m [ -k skel_dir ]]
[ -u uid [ -o]] [ -s shell ] login
OPTIONS
-c comment Any text string. It is generally a short
description of the login, and is currently used
as the field for the user's full name. This
information is stored in the user's /etc/passwd
entry.
-m The user's home directory will be created if it
does not exist.
-d dir The home directory of the new user. It defaults
to base_dir/login, where base_dir is the base
directory for new login home directories and
login is the new login name.
$ id -a uid=0(root) gid=1(other) groups=1(other),0(root),2(bin),3(sys),4(adm),5(uucp),6(mail),7(tty),8(lp),9(nuucp),12(daemon)
$ id -un root
$ id -gn other
-u Output only the effective user ID, using the format
"%u\n".
-g Output only the effective group ID, using the format
"%u\n".
-n Output the name in the format "%s" instead of the
numeric ID using the format "%u".
> > How can I create groups in Unix? I am using SunOS 5.6.
> Edit /etc/group.
Use groupadd is preferable (more abstract) And if you're really desperate on Solaris you can use admintool.
dave
groupadd [-g gid [-o]] group
documented on: 2000.05.11 Thu 16:31:11
*Tags*: new group
For files sharing over different systems, they must at least to have the same group id.
get the client group id (on sunshine)
$ id uid=1001(tong) gid=1001(tong) groups=1001(tong)
create the same group id on the org server (iitrc)
# groupadd -g 1001 tong
# tail /etc/group ... tong::1001:
on source, change umask and create a file
iitrc:~$ umask 006
iitrc:~$ id uid=1006(tong) gid=1001(tong) groups=1001(tong),1(other)
iitrc:~$ touch aaab
on client, see the result
adduser username groupname
and the user username will be added to the group groupname.
Newsgroups: comp.os.linux.misc Date: 2001-01-15 00:50:07 PST
> Is there a shell utility to add a user to a group? I know usmod -G > almost does the job, but instead of adding the user to a group, it > modifies the user's group settings.
ok, after a little playing around, I found the following solution which I think is simple enough:
usermod -G `id -Gn user | tr ' ' ,`,group user
Jim H
> And it has been. In Debian I just type > > adduser username groupname > > and the user username will be added to the group groupname. > > Of course, you could also just run vigr.
Doesn't work that way on Redhat. Didn't know about vigr. Just goes too so no matter how long you use something, there is always something new to learn.
Jim H
newgrp the_group
documented on: 2000.04.14 Fri 10:58:00
Newsgroups: comp.unix.shell
> I want to change the id number for my account, so that every > time I log on, I got this uid number which is my pick. Is it > ok merely change the uid field in /etc/passwd?
This is bad thing to do. Very bad, much too bad, bad, bad.
For one thing, when you create files, your uid is used to determine the owner of the file. This is dereferenced when using the 'ls -l' command - and so you get the actual name as the owner instead of a uid. If there isn't an entry in the passwd file for any uid, an 'ls -l' would display only the uid as the owner.
Furthermore, your uid is used in various places on unix - thus it isn't a good idea to even 're-use' old uid's for new employees.
I don't know of any uid cleanup routines, but it's best to expire old uid's and use new ones.
Can anyone in the ng shed more wisdom on this?
> I changed it by hand. Now my uid=9999(tong) > is there a command to do it? what else > should I change/take into consideration?
I'm getting curious as to why you need to do this in the first place. Anyhow, why not just create another user with the uid of 9999 - as you have root privs anyway.
-l login_name
The name of the user will be changed from login to login_name.
Nothing else is changed. In particular, the user's home
directory name should probably be changed to reflect the new
login name.
-u uid The numerical value of the user's ID.
*Tags*: cmd:passwd expire force new password change at first logon/login
> of the things I want to do is setup new user accounts so the user > has to change their password on thier first login. I cannot seem to
You can do a passwd -f <userid> This forces them to change it.
Force the user to change password at the next login by expiring the password for name.
Date: Mon, 30 Sep 2002 20:29:09 -0700 Newsgroups: comp.os.linux.setup
>For security popurse, I want to diable some user account to login, like >game, mail..., what is a easy way to do it?
Use "passwd -l <username>" where the option "l" (lowercase "L") means account lockout.
Chris
I have most my users' shell /sbin/nologin. That way they can still use their email, but will not get shell access (which for most users is good).
Newsgroups: comp.os.linux.setup Date: Mon, 02 Feb 2004 12:04:26 -0500
> I'm currently in the process of creating a back-up server for our > primary linux system. > > My last sticking point is how best to migrate/copy user accounts. > We're using shadow passwords and what I am wondering is if I can > literally copy and paste entries from the shadow password on the > primary system, into the shadow password file on the back-up system? > My primary aim from this is to enable existing users to log into the > back-up system without having to change their passwords.
(My opinion) Technically a better way to do this is by having a separate NIS (also known as YP) server that maintains all passwords, and telling all machines (incluing the backup server) to authenticate via NIS from the main NIS server.
However back to what you asked. I have done this before. The only key changes I did was to copy all RELEVANT data from:
/etc/shadow /etc/passwd /etc/group
Since passwd contains both /home location and shell information, that information MUST match. ex:
user1:x:500:500:Full Name:/home/user1:/bin/myshell
Directory /home/user1 and /bin/myshell must exist on the new machine.
This is just a starting point. Other files in /etc/ are needed for important system functionality, but these are the minimum I needed to allow access. I hope this helps.
Mauriat