Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
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.
This might be the wrong forum, but it seemed like it might get the proper exposure here. Please excuse me if I was wrong.
I am trying to find a command that will simply logout all users and close all sessions on a machine with a single command or at least as simply as possible.
I am playing with remote access to one of my machines and in the proccess I have frequently wound up with multiple sessions on the target machine from the same user (root, I know, I know), thus sucking resources which is counter productive to what I'm trying to accomplish with the remote logins. Is there a simple way to log EVERYONE out so that I can just log back in after all those resources should, in theory at least, be released?
Thanks for the response. The command didn't work (it gave errors about "kill usage" and proccesses that didn't exist which is weird), but it taught me enough to find one that would work and that was 99% of the solution.
WARNING IF ANYONE TRIES THIS: NO DATA WILL BE SAVED AND THIS IS INSTANT.
I composed the first part of the command, using 'echo' instead of 'kill' (so that I wouldn't actually log myself out), then got it slightly wrong when I pasted it in.
I'm still looking at the command that you gave
Code:
kill `ps -ef | egrep '(tty|pts)'`
I'm slightly disturbed by this. If I replace 'kill' with 'echo':
What's happening is that everything emitted by "ps -ef | egrep '(tty|pts)'" is being used as an argument to 'kill'. This includes a lot of extraneous stuff, such as the process owner, the time the process was spawned, which tty it was spawned from... which should be relatively harmless, as well as the process ID of the login process that you're trying to kill... but then it also includes the process ID of the parent process. In several cases, this is the PID of init (which is '1'). Killing init will take your whole system down, and fast... and even if you don't have permissions to kill init, you probably don't want to kill the other parent processes.
This is why I included the 'awk' statement, which specified only the PIDs of the processes that I wanted to kill.
As an aside, there are also a few stylistic issues with that line: back-ticks are generally deprecated in favor of '$()', and piping arguments to xargs is always better than feeding arguments through command substitution.
I took this output to all be related to user-logins. In this case my current login which should be the only one on the machine........I think. What I do know is that it returned me to the kdmchooser which then allowed me to log back in and went from 5.5 of 6 gigs of ram being used to .5 which is all I was really after since what I'm actually doing is to use the power and speed of the Slack machine while a few things like amarok continue to run on the local machine. It's actually faster to do it this way than to be local to either machine alone.
I would definitely be interested in a cleaner way to do this, it seems like there would HAVE to be. The part about having to do it remotely is the hardest part it seems, because the machine has to be immediately available for remote logins or it does me no good. I would never consider my method for a production environment, or if there were useful processes running on the remote machine. (I'm just trying to let my sick wife get some rest! lol).
The awk command has the magic though, it cuts out the second column:
Definitely more elegant.
Quote:
As an aside, there are also a few stylistic issues with that line: back-ticks are generally deprecated in favor of '$()', and piping arguments to xargs is always better than feeding arguments through command substitution.
I've heard this before. What is the reasoning for this, as backticks sure are easier to type! As a here-to-now-point-and-clicker I definitely have an affinity for things that don't requier SHIFT+TOP_ROW_KEYS! The command I gave was actually my first forray into any extended command option/piping.
I've heard this before. What is the reasoning for this, as backticks sure are easier to type! As a here-to-now-point-and-clicker I definitely have an affinity for things that don't requier SHIFT+TOP_ROW_KEYS! The command I gave was actually my first forray into any extended command option/piping.
1) Backticks are hard to read... it's often hard to tell them apart from single quotes, which is a significant difference.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.