LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-14-2018, 09:23 AM   #1
ruben_shah_j
LQ Newbie
 
Registered: Jul 2018
Posts: 9

Rep: Reputation: Disabled
Question Is there any possibility to delete an user using uid??


I was trying to remove some user from my linux system and I checked is there any possibility to delete user using user id but i couldn't find anything related to that.....
 
Old 08-14-2018, 10:14 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,879
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
The command to delete a user is userdel(8).
 
1 members found this post helpful.
Old 08-14-2018, 10:17 AM   #3
ruben_shah_j
LQ Newbie
 
Registered: Jul 2018
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rtmistler View Post
The command to delete a user is userdel(8).
is there any way i can use the user id with this command
 
Old 08-14-2018, 10:23 AM   #4
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,879
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Quote:
Originally Posted by ruben_shah_j View Post
is there any way i can use the user id with this command
Please read the manual page for the command. It tells you the requirements and limitations for the command. It is the only way I'm aware of to delete a user, excepting a radical thing like reinstalling the OS (not recommended).
 
1 members found this post helpful.
Old 08-14-2018, 11:32 AM   #5
lougavulin
Member
 
Registered: Jul 2018
Distribution: Slackware,x86_64,current
Posts: 279

Rep: Reputation: 100Reputation: 100
To use userdel, you need to be root. So, the only way I see is to do a script which use /etc/passwd to get the username from the uid. Then call userdel with the username found.
But I don't understand the requirement of UID use.
 
1 members found this post helpful.
Old 08-14-2018, 03:07 PM   #6
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,779

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
An example script
Code:
lookup=4711
username=`getent passwd "$lookup" | cut -f1 -d:`
if [ -n "$username" ]
then
  echo "running 'deluser $username'"
  deluser "$username"
else
  echo "$lookup not found"
fi
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Change uid from user who had uid=0 (but not is root) rockyx Linux - General 10 04-27-2017 01:49 PM
Possibility to delete /tmp directory content? lensilvan Slackware 26 12-02-2015 09:17 AM
avoiding allocate uid/gid belonged to delete's users erodri07 Linux - Security 7 06-18-2012 06:32 PM
[SOLVED] multiple user accounts with uid 0 . I want to delete all user names except "root" m00seman645 Linux - Newbie 2 10-21-2011 01:56 PM
Is there a possibility to configure iptables depending on the user ? xpucto Linux - Security 4 06-24-2008 12:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration