Skip to main content

Howto: Linux Kill and Logout Users

Howto: Linux Kill and Logout Users


http://www.cyberciti.biz/tips/howto-linux-kill-and-logout-users.html

. One of such utility is skill which is responsible to send a signal to users and process such as:
  • Halt user terminal
  • Kill user and logout
# skill -STOP -u vivek
 # skill -CONT -u vivek
# skill -KILL -u vivek

Task: Kill and Logout All Users

# skill -KILL -v /dev/pts/*

pkill command syntax

pkill -KILL -u {username}

kill command

To halt or stop a user called vivek, enter:
# pkill -STOP -u vivek
To resume a user called vivek, enter:
# pkill -CONT -u vivek
To kill all php-cgi process owned by vivek user, enter:
# pkill -KILL -u vivek php-cgi

 

pkill -9 -t pts/0
 
pkill -9 -t pts/tty-number. -t is the switch to specify tty 


How to logout or kill other user session?

Well, let’s start saying that you need to be root to do that, and that it is not polite or a good idea to do that, unless that user is not logged with permission.
It is always better to politely ask her to logout by herself, using the wall, command. But, let’s suppose you really want to logout that user. Use the command skill
skill -KILL -u [user]
Replace [user] with the username of the user you want to kill, if you only want to stop for a while his / her session, enter at prompt as root:
skill -STOP -u [user]
Once you decide to let [user] continue using the system run:
skill -CONT -u [user]
Once again replase [user] with the username of the user you want to interact with.
Read skill man page, for more options.

How to setup auto logout time in a CLI

We can set up automatic logout for root session so that session gets logged off, if it is idle for a while. It is important to know this as any sneaker can misuse the situation, when a root user leaves the session idle. The method is very simple and as follows:

01. Locate the system file
[root@daddylinux~]#nano .bashrc

02. Go to under the #user specific aliases and functions line and then type
TMOUT=60

03. Save this file
Ctrl + O

04. Exit the file
Ctrl + X

Here TMOUT is an environment variable which instructs the bash shell to exit if the session is idle. Here timeout is set as 300 seconds (5 minutes).

Comments

Popular posts from this blog

AMD Graphic Driver (Radeon 6400 series) Install on Linux CentOS-6.2 x86_64 bit

Add-on in Dell vostro 3350 laptop for AMD Catalyst™
driver Radeon HD 6400 series graphic card in CentOS 6.2 x86_64 Linux
Step1: Update the CentOS with following packages
# yum install kernel-devel kernel-headers gcc gcc-c++

Now download the driver from the amd site http://support.amd.com/us/gpudownload/linux/Pages/radeon_linux.aspx

Step2: Now install AMD Graphic driver
#sh amd-driver-installer-12-4-x86.x86_64.run

Step3: check log file
#vim /usr/share/ati/fglrx-install.log

there will be an error like this

"ERROR: Module drm is in use by i915,drm_kms_helper"
.
.
"You must change your working directory to /lib/modules/fglrx
and then call ./make_install.sh in order to install the built module."

You can ignore these lines happily if they don’t contain any error message. You don’t really need to execute the command mentioned in those lines.

Step4: Blacklist radeon and radeonhd kernel modules

Add these lines to /etc/modprobe.d/blacklist.conf.

blacklist radeon
blacklist radeo…

Port forward of KVM Guest Virtual Machine through Host Machine using IPTABLE/FIREWALL in Linux System

Port forward of KVM Guest Virtual Machine through Host Machine using IPTABLE/FIREWALL in Linux System
There is a lot of method given in Internet for KVM guest machine port forwarding but I always look for the simple solution that can work in any Linux System.

I have issue during the port forward by IPTABLE/FIREWALL as it disable the Internet access within KVM guest machine.
If I look for Internet access within KVM guest machine then system disable port forwarding.

I have implement the simple solution in CentOS 6.5 x86_64 with can work in both situation as follows:

Step 1: Restart libvirtd service, so that it will modify your firewall rules as per KVM requirement.
# service libvirtd restart
Step 2: You need to add two rules in IPTABLE for NAT and FILTER
# iptables-save > iptable_save_default_libvirtd
# cp iptable_save_default_libvirtd iptable_modifed_libvirtd
# vim  iptable_modifed_libvirtd

Add line after *nat for SSH access

 -A PREROUTING -i eth0 -p tcp -m tcp --dport 222 -j DNA…

Yum command for download list of packages

Some time we need the download the software but not to install.
Also we have a list of software from repository in a text file but need to download by the yum.
To solve this kind of problem we need some trick of Linux,
download the package yum-downloadonly plugin
create a text file with rpm name.
now parse it to yum command
#yum install $(cat rpm-list.txt)

to download only the packages
#yum install <package name> --downloadonly --downloaddir=/home/user/

combine command
# yum install  $(cat rpm-list.txt) --downloadonly --downloaddir=/home/user

create a list from yum.log
#cp /var/log/yum.log /home/user/yum.log

select the package name only
# awk '{print $5}' /home/user/yum.log > rpm-list.txt

view the list
# cat rpm-list.txt

 to query about a package
# repoquery --list <package name>

to take information about package
#yum info <package name>

to show the list of packages
# yum list

to find a package for yum list
# yum list | grep <package name>