星期日 五月 25, 2008

      Solaris OS has a core conception --- user and user account management .User has all of processes and files . If OS has no users,it can not finish data operation and system management. User must has an account to login the system,and he can finish the  prospective work. As Solaris system administrator, it is a key job to manage user and account(there are some conception about user group,but I do not introduce this).


     The loginning name has 8 characters at most. After creating the account, we can :1.start Shell; 2.implement application program ;3.call all kinds of system serveice. User management refer to 3 document: 1./etc/passwd: user acconut information. 2./etc/group:group configuration information; 3./ect/shadow: account password and all kinds of control information. Solaris integrate user account management into SMC,and SMC help administrators manage system and applications.Besides SMC, we can finish management work by command-line.


     1.add user:#useradd -u uid -g gid -d home_directory -s path_to_shell -c comment login_name 


    2 change user account attribute:usermod


    3 delete user:userdel


DEMO 1


add user sun1 and sun2:


#useradd -u 200 -g other -d /export/home/sun1 -m -c "first user" -k /etc/skel sun1


#useradd -u 300 -g other -d /export/home/sun2 -m -s /usr/bin/sh -c "second" sun2


change user UID,and change the password:


#usermod -u 400 sun1


#grep sun1 /etc/passwd


#passwd sun1


change user and user home:


#usermod -d /export/home/sun22 -m -l sun22 sun2


#ls -ld /export/home/sun22


user accuont control strategy,lock and unlock:


#usermod -f 10 -e 12/31/2008 sun1


#passwd -l sun1


#passwd -u sun1


delete user


#userdel -r sun1


DEMO2


create the bulk of user


1.create user list file:userlist.lst    #cat/export/home/userlist.lst


sun1 sun2 sun3


2.create Script file:adduser.sh,#cat/export/home/adduser.sh


for i in 'cat/export/home/userlist.lst'
                          do
                            useradd -d /export/home/$i -m $i
                          done


#chmod u+x /export/home/adduser.sh


3.run script file:#./export/home/adduser.sh


The end !Thank you very much!


 

评论:

Thanks for that scripting example - it's really nice to see basic examples on these blogs for the newbies learning
how to do stuff. SMC doesn't appear to be in OpenSolaris 2008.05, and I've been wanting to find a way of adding multiple
users from a file. :)

发表于 Dave 在 2008年05月25日, 01:09 下午 CST #

发表一条评论:
  • HTML语法: 禁用