add to sudoers and auto start services on Centos

How to add a CentOS user to the sudoers list

vi /etc/sudoers

...## Next comes the main part: which users can run what software on## which machines (the sudoers file can be shared between multiple## systems).## Syntax:####     user    MACHINE=COMMANDS#### The COMMANDS section may have other options added to it.#### Allow root to run any commands anywhere
root    ALL=(ALL)     ALL
youruser ALL=(ALL)  ALL

How to auto start services on boot in Centos / Redhat?

To auto start a new service:

  • Find out the name of service’s script from /etc/init.d/ directory e.g. mysqld or httpd
  • Add it to chkconfig
    sudo /sbin/chkconfig --add mysqld
  • Make sure it is in the chkconfig.
    sudo /sbin/chkconfig --list mysqld
  • Set it to autostart
    sudo /sbin/chkconfig mysqld on

To stop a service from auto starting on boot

  • sudo /sbin/chkconfig mysqld off

防火墙开放80端口

[root@localhost lele]# /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
[root@localhost lele]# /etc/rc.d/init.d/iptables save

如何修改centos等linux系统的hostname?重启后也生效

简单来说,uname -a 可以看到hostname,修改步骤如下:

  1. uname -a 查看hostname
  2. hostname www.ctohome.com 修改下,让hostname立刻生效。
  3. vi /etc/hosts 修改原hostname为 www.ctohome.com
  4. vi  /etc/sysconfig/network 修改原hostname为 www.ctohome.com,这样可以让reboot重启后也生效
  5. reboot重启,uname -a 重新检查下。收工

相关推荐