Valid special characters allowed in a CentOS 7 username?
I'm trying to figure out how CentOS 7 identifies what is considered a valid character in a naming convention when a user account is created.
I was playing around with useradd to confirm my understanding of what CentOS considered valid characters in a user name.... and to my surprise the useradd command accepted '_' and '.'... Which got me wondering where valid/invalid characters are established in CentOS
The useradd man page in CentOS doesn't mention valid characters... And google searches said this is done with NAME_REGEX (For ubuntu at least)... and had me looking for it in a adduser.conf file... which does not exist in CentOS 7... I haven't been able to locate a CentOS/Red Hat specific source on google about this... But I've also looked in /etc/login.defs and /etc/default/useradd with no luck
Can anyone direct me to the mechanism in CentOS does this?
centos users
add a comment |
I'm trying to figure out how CentOS 7 identifies what is considered a valid character in a naming convention when a user account is created.
I was playing around with useradd to confirm my understanding of what CentOS considered valid characters in a user name.... and to my surprise the useradd command accepted '_' and '.'... Which got me wondering where valid/invalid characters are established in CentOS
The useradd man page in CentOS doesn't mention valid characters... And google searches said this is done with NAME_REGEX (For ubuntu at least)... and had me looking for it in a adduser.conf file... which does not exist in CentOS 7... I haven't been able to locate a CentOS/Red Hat specific source on google about this... But I've also looked in /etc/login.defs and /etc/default/useradd with no luck
Can anyone direct me to the mechanism in CentOS does this?
centos users
1
Related, over at SO (for whatever reason): What are the real rules for linux usernames on CentOS 6 and RHEL 6?
– Kusalananda
5 hours ago
Relating unix.stackexchange.com/q/287077/117549
– Jeff Schaller
5 hours ago
add a comment |
I'm trying to figure out how CentOS 7 identifies what is considered a valid character in a naming convention when a user account is created.
I was playing around with useradd to confirm my understanding of what CentOS considered valid characters in a user name.... and to my surprise the useradd command accepted '_' and '.'... Which got me wondering where valid/invalid characters are established in CentOS
The useradd man page in CentOS doesn't mention valid characters... And google searches said this is done with NAME_REGEX (For ubuntu at least)... and had me looking for it in a adduser.conf file... which does not exist in CentOS 7... I haven't been able to locate a CentOS/Red Hat specific source on google about this... But I've also looked in /etc/login.defs and /etc/default/useradd with no luck
Can anyone direct me to the mechanism in CentOS does this?
centos users
I'm trying to figure out how CentOS 7 identifies what is considered a valid character in a naming convention when a user account is created.
I was playing around with useradd to confirm my understanding of what CentOS considered valid characters in a user name.... and to my surprise the useradd command accepted '_' and '.'... Which got me wondering where valid/invalid characters are established in CentOS
The useradd man page in CentOS doesn't mention valid characters... And google searches said this is done with NAME_REGEX (For ubuntu at least)... and had me looking for it in a adduser.conf file... which does not exist in CentOS 7... I haven't been able to locate a CentOS/Red Hat specific source on google about this... But I've also looked in /etc/login.defs and /etc/default/useradd with no luck
Can anyone direct me to the mechanism in CentOS does this?
centos users
centos users
edited 5 hours ago
Rui F Ribeiro
41.6k1483141
41.6k1483141
asked 5 hours ago
BodishaBodisha
282
282
1
Related, over at SO (for whatever reason): What are the real rules for linux usernames on CentOS 6 and RHEL 6?
– Kusalananda
5 hours ago
Relating unix.stackexchange.com/q/287077/117549
– Jeff Schaller
5 hours ago
add a comment |
1
Related, over at SO (for whatever reason): What are the real rules for linux usernames on CentOS 6 and RHEL 6?
– Kusalananda
5 hours ago
Relating unix.stackexchange.com/q/287077/117549
– Jeff Schaller
5 hours ago
1
1
Related, over at SO (for whatever reason): What are the real rules for linux usernames on CentOS 6 and RHEL 6?
– Kusalananda
5 hours ago
Related, over at SO (for whatever reason): What are the real rules for linux usernames on CentOS 6 and RHEL 6?
– Kusalananda
5 hours ago
Relating unix.stackexchange.com/q/287077/117549
– Jeff Schaller
5 hours ago
Relating unix.stackexchange.com/q/287077/117549
– Jeff Schaller
5 hours ago
add a comment |
1 Answer
1
active
oldest
votes
Note that useradd
may be more restrictive than what is actually valid as a username. The rules as to what a valid username is may also change via PAM and nsswitch configuration settings.
The POSIX standard says that usernames must be from the "portable filename characterset" but the first character must not be a hyphen.
The portable filename character set are the characters A-Z a-z 0-9 . - _
Note this means that something like "1337" is a valid username according to this standard, which may cause issues elsewhere.
So, for safety, I would use a pattern such as [A-Za-z][A-Za-z0-9._-]+
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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
});
}
});
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%2funix.stackexchange.com%2fquestions%2f507575%2fvalid-special-characters-allowed-in-a-centos-7-username%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
Note that useradd
may be more restrictive than what is actually valid as a username. The rules as to what a valid username is may also change via PAM and nsswitch configuration settings.
The POSIX standard says that usernames must be from the "portable filename characterset" but the first character must not be a hyphen.
The portable filename character set are the characters A-Z a-z 0-9 . - _
Note this means that something like "1337" is a valid username according to this standard, which may cause issues elsewhere.
So, for safety, I would use a pattern such as [A-Za-z][A-Za-z0-9._-]+
add a comment |
Note that useradd
may be more restrictive than what is actually valid as a username. The rules as to what a valid username is may also change via PAM and nsswitch configuration settings.
The POSIX standard says that usernames must be from the "portable filename characterset" but the first character must not be a hyphen.
The portable filename character set are the characters A-Z a-z 0-9 . - _
Note this means that something like "1337" is a valid username according to this standard, which may cause issues elsewhere.
So, for safety, I would use a pattern such as [A-Za-z][A-Za-z0-9._-]+
add a comment |
Note that useradd
may be more restrictive than what is actually valid as a username. The rules as to what a valid username is may also change via PAM and nsswitch configuration settings.
The POSIX standard says that usernames must be from the "portable filename characterset" but the first character must not be a hyphen.
The portable filename character set are the characters A-Z a-z 0-9 . - _
Note this means that something like "1337" is a valid username according to this standard, which may cause issues elsewhere.
So, for safety, I would use a pattern such as [A-Za-z][A-Za-z0-9._-]+
Note that useradd
may be more restrictive than what is actually valid as a username. The rules as to what a valid username is may also change via PAM and nsswitch configuration settings.
The POSIX standard says that usernames must be from the "portable filename characterset" but the first character must not be a hyphen.
The portable filename character set are the characters A-Z a-z 0-9 . - _
Note this means that something like "1337" is a valid username according to this standard, which may cause issues elsewhere.
So, for safety, I would use a pattern such as [A-Za-z][A-Za-z0-9._-]+
answered 4 hours ago
Stephen HarrisStephen Harris
26.8k35181
26.8k35181
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- 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%2funix.stackexchange.com%2fquestions%2f507575%2fvalid-special-characters-allowed-in-a-centos-7-username%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
1
Related, over at SO (for whatever reason): What are the real rules for linux usernames on CentOS 6 and RHEL 6?
– Kusalananda
5 hours ago
Relating unix.stackexchange.com/q/287077/117549
– Jeff Schaller
5 hours ago