nixCraft Linux Forum

nixCraft

Linux 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

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 03-15-2007, 11:54 PM
Junior Member
User
 
Join Date: Mar 2007
Posts: 14
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
Sponsored Links
  #2 (permalink)  
Old 03-16-2007, 02:40 AM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,036
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 | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
  #3 (permalink)  
Old 03-16-2007, 08:23 PM
Junior Member
User
 
Join Date: Mar 2007
Posts: 14
Rep Power: 0
narasimha.reddygnv
Default thanks aaaaaaaa lot ..

thanks a lot
Reply With Quote
  #4 (permalink)  
Old 03-17-2007, 08:52 AM
Junior Member
User
 
Join Date: Mar 2007
Posts: 14
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 03-17-2007, 04:01 PM
Junior Member
User
 
Join Date: Mar 2007
Posts: 8
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 03-19-2007, 11:07 AM
Junior Member
User
 
Join Date: Mar 2007
Posts: 14
Rep Power: 0
narasimha.reddygnv
Default yeah . working sucessfully

thns alot
Reply With Quote
Reply

Bookmarks


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 On

Similar Threads

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


All times are GMT +5.5. The time now is 09:00 PM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

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