LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-03-2004, 06:14 AM   #1
Plauderer
LQ Newbie
 
Registered: Sep 2004
Posts: 6

Rep: Reputation: 0
Question can't 'userdel' OR How to fix a corrupt utmp?


I wanted to use "userdel -r username" to delete a user account. Now whenever i try it states "User username is currently logged in". But he isn't. When i try "ps -u username" i get no processes for this user. How do i get rid of this user?

I read somewhere else that i need to delete "/var/run/utmp" and to "touch" a new one. But i don't think that this is a good idea.
The funny thing is when i use the command "w" i see correctly only root as logged in. Only the command "users" shows me the "dead" user i want to delete. But i read somewhere that "w" is using the utmp database aswell.

Now i googled some infos bout this and it sems a common problem to have a corrupt utmp database. Does anyone know how to fix that without rebooting the machine?

Thanks in advance,
Plauderer
 
Old 09-03-2004, 06:30 AM   #2
masand
LQ Guru
 
Registered: May 2003
Location: INDIA
Distribution: Ubuntu, Solaris,CentOS
Posts: 5,522

Rep: Reputation: 69
hi

utmp is a file,and u cannot edit the file without the utmp functions
see
man setutent
if u want to delete the entry from the utmp file,then u need to use the functions defined in the above man comand
and do u get this error everytime and do that users log into ur machine sometime or not ??
and the /var/run/utmp file is deleted and created new after each reboot
there is a switch in "who" which allows u to use the file for list of users
use the /var/log/wtmp there
u will get a list of all users logged in to ur machine from the begining

regards
 
Old 09-03-2004, 06:50 AM   #3
Plauderer
LQ Newbie
 
Registered: Sep 2004
Posts: 6

Original Poster
Rep: Reputation: 0
First, thank you for your prompt answer!
Quote:
Originally posted by masand
hi

utmp is a file,and u cannot edit the file without the utmp functions
see
man setutent
if u want to delete the entry from the utmp file,then u need to use the functions defined in the above man comand
Don't have any such file / command. Maybe i have to install utmp-tools or something?
Quote:
and do u get this error everytime and do that users log into ur machine sometime or not ??
erm i think it was my own fault. I created the user for myself so i don't use root all the time. I logged in once and got stuck. So i killed the users processes. Since then i have this behaviour.
Quote:
and the /var/run/utmp file is deleted and created new after each reboot
I knew that already. It's just that i don't want to restart the machine only for this.
Quote:
there is a switch in "who" which allows u to use the file for list of users
use the /var/log/wtmp there
u will get a list of all users logged in to ur machine from the begining
I can't find a switch for who to choose wtmp as database. Neither in the manpages nor the info-section.

Thanks, Plauderer
 
Old 09-03-2004, 11:50 AM   #4
masand
LQ Guru
 
Registered: May 2003
Location: INDIA
Distribution: Ubuntu, Solaris,CentOS
Posts: 5,522

Rep: Reputation: 69
hi
if u could have gone throught the who --help throughly
section then u might have found out this

[root@gaurav root]# who --help
Usage: who [OPTION]... [ FILE | ARG1 ARG2 ]

-a, --all same as -b -d --login -p -r -t -T -u
-b, --boot time of last system boot
-d, --dead print dead processes
-H, --heading print line of column headings
-i, --idle add idle time as HOURS:MINUTES, . or old
(deprecated, use -u)
-l, --login print system login processes
--lookup attempt to canonicalize hostnames via DNS
-m only hostname and user associated with stdin
-p, --process print active processes spawned by init
-q, --count all login names and number of users logged on
-r, --runlevel print current runlevel
-s, --short print only name, line, and time (default)
-t, --time print last system clock change
-T, -w, --mesg add user's message status as +, - or ?
-u, --users list users logged in
--message same as -T
--writable same as -T
--help display this help and exit
--version output version information and exit

If FILE is not specified, use /var/run/utmp. /var/log/wtmp as FILE is common.
If ARG1 ARG2 given, -m presumed: `am i' or `mom likes' are usual.

Report bugs to <bug-coreutils@gnu.org>.

here it is spcifies that u can spcefy a differnt file for parsing
so when i run

[root@gaurav root]# who /var/log/wtmp
root :0 Sep 1 23:42
root pts/1 Sep 1 23:43
root pts/2 Sep 1 23:43
root pts/4 Sep 1 23:43
root pts/3 Sep 1 23:43
root pts/4 Sep 2 00:49
root :0 Sep 2 21:57
root pts/1 Sep 2 21:57
root pts/2 Sep 2 21:58
root pts/3 Sep 2 21:58
root :0 Sep 2 22:30
root pts/1 Sep 2 22:30
root pts/2 Sep 2 22:31
root pts/3 Sep 2 22:31
root pts/4 Sep 2 22:55
root pts/4 Sep 2 23:13
root pts/5 Sep 2 23:43
root pts/2 Sep 3 01:00
root pts/2 Sep 3 01:05
root pts/2 Sep 3 01:18
root :0 Sep 3 08:37
root pts/1 Sep 3 08:37
root pts/2 Sep 3 08:37
root pts/3 Sep 3 08:48
root pts/2 Sep 3 09:52
root :0 Sep 3 22:18
root pts/1 Sep 3 22:18
root pts/2 Sep 3 22:19
root pts/3 Sep 3 22:20
root pts/4 Sep 3 22:27
[root@gaurav root]#

i get the above

anfd this the output from my
man setutent command
utmpname() sets the name of the utmp-format file for the other utmp
functions to access. If utmpname() is not used to set the filename
before the other functions are used, they assume _PATH_UTMP, as defined
in <paths.h>.

setutent() rewinds the file pointer to the beginning of the utmp file.
It is generally a Good Idea to call it before any of the other func-
tions.

endutent() closes the utmp file. It should be called when the user
code is done accessing the file with the other functions.

getutent() reads a line from the current file position in the utmp
file. It returns a pointer to a structure containing the fields of the
line.

-------------------------------------

see if this help u

regards
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash: userdel: command not found dwdrumrboy Linux - Newbie 9 04-16-2005 11:47 AM
How do I fix corrupt video settings? MALDATA Linux - General 3 03-14-2005 11:26 AM
removing users with userdel linuxtesting2 Linux - Newbie 1 09-15-2004 01:35 AM
userdel command... should I run it? The_Nerd Linux - Software 2 09-12-2004 08:31 PM
Corrupt Zip/OpenOffice file - any way to fix? gazurtoids Linux - Software 0 12-09-2003 03:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:58 PM.

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