How to make home directory of existing users?












2














#!/bin/bash

OLDIFS=$IFS
IFS=","

while read firstname lastname userid
do
sudo useradd -c "${firstname}.${lastname}" -d /home/students/student/"${firstname}.${lastname}" -G students -s /bin/bash "${userid}"
done < hello.csv









share|improve this question









New contributor




vishnu prajapati is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1




    You might want to investigate the newusers command ("update and create new users in batch")
    – steeldriver
    2 days ago










  • Welcome to Ask Ubuntu! What’s your question? What are you trying to achieve? (Please edit your post when you want to clarify something or add information. It’s best to have everything relevant in one place. Additionally, comments may be deleted for various reasons.) Thanks.
    – David Foerster
    2 days ago
















2














#!/bin/bash

OLDIFS=$IFS
IFS=","

while read firstname lastname userid
do
sudo useradd -c "${firstname}.${lastname}" -d /home/students/student/"${firstname}.${lastname}" -G students -s /bin/bash "${userid}"
done < hello.csv









share|improve this question









New contributor




vishnu prajapati is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1




    You might want to investigate the newusers command ("update and create new users in batch")
    – steeldriver
    2 days ago










  • Welcome to Ask Ubuntu! What’s your question? What are you trying to achieve? (Please edit your post when you want to clarify something or add information. It’s best to have everything relevant in one place. Additionally, comments may be deleted for various reasons.) Thanks.
    – David Foerster
    2 days ago














2












2








2







#!/bin/bash

OLDIFS=$IFS
IFS=","

while read firstname lastname userid
do
sudo useradd -c "${firstname}.${lastname}" -d /home/students/student/"${firstname}.${lastname}" -G students -s /bin/bash "${userid}"
done < hello.csv









share|improve this question









New contributor




vishnu prajapati is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











#!/bin/bash

OLDIFS=$IFS
IFS=","

while read firstname lastname userid
do
sudo useradd -c "${firstname}.${lastname}" -d /home/students/student/"${firstname}.${lastname}" -G students -s /bin/bash "${userid}"
done < hello.csv






bash






share|improve this question









New contributor




vishnu prajapati is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




vishnu prajapati is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Jan 6 at 13:24









Kulfy

3,85841140




3,85841140






New contributor




vishnu prajapati is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Jan 6 at 13:10









vishnu prajapativishnu prajapati

111




111




New contributor




vishnu prajapati is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





vishnu prajapati is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






vishnu prajapati is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 1




    You might want to investigate the newusers command ("update and create new users in batch")
    – steeldriver
    2 days ago










  • Welcome to Ask Ubuntu! What’s your question? What are you trying to achieve? (Please edit your post when you want to clarify something or add information. It’s best to have everything relevant in one place. Additionally, comments may be deleted for various reasons.) Thanks.
    – David Foerster
    2 days ago














  • 1




    You might want to investigate the newusers command ("update and create new users in batch")
    – steeldriver
    2 days ago










  • Welcome to Ask Ubuntu! What’s your question? What are you trying to achieve? (Please edit your post when you want to clarify something or add information. It’s best to have everything relevant in one place. Additionally, comments may be deleted for various reasons.) Thanks.
    – David Foerster
    2 days ago








1




1




You might want to investigate the newusers command ("update and create new users in batch")
– steeldriver
2 days ago




You might want to investigate the newusers command ("update and create new users in batch")
– steeldriver
2 days ago












Welcome to Ask Ubuntu! What’s your question? What are you trying to achieve? (Please edit your post when you want to clarify something or add information. It’s best to have everything relevant in one place. Additionally, comments may be deleted for various reasons.) Thanks.
– David Foerster
2 days ago




Welcome to Ask Ubuntu! What’s your question? What are you trying to achieve? (Please edit your post when you want to clarify something or add information. It’s best to have everything relevant in one place. Additionally, comments may be deleted for various reasons.) Thanks.
– David Foerster
2 days ago










1 Answer
1






active

oldest

votes


















5














From the manpage:






-m, --create-home
Create the user's home directory if it does not exist.
The files and directories contained in the skeleton directory
(which can be defined with the -k option) will be copied to
the home directory.

By default, if this option is not specified and CREATE_HOME
is not enabled, no home directories are created.



However, I would strongly suggest to not use a user's real name
for the $HOME directory as you did with -d /home/students/student/"${firstname}.${lastname}".
Think of (real) usernames like "John A. Doe".
His $HOME directory would contain a space and that is not exactly userfriendly.






share|improve this answer























  • Or someone with a non-latin name. Would not work. Usernames has to match [a-z_][a-z0-9_-]*[$]? according to man useradd
    – vidarlo
    Jan 6 at 13:44






  • 1




    @vidarlo Not quite. What you say is true for the username (the string you get from id or what you need to type when logging in, e.g. pduck). But the OP uses the real name for the $HOME path, e.g. /home/students/student/Perl.Duck. Here, anything that is a valid filename is allowed but when it contains weird characters you always have to write "$HOME" instead of just $HOME and I'm tempted to predict that users will keep asking the OP why cd /home/students/student/John A. Doe won't take them to their home directory but complain about cd: too many arguments instead.
    – PerlDuck
    2 days ago










  • Good distinction. I didn't spot that :)
    – vidarlo
    2 days ago











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






vishnu prajapati is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1107416%2fhow-to-make-home-directory-of-existing-users%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









5














From the manpage:






-m, --create-home
Create the user's home directory if it does not exist.
The files and directories contained in the skeleton directory
(which can be defined with the -k option) will be copied to
the home directory.

By default, if this option is not specified and CREATE_HOME
is not enabled, no home directories are created.



However, I would strongly suggest to not use a user's real name
for the $HOME directory as you did with -d /home/students/student/"${firstname}.${lastname}".
Think of (real) usernames like "John A. Doe".
His $HOME directory would contain a space and that is not exactly userfriendly.






share|improve this answer























  • Or someone with a non-latin name. Would not work. Usernames has to match [a-z_][a-z0-9_-]*[$]? according to man useradd
    – vidarlo
    Jan 6 at 13:44






  • 1




    @vidarlo Not quite. What you say is true for the username (the string you get from id or what you need to type when logging in, e.g. pduck). But the OP uses the real name for the $HOME path, e.g. /home/students/student/Perl.Duck. Here, anything that is a valid filename is allowed but when it contains weird characters you always have to write "$HOME" instead of just $HOME and I'm tempted to predict that users will keep asking the OP why cd /home/students/student/John A. Doe won't take them to their home directory but complain about cd: too many arguments instead.
    – PerlDuck
    2 days ago










  • Good distinction. I didn't spot that :)
    – vidarlo
    2 days ago
















5














From the manpage:






-m, --create-home
Create the user's home directory if it does not exist.
The files and directories contained in the skeleton directory
(which can be defined with the -k option) will be copied to
the home directory.

By default, if this option is not specified and CREATE_HOME
is not enabled, no home directories are created.



However, I would strongly suggest to not use a user's real name
for the $HOME directory as you did with -d /home/students/student/"${firstname}.${lastname}".
Think of (real) usernames like "John A. Doe".
His $HOME directory would contain a space and that is not exactly userfriendly.






share|improve this answer























  • Or someone with a non-latin name. Would not work. Usernames has to match [a-z_][a-z0-9_-]*[$]? according to man useradd
    – vidarlo
    Jan 6 at 13:44






  • 1




    @vidarlo Not quite. What you say is true for the username (the string you get from id or what you need to type when logging in, e.g. pduck). But the OP uses the real name for the $HOME path, e.g. /home/students/student/Perl.Duck. Here, anything that is a valid filename is allowed but when it contains weird characters you always have to write "$HOME" instead of just $HOME and I'm tempted to predict that users will keep asking the OP why cd /home/students/student/John A. Doe won't take them to their home directory but complain about cd: too many arguments instead.
    – PerlDuck
    2 days ago










  • Good distinction. I didn't spot that :)
    – vidarlo
    2 days ago














5












5








5






From the manpage:






-m, --create-home
Create the user's home directory if it does not exist.
The files and directories contained in the skeleton directory
(which can be defined with the -k option) will be copied to
the home directory.

By default, if this option is not specified and CREATE_HOME
is not enabled, no home directories are created.



However, I would strongly suggest to not use a user's real name
for the $HOME directory as you did with -d /home/students/student/"${firstname}.${lastname}".
Think of (real) usernames like "John A. Doe".
His $HOME directory would contain a space and that is not exactly userfriendly.






share|improve this answer














From the manpage:






-m, --create-home
Create the user's home directory if it does not exist.
The files and directories contained in the skeleton directory
(which can be defined with the -k option) will be copied to
the home directory.

By default, if this option is not specified and CREATE_HOME
is not enabled, no home directories are created.



However, I would strongly suggest to not use a user's real name
for the $HOME directory as you did with -d /home/students/student/"${firstname}.${lastname}".
Think of (real) usernames like "John A. Doe".
His $HOME directory would contain a space and that is not exactly userfriendly.







share|improve this answer














share|improve this answer



share|improve this answer








edited 2 days ago









wizzwizz4

1176




1176










answered Jan 6 at 13:19









PerlDuckPerlDuck

5,52411231




5,52411231












  • Or someone with a non-latin name. Would not work. Usernames has to match [a-z_][a-z0-9_-]*[$]? according to man useradd
    – vidarlo
    Jan 6 at 13:44






  • 1




    @vidarlo Not quite. What you say is true for the username (the string you get from id or what you need to type when logging in, e.g. pduck). But the OP uses the real name for the $HOME path, e.g. /home/students/student/Perl.Duck. Here, anything that is a valid filename is allowed but when it contains weird characters you always have to write "$HOME" instead of just $HOME and I'm tempted to predict that users will keep asking the OP why cd /home/students/student/John A. Doe won't take them to their home directory but complain about cd: too many arguments instead.
    – PerlDuck
    2 days ago










  • Good distinction. I didn't spot that :)
    – vidarlo
    2 days ago


















  • Or someone with a non-latin name. Would not work. Usernames has to match [a-z_][a-z0-9_-]*[$]? according to man useradd
    – vidarlo
    Jan 6 at 13:44






  • 1




    @vidarlo Not quite. What you say is true for the username (the string you get from id or what you need to type when logging in, e.g. pduck). But the OP uses the real name for the $HOME path, e.g. /home/students/student/Perl.Duck. Here, anything that is a valid filename is allowed but when it contains weird characters you always have to write "$HOME" instead of just $HOME and I'm tempted to predict that users will keep asking the OP why cd /home/students/student/John A. Doe won't take them to their home directory but complain about cd: too many arguments instead.
    – PerlDuck
    2 days ago










  • Good distinction. I didn't spot that :)
    – vidarlo
    2 days ago
















Or someone with a non-latin name. Would not work. Usernames has to match [a-z_][a-z0-9_-]*[$]? according to man useradd
– vidarlo
Jan 6 at 13:44




Or someone with a non-latin name. Would not work. Usernames has to match [a-z_][a-z0-9_-]*[$]? according to man useradd
– vidarlo
Jan 6 at 13:44




1




1




@vidarlo Not quite. What you say is true for the username (the string you get from id or what you need to type when logging in, e.g. pduck). But the OP uses the real name for the $HOME path, e.g. /home/students/student/Perl.Duck. Here, anything that is a valid filename is allowed but when it contains weird characters you always have to write "$HOME" instead of just $HOME and I'm tempted to predict that users will keep asking the OP why cd /home/students/student/John A. Doe won't take them to their home directory but complain about cd: too many arguments instead.
– PerlDuck
2 days ago




@vidarlo Not quite. What you say is true for the username (the string you get from id or what you need to type when logging in, e.g. pduck). But the OP uses the real name for the $HOME path, e.g. /home/students/student/Perl.Duck. Here, anything that is a valid filename is allowed but when it contains weird characters you always have to write "$HOME" instead of just $HOME and I'm tempted to predict that users will keep asking the OP why cd /home/students/student/John A. Doe won't take them to their home directory but complain about cd: too many arguments instead.
– PerlDuck
2 days ago












Good distinction. I didn't spot that :)
– vidarlo
2 days ago




Good distinction. I didn't spot that :)
– vidarlo
2 days ago










vishnu prajapati is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















vishnu prajapati is a new contributor. Be nice, and check out our Code of Conduct.













vishnu prajapati is a new contributor. Be nice, and check out our Code of Conduct.












vishnu prajapati is a new contributor. Be nice, and check out our Code of Conduct.
















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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1107416%2fhow-to-make-home-directory-of-existing-users%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

If I really need a card on my start hand, how many mulligans make sense? [duplicate]

Alcedinidae

Can an atomic nucleus contain both particles and antiparticles? [duplicate]