简体   繁体   中英

Create a Linux user with different profiles by command line

I was wondering if it was possible to override the SKEL property when adding a user in Linux.

Man page gives me everything to change dynamically any property (SHELL, HOME, ...) but not SKEL.

What I want to do is find a way to assign one profile or another to the users I'm creating.

For instance, I need to create a user with a .profile in which VAR=value1 , and another user with a .profile in which VAR=value2 . My idea was to create different SKEL, one for those who need VAR=value1 , another for those needing VAR=value2 , and simply execute adduser ... -D -magic_option /SKEL/for/value1 or adduser ... -D -magic_option /SKEL/for/value2 . But -magic_option doesn't seem to exist.

Any suggestion?

Of course, just use the -k option in useradd :

-k, --skel SKEL_DIR

The skeleton directory, which contains files and directories to be copied in the user's home directory, when the home directory is created by useradd.

This option is only valid if the -m (or --create-home) option is specified.

If this option is not set, the skeleton directory is defined by the SKEL variable in /etc/default/useradd or, by default, /etc/skel.

If possible, the ACLs and extended attributes are copied.

So you can create your /my/skel_for_users and /my/other_skel_for_users and use either of them whenever creating one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM