Linux - NewbieThis 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
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'm not an expert at any of this but, you could use the "userdel" command to remove the friends account. I have no idea why it shows that he is still logged in. But anyway, suppose your friends user name is "friend1" or something like that. You could type this:
userdel -r friend1
I believe the "-r" will cause the files in the user's home directory will be removed along with the home directory itself and the user's mail spool. You can look up more about the "userdel" command by typing this:
man userdel
It sounds like you know how to tell if some one is logged in. One way to tell if someone is currently logged in is to type this:
Erm... the command "users" shows my friend to be logged in but "w" shows only roots and myself...
I can't use userdel because i'm prompted with error stating that the user is still logged in.
where <username> is the login-username of the user you want to remove. if you have created a home directory, for example, too and want to remove it and all the files in it also when you remove the user, use
userdel -r <username>
instead. the -r switch means "remove user files too"...for more details, check
Another way to approach this problem is to use the "kill" command. If you can not log him out you may need to find his process ID number and use the "kill" command to kill the process. To find his process ID number you can use the "top" command and look for a proccess ID next to his name. You could type this:
top
Suppose that you find that his process ID number is 1792 or something like that (it will actually be a different number on your system). Then type this:
kill 1792
You might also want to look those commands up using the "man" command.
On my computer there are always dozens of processes listed under "top". There are always some processes running. Some of the processes are controlled by me and some by root. If the top command did not work you could look at all processes with this command instead:
ps -A
I may have possibly been wrong when I suggested that you could use the "kill" command to log him out. B0uncer's suggestion to change the runlevel might be better. Perhaps using the "init" command did not work properly for some reason. You might need to manually edit the inittab file to change the run level. The inittab file is located in the /etc directory. I am not sure which distro you are using or which text editor you use. But, suppose you use "gedit", when you are logged in as root you could type this to edit the file:
gedit /etc/inittab
Once the file is open you should see two lines that looks something like this:
# Default runlevel. (Do not set to 0 or 6)
id:3:initdefault:
The line with the "#" sign in front is just a comment. On the next line you need to change the 3 to a 1. You can then save the change and reboot. You should then be in single user mode. That sould do the same thing as what the "init 1" command should have done.
Was ssh already running by default when you installed Linux? Do you actually have any reason to have that running? For now at least you might want to shut down the sshd daemon that ssh uses. With most versions of Linux (but not Slackware) you could temporarily shut the sshd daemon down with this command:
/etc/rc.d/init.d/sshd stop
That will only temporarily stop the sshd daemon and prevent using ssh and sftp for now. It will not keep it from automatically starting up when you reboot.
You might also want to see what processes (if any) that the user is using. Suppose his username is "jimbo", then you could use this command to see what processes jimbo is using:
ps -u jimbo
If you can not delete his account for some reason then you should probably at least use the "passwd" command to change his password. If his name was jimbo you could type this:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.