nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

Shell script or code for deleting a user

This is a discussion on Shell script or code for deleting a user within the Shell scripting forums, part of the Development/Scripting category; hello i think this post doesnot have any meaning but as a newbie i need it .. so please help ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Linux answers from nixCraft.


Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 15-03-2007, 10:54 PM
Junior Member
User
 
Join Date: Mar 2007
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
narasimha.reddygnv
Default Shell script or code for deleting a user

hello
i think this post doesnot have any meaning but as a newbie i need it .. so please help me
i have made a script for adding a user (USiNG LINUX FEDORA 6)
now i want to delete the user .
could any one help me in writing the script ..


in the adding user program i have given permission as 777 for user & root
crated a home directory for user and givne him a password..
Reply With Quote
  #2 (permalink)  
Old 16-03-2007, 01:40 AM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,710
Thanks: 11
Thanked 245 Times in 184 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Pretty simple

Code:
#/bin/bash
read -p "Enter a User name to delete : " UNAME
grep $UNAME /etc/passwd >/dev/null

[ "$UNAME" == "root" ] && exit 1 || :

if [ $? -eq 0 ] ; then
  deluser $UNAME
 echo "User $UNAME has been deleted"
else
  echo "User $UNAME not found"
fi
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
  #3 (permalink)  
Old 16-03-2007, 07:23 PM
Junior Member
User
 
Join Date: Mar 2007
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
narasimha.reddygnv
Default thanks aaaaaaaa lot ..

thanks a lot
Reply With Quote
  #4 (permalink)  
Old 17-03-2007, 07:52 AM
Junior Member
User
 
Join Date: Mar 2007
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
narasimha.reddygnv
Default error: deluser comand not found .

the code is giving a error , command not found.
we are using linux fedora 6's terminal VI to do the program .
Reply With Quote
  #5 (permalink)  
Old 17-03-2007, 03:01 PM
Junior Member
User
 
Join Date: Mar 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
praveenmall
Default

Hello ,

change the script code userdel in place of deluser.

there is no command such deluser.

Let me know if does work.
Reply With Quote
  #6 (permalink)  
Old 19-03-2007, 10:07 AM
Junior Member
User
 
Join Date: Mar 2007
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
narasimha.reddygnv
Default yeah . working sucessfully

thns alot
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Shell code for Restoring cpmove accounts(bulk amount) vivekv Shell scripting 2 03-12-2007 09:56 PM
writing a shell script to find out my shell name jaymob123 Shell scripting 1 08-10-2007 12:36 AM
How can i create script for deleting user? Paul Shell scripting 1 02-08-2007 10:20 PM
script for mailing to user the o/p of the script ricc Shell scripting 3 11-07-2007 04:59 AM
How to change the login shell for Linux user chimu Getting started tutorials 0 26-01-2007 07:20 PM


All times are GMT +5.5. The time now is 05:21 PM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38