一、修改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常用命令: CentOS一些常用的命令,查看CPU,内存,sed,gawk,关机重启等。
Centos 常用命令 总结 实例 Centos常用命令总结实例
CentOS 常用命令在我们的使用中经常被使用。所以对一些经常使用又很重要的 CentOS 常用命令进行了下面的收集。这里简单介绍这 些 CentOS 常用命令。
CentOS常用命令大全整理
centOS7常用命令资料整理
Centos7 linux 常用的命令指令,方便操作centos7系统!!
centos7系统的常用命令,服务器日常使用到的基本和必备命令,强烈推荐入手一本,内容非常详细。
CentOS常用命令大全,新手入门必看哦~
centOS 下SSH常用命令!
CentOS常用命令
使用CentOS常用命令查看cpu使用CentOS常用命令查看cpu
Centos常用的命令.txt
CentOS常用命令[定义].pdf
这个是centos开机常用的命令,包括换源,但是里面的源有时候不稳定
实用的命令集合: 1、端口情况:netstat -npl 2、查看进程: ps aux | grep mysqld 3、安装ftp服务: yum install vsftpd 启动service vsftpd start 4、查看系统使用情况:登录用户数,运行时间等等 uptime 5、rpm -...
centos常用命令.txt
Linux初学 CentOS 常用命令
centos (linux) shell常用命令实例手册大全,包括:常用shell命令、语法、环境配置、实例、mysql、jdk、hadoop、hdfs、keepalive、文件操作、软件安装、系统、权限、服务、网络、磁盘管理 等各个方面的shell实例
CentOS常用命令大全.docx