Results 1 to 5 of 5

Thread: Accidentaly Deleted my Linux Account

  1. #1
    Join Date
    Apr 2013
    Beans
    11

    Unhappy Accidentaly Deleted my Linux Account

    When i was making my Livecd manually because remastersys will not be up anymore soon, did not get what this command did below typed it in and deleted my account! i can still access my stuff through another Distro i have installed, but cannot login to the distro i put this command in! NOW I KNOW WHAT IT DOES LOL! do i need to reinstall that Distro??? i was wondering if i could go into recovery and drop down to a root shell and reinstall my account! Thank You! for any help given!
    for i in `cat /etc/passwd | awk -F":" '{print $1}'` do uid=`cat /etc/passwd | grep "^${i}:" | awk -F":" '{print $3}'` [ "$uid" -gt "998" -a "$uid" -ne "65534" ] && userdel --force ${i} 2>/dev/null done
    Last edited by thisislinuxdj; May 10th, 2013 at 09:13 PM.

  2. #2
    Join Date
    Nov 2008
    Location
    S.H.I.E.L.D. 6-1-6
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: Accidentaly Deleted my Linux Account

    Try
    Code:
    useradd username --gid username --groups adm,cdrom,sudo,dip,plugdev,lpadmin,sambashare -d /home/username -M -N -s /bin/bash
    Replace username with your username (also /home/username)
    Last edited by sandyd; May 11th, 2013 at 02:37 AM. Reason: fixed another of my famous typos
    Don't waste your energy trying to change opinions ... Do your thing, and don't care if they like it.

  3. #3
    Join Date
    Apr 2011
    Location
    Mystletainn Kick!
    Beans
    13,616
    Distro
    Ubuntu

    Re: Accidentaly Deleted my Linux Account

    ^ Would the above command need a sudo?
    Splat Double Splat Triple Splat
    Earn Your Keep
    Don't mind me, I'm only passing through.
    Once in a blue moon, I'm actually helpful
    .

  4. #4
    Join Date
    May 2010
    Location
    uk
    Beans
    9,249
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: Accidentaly Deleted my Linux Account

    Hi

    Slight typo by sandyd.

    Code:
    UN="<Your_username>" && sudo useradd --gid $UN --groups adm,cdrom,sudo,dip,plugdev,lpadmin,sambashare -d /home/$UN -M -N -s /bin/bash $UN
    Change <Your_username> to your user name.

    It assumes that your main user group still exists (-N). This is probably a valid assumption.

    It assumes you still have your home directory (-M) and that switch was most probably put in there for this comment.

    i can still access my stuff through another Distro i have installed, but cannot login to the distro i put this command in!
    However, from man userdel.

    -f, --force
    This option forces the removal of the user account, even if the user is still logged in. It also forces userdel to
    remove the user's home directory
    and mail spool, even if another user uses the same home directory or if the mail spool
    is not owned by the specified user. If USERGROUPS_ENAB is defined to yes in /etc/login.defs and if a group exists with
    the same name as the deleted user, then this group will be removed, even if it is still the primary group of another
    user.
    Code:
    for i in `cat /etc/passwd | awk -F":" '{print $1}'`  
    do     uid=`cat /etc/passwd | grep "^${i}:" | awk -F":" '{print $3}'`
          [ "$uid" -gt "998" -a  "$uid" -ne "65534"  ] && 
    userdel  --force ${i} 2>/dev/null done


    Are you sure you can access your home directory ? I would check you still have a home directory. If not the above command will need tweaking.

    userdel --force will delete a user .

    Kind regards
    Last edited by matt_symes; May 10th, 2013 at 11:26 PM.
    If you believe everything you read, you better not read. ~ Japanese Proverb

    If you don't read the newspaper, you're uninformed. If you read the newspaper, you're mis-informed. - Mark Twain

    Thinking about becoming an Ubuntu Member?

  5. #5
    Join Date
    Apr 2013
    Beans
    11

    Red face Re: Accidentaly Deleted my Linux Account

    Thank You Guys for Reply's! Will try them when have time!

Tags for this Thread

Bookmarks

Posting Permissions

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