2. Shell Programming Exercise II

Source: Internet
Author: User

Design a shell program, add a new group to Class1, and then add 30 users belonging to this group, the user name in the form of Stdxx, where xx from 01 to 30



!#/bin/bashgroupadd class1 for i in {1..30}do   if [  $I  -le 9 ];then  UN=stu0${I}  else    UN=stu${I}   fi  useradd  $UN   mkdir /home/$UN   chown -R  $UN  / home/$UN   chgrp -r class2 /home/$UN  done#!/bin/sh i=1  groupadd  class1  while [  $i  -le 30 ]  do  if [ $ i -le 9 ] ;then      username=stu0${i}  else       username=stu${i}  fi     useradd $ username     mkdir /home/$USERNAME      chown -r   $USERNAME  /home/$USERNAME      chgrp -r class1 /home/$ username  i=$ (($i + 1))    done 


This article is from the "Itgeshen" blog, make sure to keep this source http://itgeshen.blog.51cto.com/11646497/1912336

2. Shell Programming Exercise II

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.