一、修改hostname
1.使用hostname命令
[root@test ~]# hostname yourname
这样只是临时更改了主机名。
2.修改linux主机的配置文件/etc/sysconfig/network 和 /etc/hosts
(1).修改/etc/sysconfig/network里面的主机名字。
# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=yourname //在这修改hostname
GATEWAY=192.168.1.1 //你的IP地址
(2).修改/etc/hosts里面的名字
# vi /etc/hosts
127.0.0.1 localhost.localdomain localhost
192.168.1.121 yourname //在这修改hostname //你的IP地址
//有时候只有这一行
127.0.0.1 yourname localhost.localdomain localhost
(3).让更改的名字在不重启机器下生效
# hostname yourname
# su
二、ifconfig 提示“bash: ifconfig: command not found”
1.[root@localhost sbin]$ /sbin/ifconfig 就可以出现使用了
2.[root@localhost sbin]$ export PATH=$PATH:/sbin ,这样设置后,下次就可以直 接访问了,免处第一种的麻烦,如: [root@localhost /]$ ifconfig
三、关闭防火墙命令
1. 永久性生效,重启后不会复原
开启: chkconfig iptables on
关闭: chkconfig iptables off
2. 即时生效,重启后复原
开启: service iptables start
关闭: service iptables stop
需要说明的是对于Linux下的其它服务都可以用以上命令执行开启和关闭操作。
在开启了防火墙时,做如下设置,开启相关端口,
修改/etc/sysconfig/iptables 文件,添加以下内容:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT[/size]
CentOS一些常用命令
猜你喜欢
转载自lxzjsj.iteye.com/blog/1725393
今日推荐
周排行