Shell script implementation turns off redundant TTY terminals _linux shell

Source: Internet
Author: User
Tags pkill

Today to optimize the company's new deployment servers, found that the TTY terminal has 6, in order to save a bit of memory, decided to leave only a TTY terminal, the others are off, but CENTOS6 and centos5 terminal closure method completely changed, and I am also lazy, do not want a set of a Taiwan, Writing down this foot would have saved time.

System: CentOS 6

Close TTY Terminal script:

Cat pkill.sh

Copy Code code as follows:

#!/bin/bash
Sed-i ' s/\/dev\/tty\[1-6\]/\/dev\/tty\[1-1\]/g '/etc/init/start-ttys.conf
Sed-i ' s/\/dev\/tty\[1-6\]/\/dev\/tty\[1-1\]/g '/etc/sysconfig/init
Ttypid= ' PS auxw|grep tty|grep-v grep |grep tty[2-6]|awk ' {print $NF} '
For i in $ttypid;d o initctl stop tty tty= $i;d One

To execute permissions after saving:


Copy Code code as follows:

chmod +x pkill.sh


The script is very simple, before you use the best to determine their own system, to avoid unnecessary errors.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.