At what point is the ~/.bashrc file created?












19














For instance, if I were to run the command adduser test, is the .bashrc created automatically upon creation of the home directory for the user test? If it's not created upon user creation, under what conditions is it created?



Also, if I add a .bashrc file to the home directory of a user, will it be overwritten by the OS?



Thanks in advance.










share|improve this question




















  • 2




    If you just tried it, you would find out much faster than by asking here.
    – Stig Hemmer
    Nov 2 '17 at 9:01
















19














For instance, if I were to run the command adduser test, is the .bashrc created automatically upon creation of the home directory for the user test? If it's not created upon user creation, under what conditions is it created?



Also, if I add a .bashrc file to the home directory of a user, will it be overwritten by the OS?



Thanks in advance.










share|improve this question




















  • 2




    If you just tried it, you would find out much faster than by asking here.
    – Stig Hemmer
    Nov 2 '17 at 9:01














19












19








19


4





For instance, if I were to run the command adduser test, is the .bashrc created automatically upon creation of the home directory for the user test? If it's not created upon user creation, under what conditions is it created?



Also, if I add a .bashrc file to the home directory of a user, will it be overwritten by the OS?



Thanks in advance.










share|improve this question















For instance, if I were to run the command adduser test, is the .bashrc created automatically upon creation of the home directory for the user test? If it's not created upon user creation, under what conditions is it created?



Also, if I add a .bashrc file to the home directory of a user, will it be overwritten by the OS?



Thanks in advance.







command-line bash bashrc






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 1 '17 at 21:44









wjandrea

8,47842259




8,47842259










asked Nov 1 '17 at 20:53









MichaelMichael

358110




358110








  • 2




    If you just tried it, you would find out much faster than by asking here.
    – Stig Hemmer
    Nov 2 '17 at 9:01














  • 2




    If you just tried it, you would find out much faster than by asking here.
    – Stig Hemmer
    Nov 2 '17 at 9:01








2




2




If you just tried it, you would find out much faster than by asking here.
– Stig Hemmer
Nov 2 '17 at 9:01




If you just tried it, you would find out much faster than by asking here.
– Stig Hemmer
Nov 2 '17 at 9:01










1 Answer
1






active

oldest

votes


















28














In most cases, the initial user files (including .bashrc) are created when the user is created. They are copies of the files stored into the 'skeletal' directory, named /etc/skel. There are two main commands:





  • useradd is the back-end command, if you using it directly (without any options) just a system user (and its group) will be created:





    $ sudo useradd new-user
    $ ls -la /home/new-user/
    ls: cannot access '/home/new-user/': No such file or directory



    • useradd will create a home directory and populate it with a copy of /etc/skel if the -m --create-home option is supplied. Thanks for this comment to @jwodder.


    • The option -s --shell will change the name of the new user's login shell. No matter what the new user's login shell is, the entire content of the 'skeletal' directory /etc/skel will be populated into the new user's home directory.


    • A different 'skeletal' directory cold be defined with the -k --create-home option.


    • The configuration file of this command is /etc/default/useradd.





  • adduser is user-friendly and interactive front-end of useradd. This command will copy the files from /etc/skel to the user's $HOME directory by default:



    $ sudo adduser new-user
    Adding user `new-user' ...
    Adding new group `new-user' (1002) ...
    Adding new user `new-user' (1002) with group `new-user' ...
    Creating home directory `/home/new-user' ...
    Copying files from `/etc/skel' ...
    Enter new UNIX password:
    Retype new UNIX password:
    passwd: password updated successfully
    Changing the user information for new-user
    Enter the new value, or press ENTER for the default
    Full Name : New User
    Room Number :
    Work Phone :
    Home Phone :
    Other :
    Is the information correct? [Y/n]

    $ ls -a /home/new-user/
    . .. .bash_logout .bashrc .config examples.desktop .profile .Xdefaults



    • The configuration file of this command is /etc/adduser.conf.


    • The default value for the new user's login shell is deteminated by the variable DSHELL=. It could be specified also via the option --shell. No matter what the new user's login shell is, the entire content of the 'skeletal' directory /etc/skel will be populated into the new user's home directory.


    • The SKEL= variable in this file specifies the default directory containing 'skeletal' user files.


    • The option --no-create-home will force the command adduser to do not create a user home directory, respectively the content of the 'skeletal' directory will not be copied.


    • If called with one non-option argument and the --system option, adduser will add a system user... A home directory is created by the same rules as for normal users. The new system user will have the shell /bin/false (unless overridden with the --shell option), and have logins disabled. Skeletal configuration files are not copied. ...from the manual page.







Additionally, when the user is created with any GUI tool as User Accounts, the result is identical to that of the command adduser.





References:




  • What is the difference between adduser and useradd?


  • What's the difference between "adduser" and "useradd"?


  • Home directory not being created


  • AddUsersHowto - Ubuntu Documentation Community Wiki


  • What is the *nix command to view a user's default login shell?


  • Terminal command for listing available shells







share|improve this answer



















  • 2




    useradd will also create a home directory and populate it with a copy of /etc/skel if the -m option is supplied.
    – jwodder
    Nov 1 '17 at 21:41






  • 4




    Your second code block still uses useradd in the command; was that supposed to be adduser?
    – David Z
    Nov 1 '17 at 22:04






  • 2




    Also, User Accounts makes use of adduser, doesn't it?
    – Gunnar Hjalmarsson
    Nov 1 '17 at 22:05











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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f971836%2fat-what-point-is-the-bashrc-file-created%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









28














In most cases, the initial user files (including .bashrc) are created when the user is created. They are copies of the files stored into the 'skeletal' directory, named /etc/skel. There are two main commands:





  • useradd is the back-end command, if you using it directly (without any options) just a system user (and its group) will be created:





    $ sudo useradd new-user
    $ ls -la /home/new-user/
    ls: cannot access '/home/new-user/': No such file or directory



    • useradd will create a home directory and populate it with a copy of /etc/skel if the -m --create-home option is supplied. Thanks for this comment to @jwodder.


    • The option -s --shell will change the name of the new user's login shell. No matter what the new user's login shell is, the entire content of the 'skeletal' directory /etc/skel will be populated into the new user's home directory.


    • A different 'skeletal' directory cold be defined with the -k --create-home option.


    • The configuration file of this command is /etc/default/useradd.





  • adduser is user-friendly and interactive front-end of useradd. This command will copy the files from /etc/skel to the user's $HOME directory by default:



    $ sudo adduser new-user
    Adding user `new-user' ...
    Adding new group `new-user' (1002) ...
    Adding new user `new-user' (1002) with group `new-user' ...
    Creating home directory `/home/new-user' ...
    Copying files from `/etc/skel' ...
    Enter new UNIX password:
    Retype new UNIX password:
    passwd: password updated successfully
    Changing the user information for new-user
    Enter the new value, or press ENTER for the default
    Full Name : New User
    Room Number :
    Work Phone :
    Home Phone :
    Other :
    Is the information correct? [Y/n]

    $ ls -a /home/new-user/
    . .. .bash_logout .bashrc .config examples.desktop .profile .Xdefaults



    • The configuration file of this command is /etc/adduser.conf.


    • The default value for the new user's login shell is deteminated by the variable DSHELL=. It could be specified also via the option --shell. No matter what the new user's login shell is, the entire content of the 'skeletal' directory /etc/skel will be populated into the new user's home directory.


    • The SKEL= variable in this file specifies the default directory containing 'skeletal' user files.


    • The option --no-create-home will force the command adduser to do not create a user home directory, respectively the content of the 'skeletal' directory will not be copied.


    • If called with one non-option argument and the --system option, adduser will add a system user... A home directory is created by the same rules as for normal users. The new system user will have the shell /bin/false (unless overridden with the --shell option), and have logins disabled. Skeletal configuration files are not copied. ...from the manual page.







Additionally, when the user is created with any GUI tool as User Accounts, the result is identical to that of the command adduser.





References:




  • What is the difference between adduser and useradd?


  • What's the difference between "adduser" and "useradd"?


  • Home directory not being created


  • AddUsersHowto - Ubuntu Documentation Community Wiki


  • What is the *nix command to view a user's default login shell?


  • Terminal command for listing available shells







share|improve this answer



















  • 2




    useradd will also create a home directory and populate it with a copy of /etc/skel if the -m option is supplied.
    – jwodder
    Nov 1 '17 at 21:41






  • 4




    Your second code block still uses useradd in the command; was that supposed to be adduser?
    – David Z
    Nov 1 '17 at 22:04






  • 2




    Also, User Accounts makes use of adduser, doesn't it?
    – Gunnar Hjalmarsson
    Nov 1 '17 at 22:05
















28














In most cases, the initial user files (including .bashrc) are created when the user is created. They are copies of the files stored into the 'skeletal' directory, named /etc/skel. There are two main commands:





  • useradd is the back-end command, if you using it directly (without any options) just a system user (and its group) will be created:





    $ sudo useradd new-user
    $ ls -la /home/new-user/
    ls: cannot access '/home/new-user/': No such file or directory



    • useradd will create a home directory and populate it with a copy of /etc/skel if the -m --create-home option is supplied. Thanks for this comment to @jwodder.


    • The option -s --shell will change the name of the new user's login shell. No matter what the new user's login shell is, the entire content of the 'skeletal' directory /etc/skel will be populated into the new user's home directory.


    • A different 'skeletal' directory cold be defined with the -k --create-home option.


    • The configuration file of this command is /etc/default/useradd.





  • adduser is user-friendly and interactive front-end of useradd. This command will copy the files from /etc/skel to the user's $HOME directory by default:



    $ sudo adduser new-user
    Adding user `new-user' ...
    Adding new group `new-user' (1002) ...
    Adding new user `new-user' (1002) with group `new-user' ...
    Creating home directory `/home/new-user' ...
    Copying files from `/etc/skel' ...
    Enter new UNIX password:
    Retype new UNIX password:
    passwd: password updated successfully
    Changing the user information for new-user
    Enter the new value, or press ENTER for the default
    Full Name : New User
    Room Number :
    Work Phone :
    Home Phone :
    Other :
    Is the information correct? [Y/n]

    $ ls -a /home/new-user/
    . .. .bash_logout .bashrc .config examples.desktop .profile .Xdefaults



    • The configuration file of this command is /etc/adduser.conf.


    • The default value for the new user's login shell is deteminated by the variable DSHELL=. It could be specified also via the option --shell. No matter what the new user's login shell is, the entire content of the 'skeletal' directory /etc/skel will be populated into the new user's home directory.


    • The SKEL= variable in this file specifies the default directory containing 'skeletal' user files.


    • The option --no-create-home will force the command adduser to do not create a user home directory, respectively the content of the 'skeletal' directory will not be copied.


    • If called with one non-option argument and the --system option, adduser will add a system user... A home directory is created by the same rules as for normal users. The new system user will have the shell /bin/false (unless overridden with the --shell option), and have logins disabled. Skeletal configuration files are not copied. ...from the manual page.







Additionally, when the user is created with any GUI tool as User Accounts, the result is identical to that of the command adduser.





References:




  • What is the difference between adduser and useradd?


  • What's the difference between "adduser" and "useradd"?


  • Home directory not being created


  • AddUsersHowto - Ubuntu Documentation Community Wiki


  • What is the *nix command to view a user's default login shell?


  • Terminal command for listing available shells







share|improve this answer



















  • 2




    useradd will also create a home directory and populate it with a copy of /etc/skel if the -m option is supplied.
    – jwodder
    Nov 1 '17 at 21:41






  • 4




    Your second code block still uses useradd in the command; was that supposed to be adduser?
    – David Z
    Nov 1 '17 at 22:04






  • 2




    Also, User Accounts makes use of adduser, doesn't it?
    – Gunnar Hjalmarsson
    Nov 1 '17 at 22:05














28












28








28






In most cases, the initial user files (including .bashrc) are created when the user is created. They are copies of the files stored into the 'skeletal' directory, named /etc/skel. There are two main commands:





  • useradd is the back-end command, if you using it directly (without any options) just a system user (and its group) will be created:





    $ sudo useradd new-user
    $ ls -la /home/new-user/
    ls: cannot access '/home/new-user/': No such file or directory



    • useradd will create a home directory and populate it with a copy of /etc/skel if the -m --create-home option is supplied. Thanks for this comment to @jwodder.


    • The option -s --shell will change the name of the new user's login shell. No matter what the new user's login shell is, the entire content of the 'skeletal' directory /etc/skel will be populated into the new user's home directory.


    • A different 'skeletal' directory cold be defined with the -k --create-home option.


    • The configuration file of this command is /etc/default/useradd.





  • adduser is user-friendly and interactive front-end of useradd. This command will copy the files from /etc/skel to the user's $HOME directory by default:



    $ sudo adduser new-user
    Adding user `new-user' ...
    Adding new group `new-user' (1002) ...
    Adding new user `new-user' (1002) with group `new-user' ...
    Creating home directory `/home/new-user' ...
    Copying files from `/etc/skel' ...
    Enter new UNIX password:
    Retype new UNIX password:
    passwd: password updated successfully
    Changing the user information for new-user
    Enter the new value, or press ENTER for the default
    Full Name : New User
    Room Number :
    Work Phone :
    Home Phone :
    Other :
    Is the information correct? [Y/n]

    $ ls -a /home/new-user/
    . .. .bash_logout .bashrc .config examples.desktop .profile .Xdefaults



    • The configuration file of this command is /etc/adduser.conf.


    • The default value for the new user's login shell is deteminated by the variable DSHELL=. It could be specified also via the option --shell. No matter what the new user's login shell is, the entire content of the 'skeletal' directory /etc/skel will be populated into the new user's home directory.


    • The SKEL= variable in this file specifies the default directory containing 'skeletal' user files.


    • The option --no-create-home will force the command adduser to do not create a user home directory, respectively the content of the 'skeletal' directory will not be copied.


    • If called with one non-option argument and the --system option, adduser will add a system user... A home directory is created by the same rules as for normal users. The new system user will have the shell /bin/false (unless overridden with the --shell option), and have logins disabled. Skeletal configuration files are not copied. ...from the manual page.







Additionally, when the user is created with any GUI tool as User Accounts, the result is identical to that of the command adduser.





References:




  • What is the difference between adduser and useradd?


  • What's the difference between "adduser" and "useradd"?


  • Home directory not being created


  • AddUsersHowto - Ubuntu Documentation Community Wiki


  • What is the *nix command to view a user's default login shell?


  • Terminal command for listing available shells







share|improve this answer














In most cases, the initial user files (including .bashrc) are created when the user is created. They are copies of the files stored into the 'skeletal' directory, named /etc/skel. There are two main commands:





  • useradd is the back-end command, if you using it directly (without any options) just a system user (and its group) will be created:





    $ sudo useradd new-user
    $ ls -la /home/new-user/
    ls: cannot access '/home/new-user/': No such file or directory



    • useradd will create a home directory and populate it with a copy of /etc/skel if the -m --create-home option is supplied. Thanks for this comment to @jwodder.


    • The option -s --shell will change the name of the new user's login shell. No matter what the new user's login shell is, the entire content of the 'skeletal' directory /etc/skel will be populated into the new user's home directory.


    • A different 'skeletal' directory cold be defined with the -k --create-home option.


    • The configuration file of this command is /etc/default/useradd.





  • adduser is user-friendly and interactive front-end of useradd. This command will copy the files from /etc/skel to the user's $HOME directory by default:



    $ sudo adduser new-user
    Adding user `new-user' ...
    Adding new group `new-user' (1002) ...
    Adding new user `new-user' (1002) with group `new-user' ...
    Creating home directory `/home/new-user' ...
    Copying files from `/etc/skel' ...
    Enter new UNIX password:
    Retype new UNIX password:
    passwd: password updated successfully
    Changing the user information for new-user
    Enter the new value, or press ENTER for the default
    Full Name : New User
    Room Number :
    Work Phone :
    Home Phone :
    Other :
    Is the information correct? [Y/n]

    $ ls -a /home/new-user/
    . .. .bash_logout .bashrc .config examples.desktop .profile .Xdefaults



    • The configuration file of this command is /etc/adduser.conf.


    • The default value for the new user's login shell is deteminated by the variable DSHELL=. It could be specified also via the option --shell. No matter what the new user's login shell is, the entire content of the 'skeletal' directory /etc/skel will be populated into the new user's home directory.


    • The SKEL= variable in this file specifies the default directory containing 'skeletal' user files.


    • The option --no-create-home will force the command adduser to do not create a user home directory, respectively the content of the 'skeletal' directory will not be copied.


    • If called with one non-option argument and the --system option, adduser will add a system user... A home directory is created by the same rules as for normal users. The new system user will have the shell /bin/false (unless overridden with the --shell option), and have logins disabled. Skeletal configuration files are not copied. ...from the manual page.







Additionally, when the user is created with any GUI tool as User Accounts, the result is identical to that of the command adduser.





References:




  • What is the difference between adduser and useradd?


  • What's the difference between "adduser" and "useradd"?


  • Home directory not being created


  • AddUsersHowto - Ubuntu Documentation Community Wiki


  • What is the *nix command to view a user's default login shell?


  • Terminal command for listing available shells








share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 17 '18 at 19:37

























answered Nov 1 '17 at 21:16









pa4080pa4080

13.5k52562




13.5k52562








  • 2




    useradd will also create a home directory and populate it with a copy of /etc/skel if the -m option is supplied.
    – jwodder
    Nov 1 '17 at 21:41






  • 4




    Your second code block still uses useradd in the command; was that supposed to be adduser?
    – David Z
    Nov 1 '17 at 22:04






  • 2




    Also, User Accounts makes use of adduser, doesn't it?
    – Gunnar Hjalmarsson
    Nov 1 '17 at 22:05














  • 2




    useradd will also create a home directory and populate it with a copy of /etc/skel if the -m option is supplied.
    – jwodder
    Nov 1 '17 at 21:41






  • 4




    Your second code block still uses useradd in the command; was that supposed to be adduser?
    – David Z
    Nov 1 '17 at 22:04






  • 2




    Also, User Accounts makes use of adduser, doesn't it?
    – Gunnar Hjalmarsson
    Nov 1 '17 at 22:05








2




2




useradd will also create a home directory and populate it with a copy of /etc/skel if the -m option is supplied.
– jwodder
Nov 1 '17 at 21:41




useradd will also create a home directory and populate it with a copy of /etc/skel if the -m option is supplied.
– jwodder
Nov 1 '17 at 21:41




4




4




Your second code block still uses useradd in the command; was that supposed to be adduser?
– David Z
Nov 1 '17 at 22:04




Your second code block still uses useradd in the command; was that supposed to be adduser?
– David Z
Nov 1 '17 at 22:04




2




2




Also, User Accounts makes use of adduser, doesn't it?
– Gunnar Hjalmarsson
Nov 1 '17 at 22:05




Also, User Accounts makes use of adduser, doesn't it?
– Gunnar Hjalmarsson
Nov 1 '17 at 22:05


















draft saved

draft discarded




















































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%2f971836%2fat-what-point-is-the-bashrc-file-created%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

Quarter-circle Tiles

build a pushdown automaton that recognizes the reverse language of a given pushdown automaton?

Mont Emei