Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8633575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:30:51+00:00 2026-06-12T09:30:51+00:00

I try to run the following bash script to create a bunch of users,

  • 0

I try to run the following bash script to create a bunch of users, groups, home dirs for the users and correct permissions for all of these. The OS is CentOS.

When I try to run the following, which I though should work, it returns “command not found” when running via terminal. it only gets as far as creating the /homedirs directory, nothing more. I’m a total noob at bash scripting so forgive me if this looks ugly.

mkdir /homedirs; chmod 775 /homedirs;

for iYear in {1..3} do
    sYear = $iYear"ti"
    sYearDir = "/homerirs/"$sYear
    groupadd $sYear; mkdir $sYearDir; chgrp $sYear $sYearDir; chmod 750 $sYearDir

    for sClass in {a,b} do
        sClassDir = $sYearDir/$sClass
        mkdir $sClassDir
        sClassGrp = $sYear$sClass
        groupadd $sClassGrp; chgrp $sClassGrp $sClassDir; chmod 750 $sClassDir

        for iUser in {1..3} do
            sUserName = "i"$iYear$sClass"g"$iUser
            sUserDir = $sClassDir/$sUserName
            useradd -d $sUserDir -g $sClassGrp -G $sYear -m $sUserName
            chown $sUserName $sUserDir; chmod 750 $sUserDir
        done
    done
done
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:30:52+00:00Added an answer on June 12, 2026 at 9:30 am

    The error message is caused by the spaces around the equals signs. A token with whitespace after it is interpreted as a command name; so what you intended as variable names causes the Command not found errors.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to run the following script in R (minimized example): library(neuralnet) arrhythmia <-
I try to run the following raw query in android, it seems not work
I try to run the following code: public void Init(Url rootUrl) { var web
When I try to run the following SQL snippet inside a cursor loop, set
When I try to run the following code from the REPL (playing with dynamic
When I try to run the following, I get an error back from ActiveRecord
I try to run jsf application in myeclipse using jboss web server and following
When i try and run at server i am getting the following severe error:
I get the following error when I try to run sample example of Google
When I try to run a routine I get the following error: Error Code:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.