I had Redhat Linux 6.x which was recently upgraded to the Redhat 7 box. Previously I used to use the below command to kill the linux sessions. But now I am getting the the below error if I try to kill multiple sessions.

$ skill -kill pts/1 pts/0  pts/3
Memory fault

As per man pages I also tried but that also did not work.

skill -KILL -t /dev/pts/*
        Kill users on PTY devices.

I need to kill sessions in Redhat 7.


One possible answer if users are connected through ssh:

pkill -f <myusername>@pts/1

For other cases :

who -u 

end then kill pid(s), or for example to kill all user sessions except root's one:

$ who -u | awk '!/^root /{print $6}' |xargs sudo kill
  • Thanks @tonioc for pkill suggestion. I liked it. Plus 1. I will wait till tomorrow to see if someone can advise why skill is not working. If not I will accept this as an answer. – Forever Learner Feb 21 '18 at 14:12

Noting that skill's man page says:

These tools are probably obsolete and unportable. The command syntax is poorly defined. Consider using the killall, pkill, and pgrep commands instead

I believe the syntax you're looking for is:

skill -t pts/0 -t pts/1 -t pts/3

... as it appears that the expression syntax requires one tty per -t flag.

As to why skill is not actually killing the processes, my suspicion is that the format of /proc/PID/stat changed since skill was compiled, causing it to skip past the process in the check_proc function (in an arbitrary github copy of skill.c I found). It appears to parse /proc/PID/stat manually, and never sends a kill signal to the process(es):

open("/proc/21102/stat", O_RDONLY)      = 4
read(4, "21102 (bash) S 21101 21102 21102"..., 128) = 128


open("/proc/22839/stat", O_RDONLY)      = 4
read(4, "22839 (view) S 21102 22839 21102"..., 128) = 128

When I compile a fresh copy of skill, it functions as intended:

open("/proc/22926/stat", O_RDONLY)      = 4
read(4, "22926 (bash) S 22925 22926 22926"..., 128) = 128
readlink("/proc/22926/tty", 0x7f3e47e073e0, 127) = -1 ENOENT (No such file or directory)
readlink("/proc/22926/fd/2", "/dev/pts/2", 127) = 10
kill(22926, SIGKILL)                    = 0

I would follow the suggestion of the manpage and tonioc and switch to pkill; for example, to kill processes on pts/1 and/or pts/2:

pkill -HUP -t pts/1,pts/2
  • Thanks Jeff Schaller for detailed explanation. Upvoted and Yes I will use pkill. – Forever Learner Feb 26 '18 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.