How to add users from text file into the unix system?
up vote
-1
down vote
favorite
I have a homework that require creating text file of users in unix and then reading each line of the file and actually adding them to the system?
How can this be done?
what i have done:
https://i.stack.imgur.com/G2LAK.png
however it's not working.
server syslinux
|
show 4 more comments
up vote
-1
down vote
favorite
I have a homework that require creating text file of users in unix and then reading each line of the file and actually adding them to the system?
How can this be done?
what i have done:
https://i.stack.imgur.com/G2LAK.png
however it's not working.
server syslinux
2
Homeworks are off topic here ;)
– Kulfy
Nov 22 at 12:08
Hint: you need to learn how to create a text files. What information about the user is there in the file? How to read file, a.k.a file handling? How to create new user through the command line?
– Kulfy
Nov 22 at 12:12
I thought so hard about this and still cant get how to change user (as a text) into an actual system user!
– user895829
Nov 22 at 12:16
Store into a variable and use that variable say $user
– Kulfy
Nov 22 at 12:22
4
I have seen other homework problems receive favorable responses - the difference is that the person asking the question has shown the work that they have already done, and is asking what they are doing wrong, rather than asking "how to do this". Can you amend your question with what you have already tried?
– Charles Green
Nov 22 at 16:42
|
show 4 more comments
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I have a homework that require creating text file of users in unix and then reading each line of the file and actually adding them to the system?
How can this be done?
what i have done:
https://i.stack.imgur.com/G2LAK.png
however it's not working.
server syslinux
I have a homework that require creating text file of users in unix and then reading each line of the file and actually adding them to the system?
How can this be done?
what i have done:
https://i.stack.imgur.com/G2LAK.png
however it's not working.
server syslinux
server syslinux
edited Nov 22 at 19:31
asked Nov 22 at 12:08
user895829
2
Homeworks are off topic here ;)
– Kulfy
Nov 22 at 12:08
Hint: you need to learn how to create a text files. What information about the user is there in the file? How to read file, a.k.a file handling? How to create new user through the command line?
– Kulfy
Nov 22 at 12:12
I thought so hard about this and still cant get how to change user (as a text) into an actual system user!
– user895829
Nov 22 at 12:16
Store into a variable and use that variable say $user
– Kulfy
Nov 22 at 12:22
4
I have seen other homework problems receive favorable responses - the difference is that the person asking the question has shown the work that they have already done, and is asking what they are doing wrong, rather than asking "how to do this". Can you amend your question with what you have already tried?
– Charles Green
Nov 22 at 16:42
|
show 4 more comments
2
Homeworks are off topic here ;)
– Kulfy
Nov 22 at 12:08
Hint: you need to learn how to create a text files. What information about the user is there in the file? How to read file, a.k.a file handling? How to create new user through the command line?
– Kulfy
Nov 22 at 12:12
I thought so hard about this and still cant get how to change user (as a text) into an actual system user!
– user895829
Nov 22 at 12:16
Store into a variable and use that variable say $user
– Kulfy
Nov 22 at 12:22
4
I have seen other homework problems receive favorable responses - the difference is that the person asking the question has shown the work that they have already done, and is asking what they are doing wrong, rather than asking "how to do this". Can you amend your question with what you have already tried?
– Charles Green
Nov 22 at 16:42
2
2
Homeworks are off topic here ;)
– Kulfy
Nov 22 at 12:08
Homeworks are off topic here ;)
– Kulfy
Nov 22 at 12:08
Hint: you need to learn how to create a text files. What information about the user is there in the file? How to read file, a.k.a file handling? How to create new user through the command line?
– Kulfy
Nov 22 at 12:12
Hint: you need to learn how to create a text files. What information about the user is there in the file? How to read file, a.k.a file handling? How to create new user through the command line?
– Kulfy
Nov 22 at 12:12
I thought so hard about this and still cant get how to change user (as a text) into an actual system user!
– user895829
Nov 22 at 12:16
I thought so hard about this and still cant get how to change user (as a text) into an actual system user!
– user895829
Nov 22 at 12:16
Store into a variable and use that variable say $user
– Kulfy
Nov 22 at 12:22
Store into a variable and use that variable say $user
– Kulfy
Nov 22 at 12:22
4
4
I have seen other homework problems receive favorable responses - the difference is that the person asking the question has shown the work that they have already done, and is asking what they are doing wrong, rather than asking "how to do this". Can you amend your question with what you have already tried?
– Charles Green
Nov 22 at 16:42
I have seen other homework problems receive favorable responses - the difference is that the person asking the question has shown the work that they have already done, and is asking what they are doing wrong, rather than asking "how to do this". Can you amend your question with what you have already tried?
– Charles Green
Nov 22 at 16:42
|
show 4 more comments
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
Create a file with name: text
witch contains all users name.
for example my text file contents
usertemp
this is only one test user name.
Then create bash script file like this
run.sh
#!/bin/bash
while read line; do
useradd $line
done < text
Make the script run.sh
runnable by type in terminal
chmod +x run.sh
At last run script with
./run.sh
Running above script may need root privileges.
sudo ./run.sh
Now these users cant log on because we have not assign any password to them.
[ToDO]
- Assign password for created list of users.
- Difference between using
adduser
anduseradd
, in this situation. see
- Read username, password from only one file, text.
[Related posts]
- https://askubuntu.com/a/1068448/678872
[Edit]
Remove redundant
chmod 777 run.sh
as wjandrea said on comment, its only make the script readable writable and executable for everyone see moreUse read command in script instead of
more
, to read line by line. I think its better in speed.
4
Why are you usingmore
instead of just reading the file? i.e.while read line; do ... done < text
. Also runningchmod 777
thenchmod +x
is redundant.
– wjandrea
Nov 22 at 20:06
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Create a file with name: text
witch contains all users name.
for example my text file contents
usertemp
this is only one test user name.
Then create bash script file like this
run.sh
#!/bin/bash
while read line; do
useradd $line
done < text
Make the script run.sh
runnable by type in terminal
chmod +x run.sh
At last run script with
./run.sh
Running above script may need root privileges.
sudo ./run.sh
Now these users cant log on because we have not assign any password to them.
[ToDO]
- Assign password for created list of users.
- Difference between using
adduser
anduseradd
, in this situation. see
- Read username, password from only one file, text.
[Related posts]
- https://askubuntu.com/a/1068448/678872
[Edit]
Remove redundant
chmod 777 run.sh
as wjandrea said on comment, its only make the script readable writable and executable for everyone see moreUse read command in script instead of
more
, to read line by line. I think its better in speed.
4
Why are you usingmore
instead of just reading the file? i.e.while read line; do ... done < text
. Also runningchmod 777
thenchmod +x
is redundant.
– wjandrea
Nov 22 at 20:06
add a comment |
up vote
1
down vote
accepted
Create a file with name: text
witch contains all users name.
for example my text file contents
usertemp
this is only one test user name.
Then create bash script file like this
run.sh
#!/bin/bash
while read line; do
useradd $line
done < text
Make the script run.sh
runnable by type in terminal
chmod +x run.sh
At last run script with
./run.sh
Running above script may need root privileges.
sudo ./run.sh
Now these users cant log on because we have not assign any password to them.
[ToDO]
- Assign password for created list of users.
- Difference between using
adduser
anduseradd
, in this situation. see
- Read username, password from only one file, text.
[Related posts]
- https://askubuntu.com/a/1068448/678872
[Edit]
Remove redundant
chmod 777 run.sh
as wjandrea said on comment, its only make the script readable writable and executable for everyone see moreUse read command in script instead of
more
, to read line by line. I think its better in speed.
4
Why are you usingmore
instead of just reading the file? i.e.while read line; do ... done < text
. Also runningchmod 777
thenchmod +x
is redundant.
– wjandrea
Nov 22 at 20:06
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Create a file with name: text
witch contains all users name.
for example my text file contents
usertemp
this is only one test user name.
Then create bash script file like this
run.sh
#!/bin/bash
while read line; do
useradd $line
done < text
Make the script run.sh
runnable by type in terminal
chmod +x run.sh
At last run script with
./run.sh
Running above script may need root privileges.
sudo ./run.sh
Now these users cant log on because we have not assign any password to them.
[ToDO]
- Assign password for created list of users.
- Difference between using
adduser
anduseradd
, in this situation. see
- Read username, password from only one file, text.
[Related posts]
- https://askubuntu.com/a/1068448/678872
[Edit]
Remove redundant
chmod 777 run.sh
as wjandrea said on comment, its only make the script readable writable and executable for everyone see moreUse read command in script instead of
more
, to read line by line. I think its better in speed.
Create a file with name: text
witch contains all users name.
for example my text file contents
usertemp
this is only one test user name.
Then create bash script file like this
run.sh
#!/bin/bash
while read line; do
useradd $line
done < text
Make the script run.sh
runnable by type in terminal
chmod +x run.sh
At last run script with
./run.sh
Running above script may need root privileges.
sudo ./run.sh
Now these users cant log on because we have not assign any password to them.
[ToDO]
- Assign password for created list of users.
- Difference between using
adduser
anduseradd
, in this situation. see
- Read username, password from only one file, text.
[Related posts]
- https://askubuntu.com/a/1068448/678872
[Edit]
Remove redundant
chmod 777 run.sh
as wjandrea said on comment, its only make the script readable writable and executable for everyone see moreUse read command in script instead of
more
, to read line by line. I think its better in speed.
edited Nov 23 at 12:04
answered Nov 22 at 13:55
EsmaeelE
1867
1867
4
Why are you usingmore
instead of just reading the file? i.e.while read line; do ... done < text
. Also runningchmod 777
thenchmod +x
is redundant.
– wjandrea
Nov 22 at 20:06
add a comment |
4
Why are you usingmore
instead of just reading the file? i.e.while read line; do ... done < text
. Also runningchmod 777
thenchmod +x
is redundant.
– wjandrea
Nov 22 at 20:06
4
4
Why are you using
more
instead of just reading the file? i.e. while read line; do ... done < text
. Also running chmod 777
then chmod +x
is redundant.– wjandrea
Nov 22 at 20:06
Why are you using
more
instead of just reading the file? i.e. while read line; do ... done < text
. Also running chmod 777
then chmod +x
is redundant.– wjandrea
Nov 22 at 20:06
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1095085%2fhow-to-add-users-from-text-file-into-the-unix-system%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Homeworks are off topic here ;)
– Kulfy
Nov 22 at 12:08
Hint: you need to learn how to create a text files. What information about the user is there in the file? How to read file, a.k.a file handling? How to create new user through the command line?
– Kulfy
Nov 22 at 12:12
I thought so hard about this and still cant get how to change user (as a text) into an actual system user!
– user895829
Nov 22 at 12:16
Store into a variable and use that variable say $user
– Kulfy
Nov 22 at 12:22
4
I have seen other homework problems receive favorable responses - the difference is that the person asking the question has shown the work that they have already done, and is asking what they are doing wrong, rather than asking "how to do this". Can you amend your question with what you have already tried?
– Charles Green
Nov 22 at 16:42