I have received a request to add about 100 users in the Linux box, which is already in the LDAP, so I do not use it Point it to new users and on a text file Another admin is taking care of the ldap piece so I just have to do all the Home Directory to be prepared and adding the user to the box once the user gets the right sub To put on Ogkrta. Making directories is not a problem, but I like a more elegant script to chown them to the right user. Which is currently visible to me
chown -R testuser1 testgroup1 / home / tetsuser1; Chown -R Testosterore 2 Testgroup 2 / Home / Testgroup 2; By default I requested that the name of the username and name of the group appeared in pop in Excel, added a column of "chown-r", then added a column of "/" followed by copy and pasted the user name column and then ";" Added a column and dragged from the previous row down to the other. It was run in the Notepad, something quick to find and took place and in less than a minute I have a complete request and a sad empty emotion. I know it was actually a ghetto system and I am trying to stay away from using Excel to avoid learning new scripting techniques, so this is my real question.
tl; Dr I made 100 home directories and pressed them for the right users, but it was ugly, there are real questions below.
You have a file with such a name that looks like this (only 1000 users and actual users and groups can say)
TestSyear 1 TestGroup 1
TestSyear2 TestGroup 2 - testuser3 testgroup1Write a script that creates home directories for all users and maintains the directory created for the right user and group. To create a directory, I used the following (free from flame / also correct me on this.)
var = 'cut -f1 -d' "idlist '(I use the backstrokes apostroops Does not do around the cut command)
mkdir $ var
awk '{System ("MKDIR" $ 1); System ("$ 1" to "1 dollar": "$ 2" "$ 1);}' Idlist
Needed to run under the core privilege of the tested course It does not collect commands for you to perform under Backlit or $ (). It executes them directly.
Edit to add:
If you want to set a script file or as a nickname, if you do something you often do, I suggest, though, you learn awk is a very good little language and really In any Pox-compatible system Guarantee. (I think it is really other than sh in.)
Comments
Post a Comment