To exclude users in password file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting To exclude users in password file
# 1  
Old 02-15-2015
Question To exclude users in password file

Hi,

I want to exclude the users below 500 in the password file with the below script.

Code:
#!/bin/bash

# get date in dd-mm-yyyy format
NOW=$(date +"%d-%m-%Y")

exec > "/root/SYSINFO/User_details_`uname -n`_$NOW.txt"

cut -d: -f1 /etc/passwd > /tmp/pass.txt && for i in `cat /tmp/pass.txt`;
do
echo ====== USERS $i =======;
chage -l $i;
done

# 2  
Old 02-16-2015
And then get stuck with your system?
Who is below 500 ?
# 3  
Old 02-16-2015
Code:
awk -F: '$3 >= 500 {print $1}' /etc/passwd

Moderator's Comments:
Mod Comment
Please wrap all code, files, input & output/errors in CODE tags.
It makes it far easier to read and multiple spaces are preserved.

Last edited by rbatte1; 02-16-2015 at 01:39 PM.. Reason: Added CODE tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to match certain users from password file?

I need to match all users starting from ab and cd. All the users are having five letters in total. ie: ab123 I tried below, but many other users with more than five letters are also appearing. I need to catch only users starting with ab & cd that has only five letters. possible? awk -F: '$1 ~... (3 Replies)
Discussion started by: wimaxpole
3 Replies

2. Solaris

How to programmatically reset a users password.?

Hello all, I have a small C++ app for my solaris admins. I need to set it up so they can reset a users password. The admin does not have the old password. How can I reset a users password to a temp password either using passwd or PAM? I need to do this from within my C++ app. I have searched... (3 Replies)
Discussion started by: ChickenPox
3 Replies

3. Solaris

Change password for users

I am on SunOS SolarisServer 5.11 11.1 i86pc i386 i86pc , I am trying to change password for a user,but I get the following message.I cannot find any google help on the matter.can anyone help? root@SolarisServer:~# passwd passwd: Changing password for stain Please try again Please try... (6 Replies)
Discussion started by: cbtshare
6 Replies

4. Ubuntu

[Solved] Using Find with an exclude/exclude file

I am familiar with using tar and exclude/include files: tar zcf backup.dirs.tgz --files-from=include.mydirs --exclude-from=exclude.mydirs --no-recursion but was wondering if I could use find in the same way. I know that you can just specify the directories to exclude but my list is... (2 Replies)
Discussion started by: metallica1973
2 Replies

5. Shell Programming and Scripting

Users who have never changed their password from /etc/shadow.

Hello, I have to do a script which returns users who have never changed their password from /etc/shadow. Here is what have I done and I'm not sure if it's ok. I tried to return just users who doesn;t have password set or are locked. Can be there other kind of user who never changed the... (3 Replies)
Discussion started by: catalint
3 Replies

6. UNIX Desktop Questions & Answers

Too many users with root password

Hi there, I'm working with a Linux server and now I can get a daily Logwatch mail ... my question is:since there are too many users with root password (...in my opinion... :mad:) how could I prevent to delete information about "su" log? Thanks in advance, GB (3 Replies)
Discussion started by: Giordano Bruno
3 Replies

7. Shell Programming and Scripting

script to change password for all users

We have a server where we have a number of user ids and we also have the list of old passwords in a CSV file. Now we want to change the password of all the users and assign them a default password.Can we write a shell script to do that. I am planning to read the user name and corresponding... (7 Replies)
Discussion started by: dr46014
7 Replies

8. Shell Programming and Scripting

Help- Change the password of users to common one

Hi all I have some 106 users of which i need to change the password of them to a common one. I dont know their paswword. But i need to reset them to a common one. How can i do this with a shell script? It would be a great help if some one can help to sort out this.:b::b: I know it can be... (0 Replies)
Discussion started by: Tuxidow
0 Replies

9. UNIX for Dummies Questions & Answers

Have users changed their password

How can I know users have changed their passwords ? I don't need their password (!) I have to know if they have changed their pass word and when ? Thank you in advance for any SIMPLE answer. (6 Replies)
Discussion started by: annemar
6 Replies

10. UNIX for Dummies Questions & Answers

Setting password restrictions for all users

I would like to change the password requirements for all our AIX 5.2 logins but am having trouble finding a place where I can set the rules for everyone at the same time. I know I can go user by user in smit passwords but is there a way to create rules for everyone at the same time? Thanks,... (2 Replies)
Discussion started by: drathbone
2 Replies
Login or Register to Ask a Question