Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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
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.
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
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.