Sponsored Content
Top Forums Shell Programming and Scripting Using userdel -r in a script? To delete multiple users. Post 302362361 by sol10admin on Thursday 15th of October 2009 06:35:23 PM
Old 10-15-2009
Thanks! That worked also. The only problem was that with TSOL the -r didn't work. So I just repeated my for statement as follows.
Code:
#!/bin/ksh
#
for user in $(< dellist.txt)
do
userdel r $user
done
#
for user1 in $(< dellist.txt)
do
rm -rM /home/$user1
done
#

PS. I don't mind the UUOC. Smilie

Last edited by pludi; 10-16-2009 at 02:22 AM.. Reason: co
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Need a script to delete multiple files

Hello, I am working with about 500,000 text files and 90% of them are duplicates. I need a way to delete the duplicate ones. The files are email messages with the following file name examples: 20040129-1457 This is the Subject line.txt 20040129-1457 This is the Subject line-1.txt... (3 Replies)
Discussion started by: navycow
3 Replies

2. Shell Programming and Scripting

Script to delete all data from multiple files

its urgent!!!!!!111 i need a script which can delete data from multiple files. plz if anybody knows the script plz write a mail to me : (Email addresses are not allowed) (5 Replies)
Discussion started by: uni_ajay_r
5 Replies

3. Shell Programming and Scripting

Need Script to delete multiple entries from a file

I am new to Linux and would appreciate some help. I need a script to do the following: My file contains the following entries more file 1 1 1 1 2 2 2 I want to delete multiple entries of 1 and 2 and just keep one of each. The output should look like more file 1 2 Thanks (1 Reply)
Discussion started by: sidewayz
1 Replies

4. Shell Programming and Scripting

script to delete multiple files in remote machine

Requirement Several files in remote machines ought to be deleted via sh. Name of the files to be deleted are know Approach 1) script was written with ftp (requires credential) and delete command. File names were passed as array(iterated via for loop-with ftp+delete commands enclosed within... (1 Reply)
Discussion started by: vkalya
1 Replies

5. Shell Programming and Scripting

Create multiple users with individual passwords to users

hi, i am new to shell scripts i write a shell script to create multiple users but i need to give passwords to that users while creating users, command to write this script (1 Reply)
Discussion started by: DONFOX
1 Replies

6. Shell Programming and Scripting

Script to add new users to a group on multiple servers using SSH

Hi Experts, I am new to scripting. We have around 400 Linux servers in our environment. I want to add a new user to a perticular group on all the servers using SSH. Requirements: 1) Need to take the server names from a text file. 2) Login into each server and check whether perticular... (1 Reply)
Discussion started by: Satya1983
1 Replies

7. Homework & Coursework Questions

Script to delete multiple users

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Hi This is my first post.I am learning Unix and finding it difficult to get a handle on the scripting side of... (5 Replies)
Discussion started by: dom17
5 Replies

8. Shell Programming and Scripting

Script To Delete User Accounts On Multiple Servers

Hello All, The servers in question are AIX/Unix servers. I was hoping to find a scripting solution where I could use one server as a jump server and run a script that would check each server for a user account (the source file for the user accounts would be a text file or csv file) , and delete... (4 Replies)
Discussion started by: k45bryant
4 Replies

9. Shell Programming and Scripting

Script to delete users in the servers

Hi Team, Hope you are doing good.I am new to scripting.I have a requirement of deleting around 10 users in 100 servers.It is very time consuming by logging into each servers and delete the user.Here I have redhat 6 ,Suse linux 10&11 environment servers. In one set of servers I have... (5 Replies)
Discussion started by: muraliinfy04
5 Replies

10. Shell Programming and Scripting

Shell script for creating multiple users with password

for UserName in `cat users` ; do useradd -d /u02 -s /usr/libexec/openssh/sftp-server -G ftp-users $UserName ; PassWord=$( echo $( tr '' '' <<< ${UserName:0:1} )${UserName:1} ) ; echo "$PassWord@123" | passwd $UserName --stdin ; done can some one explain what the bold text do Please use... (5 Replies)
Discussion started by: James0806
5 Replies
userdel(1M)						  System Administration Commands					       userdel(1M)

NAME
userdel - delete a user's login from the system SYNOPSIS
userdel [-r] login DESCRIPTION
The userdel utility deletes a user account from the system and makes the appropriate account-related changes to the system file and file system. OPTIONS
The following options are supported: -r Remove the user's home directory from the system. This directory must exist. The files and directories under the home directory will no longer be accessible following successful execution of the command. OPERANDS
The following operands are supported: login An existing login name to be deleted. EXIT STATUS
The following exit values are returned: 0 Successful completion. 2 Invalid command syntax. A usage message for the userdel command is displayed. 6 The account to be removed does not exist. 8 The account to be removed is in use. 10 Cannot update the /etc/group or /etc/user_attr file but the login is removed from the /etc/passwd file. 12 Cannot remove or otherwise modify the home directory. FILES
/etc/passwd system password file /etc/shadow system file contain users' encrypted passwords and related information /etc/group system file containing group definitions /etc/user_attr system file containing additional user attributes ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
auths(1), passwd(1), profiles(1), roles(1), users(1B), groupadd(1M), groupdel(1M), groupmod(1M), logins(1M), roleadd(1M), rolemod(1M), useradd(1M), userdel(1M), usermod(1M), passwd(4), prof_attr(4), user_attr(4), attributes(5) NOTES
The userdel utility only deletes an account definition that is in the local /etc/group, /etc/passwd, /etc/shadow, and /etc/user_attr file. file. If a network name service such as NIS or NIS+ is being used to supplement the local /etc/passwd file with additional entries, userdel cannot change information supplied by the network name service. SunOS 5.11 8 Sep 1999 userdel(1M)
All times are GMT -4. The time now is 03:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy