Find the answer to your Linux question:
Results 1 to 8 of 8
Hi Frndz Is there any command to delete all the users at once. Iam using #userdel -r 'username' and it works kool, but i want to delete all the user ...
  1. #1
    Linux Newbie
    Join Date
    Aug 2008
    Posts
    119

    COMMAND for deleting all usera at once

    Hi Frndz

    Is there any command to delete all the users at once.
    Iam using

    #userdel -r 'username'

    and it works kool, but i want to delete all the user at once.
    Plz help me out of this

    Thanks in Advance

  2. #2
    Just Joined!
    Join Date
    May 2009
    Posts
    9
    why cant it can be done through scripting...

    list and for loop can do that

    thanks
    Rasal

  3. #3
    Linux Newbie
    Join Date
    Aug 2008
    Posts
    119
    HI rasalp

    Its a nice idea but i dont no this scripting and am just new to linux
    Can u just help me to do this.

    Thanks in Advance

  4. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    Rather than giving you the loaded gun, helping put it to your head, and then assisting you to pull the trigger, why don't you tell us why you need to be able to do this?
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  5. #5
    Linux Newbie
    Join Date
    Aug 2008
    Posts
    119
    Hi Rubberman

    I am not able to get u.

    MY PROB IS I HAVE CREATED 15 USERS IN MY REDHAT-4 AND I WANT TO DELETE ALL THE USERS AT ONCE

    If can just help me

    Thanks in Advance

  6. #6
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    The Linux OS creates a number of special user accounts automatically. You do not want to delete those. Assuming you are using normal security on your system, then the fastest/easiest way is as root to edit the files /etc/passwd and /etc/shadow, removing the entries for the users you want to delete. Then go to /home and remove their directories and data with the command "rm -rf username".
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  7. #7
    Just Joined!
    Join Date
    May 2009
    Posts
    6
    This solution does not stop you from having to type out the names of all 15 users, but it still prevents you from having to type "userdel" 15 times.

    Code:
    for nnn in user1 user2 user3 user4; do
       userdel -r $nnn
    done

  8. #8
    Just Joined!
    Join Date
    May 2009
    Posts
    9
    Run this script under /home
    will delete the users created.

    ch=`ls`
    ch1="lost+found"
    for i in $ch
    do
    if [ $i = $ch1 ]
    then
    echo "Could Not Be Deleted"
    else
    userdel -r $i
    echo $i " is deleted"
    fi
    done

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...