Awk to get all my regular users in shadowConvey some message to all usersHow can I process multi-line records...
Can a Hogwarts student refuse the Sorting Hat's decision?
How to prevent Deadlock on SELECT queries?
What is the difference between "un plan" and "une carte" (in the context of map)?
foot-pounds of energy?
Are valid inequalities worth the effort given modern solver preprocessing options?
Would this winged human/angel be able to fly?
Did Logical Positivism fail because it simply denied human emotion?
Is a text with orthographic or grammatic mistakes in a language X still a text in that language X?
What printing process is this?
The Game of the Century - why didn't Byrne take the rook after he forked Fischer?
How easy is it to get a gun illegally in the United States?
How do I show and not tell a backstory?
A verb for when some rights are not violated?
When using the Proficiency Dice optional rule, how should they be used in determining a character's Spell Save DC?
How to make clear to my boyfriend that I simply don't have anything to talk about
Glue-up for butcher block-style countertop
How to win against ants
Properties: Left of the colon
A Checkmate of Dubious Legality
Need reasons why a satellite network would not work
Is a switch from R to Python worth it?
Is the first page of a novel really that important?
Is it uncompelling to continue the story with lower stakes?
Is it okay to use different fingers every time while playing a song on keyboard? Is it considered a bad practice?
Awk to get all my regular users in shadow
Convey some message to all usersHow can I process multi-line records with awk in a bash script?return value from awkUpstart - unable to read /etc/shadow unless sudoBash: Regular Expressions in substitutionSet expire date for usersGet one element of path string using bashSeparating Commands in a Script File?Substitute cut command inside AWK scriptMake variables show a column with awk
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I have a script.
I want to get all my regular users from /etc/shadow e.g all users which second term in shadow file begins with $ or !$.
My pattern is
sudo getent shadow | awk -F: '$2 ~ /^$/ || /^!$/ {print $1}'
It doesn't work for now.
bash scripts
add a comment |
I have a script.
I want to get all my regular users from /etc/shadow e.g all users which second term in shadow file begins with $ or !$.
My pattern is
sudo getent shadow | awk -F: '$2 ~ /^$/ || /^!$/ {print $1}'
It doesn't work for now.
bash scripts
does it have to be awk? :-)
– Rinzwind
10 hours ago
add a comment |
I have a script.
I want to get all my regular users from /etc/shadow e.g all users which second term in shadow file begins with $ or !$.
My pattern is
sudo getent shadow | awk -F: '$2 ~ /^$/ || /^!$/ {print $1}'
It doesn't work for now.
bash scripts
I have a script.
I want to get all my regular users from /etc/shadow e.g all users which second term in shadow file begins with $ or !$.
My pattern is
sudo getent shadow | awk -F: '$2 ~ /^$/ || /^!$/ {print $1}'
It doesn't work for now.
bash scripts
bash scripts
edited 10 hours ago
Eliah Kagan
87.7k22 gold badges243 silver badges386 bronze badges
87.7k22 gold badges243 silver badges386 bronze badges
asked 10 hours ago
danasodanaso
675 bronze badges
675 bronze badges
does it have to be awk? :-)
– Rinzwind
10 hours ago
add a comment |
does it have to be awk? :-)
– Rinzwind
10 hours ago
does it have to be awk? :-)
– Rinzwind
10 hours ago
does it have to be awk? :-)
– Rinzwind
10 hours ago
add a comment |
2 Answers
2
active
oldest
votes
You need to escape the $, as it is a special char for "End of Line" much like ^ is "Beginning of Line".
sudo getent shadow | awk -F: '$2 ~ /^$/ || $2 ~ /^!$/ {print $1}'
+1 good catch :)
– Rinzwind
10 hours ago
Thanks, it works. I just need to not include root user
– danaso
10 hours ago
Simplified:awk -F: '$2 ~ /^!?$/ {print $1}'- This combines the two match tests and says "match a dollar sign at the beginning of the field, optionally (?) preceded by a!"
– Dennis Williamson
27 mins ago
add a comment |
All users with a password set can be listed like this:
getent shadow | egrep '^[^:]*:[*!]:' -v | cut -f1 -d:
add a comment |
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
});
}
});
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%2f1163551%2fawk-to-get-all-my-regular-users-in-shadow%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to escape the $, as it is a special char for "End of Line" much like ^ is "Beginning of Line".
sudo getent shadow | awk -F: '$2 ~ /^$/ || $2 ~ /^!$/ {print $1}'
+1 good catch :)
– Rinzwind
10 hours ago
Thanks, it works. I just need to not include root user
– danaso
10 hours ago
Simplified:awk -F: '$2 ~ /^!?$/ {print $1}'- This combines the two match tests and says "match a dollar sign at the beginning of the field, optionally (?) preceded by a!"
– Dennis Williamson
27 mins ago
add a comment |
You need to escape the $, as it is a special char for "End of Line" much like ^ is "Beginning of Line".
sudo getent shadow | awk -F: '$2 ~ /^$/ || $2 ~ /^!$/ {print $1}'
+1 good catch :)
– Rinzwind
10 hours ago
Thanks, it works. I just need to not include root user
– danaso
10 hours ago
Simplified:awk -F: '$2 ~ /^!?$/ {print $1}'- This combines the two match tests and says "match a dollar sign at the beginning of the field, optionally (?) preceded by a!"
– Dennis Williamson
27 mins ago
add a comment |
You need to escape the $, as it is a special char for "End of Line" much like ^ is "Beginning of Line".
sudo getent shadow | awk -F: '$2 ~ /^$/ || $2 ~ /^!$/ {print $1}'
You need to escape the $, as it is a special char for "End of Line" much like ^ is "Beginning of Line".
sudo getent shadow | awk -F: '$2 ~ /^$/ || $2 ~ /^!$/ {print $1}'
edited 10 hours ago
answered 10 hours ago
pLumopLumo
10.5k21 silver badges48 bronze badges
10.5k21 silver badges48 bronze badges
+1 good catch :)
– Rinzwind
10 hours ago
Thanks, it works. I just need to not include root user
– danaso
10 hours ago
Simplified:awk -F: '$2 ~ /^!?$/ {print $1}'- This combines the two match tests and says "match a dollar sign at the beginning of the field, optionally (?) preceded by a!"
– Dennis Williamson
27 mins ago
add a comment |
+1 good catch :)
– Rinzwind
10 hours ago
Thanks, it works. I just need to not include root user
– danaso
10 hours ago
Simplified:awk -F: '$2 ~ /^!?$/ {print $1}'- This combines the two match tests and says "match a dollar sign at the beginning of the field, optionally (?) preceded by a!"
– Dennis Williamson
27 mins ago
+1 good catch :)
– Rinzwind
10 hours ago
+1 good catch :)
– Rinzwind
10 hours ago
Thanks, it works. I just need to not include root user
– danaso
10 hours ago
Thanks, it works. I just need to not include root user
– danaso
10 hours ago
Simplified:
awk -F: '$2 ~ /^!?$/ {print $1}' - This combines the two match tests and says "match a dollar sign at the beginning of the field, optionally (?) preceded by a !"– Dennis Williamson
27 mins ago
Simplified:
awk -F: '$2 ~ /^!?$/ {print $1}' - This combines the two match tests and says "match a dollar sign at the beginning of the field, optionally (?) preceded by a !"– Dennis Williamson
27 mins ago
add a comment |
All users with a password set can be listed like this:
getent shadow | egrep '^[^:]*:[*!]:' -v | cut -f1 -d:
add a comment |
All users with a password set can be listed like this:
getent shadow | egrep '^[^:]*:[*!]:' -v | cut -f1 -d:
add a comment |
All users with a password set can be listed like this:
getent shadow | egrep '^[^:]*:[*!]:' -v | cut -f1 -d:
All users with a password set can be listed like this:
getent shadow | egrep '^[^:]*:[*!]:' -v | cut -f1 -d:
answered 10 hours ago
RinzwindRinzwind
220k29 gold badges425 silver badges567 bronze badges
220k29 gold badges425 silver badges567 bronze badges
add a comment |
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.
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%2f1163551%2fawk-to-get-all-my-regular-users-in-shadow%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
does it have to be awk? :-)
– Rinzwind
10 hours ago