Skip to main content

192.168.1.1 > 新闻资讯 >

平时遇到问题的总结

2014-03-10 00:19 浏览:

查看某个程序被哪个端口占用

# lsof -i:3306

 

查看httpd连接数

# netstat -atp|grep httpd

 

如何将本地80端口的请求转发到8080端口,例如当前IP为192.168.1.8

iptables -t nat -A PREROUTING -d 192.168.1.8 -p tcp --dport 80 -j DNAT --to-destination 192.168.1.80:8080

 

查看某个网卡流量,或服务流量

ifstat,iftop,nethogs

 

内核参数修改文件

把参数添加到/etc/sysctl.conf中,然后执行sysctl -p使参数生效,永久生效

 

 

apache三种工作模式

preferk

worker

event

 

修改主机名

[root@salt-server ~]# cat /etc/sysconfig/network

NETWORKING=yes

HOSTNAME=salt-server

修改DNS

[root@salt-server ~]# cat /etc/resolv.conf

nameserver 202.106.0.20

 

修改本地hosts文件

[root@salt-server ~]# cat /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

 

修改本地网卡

[root@salt-server ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE="eth0"

HWADDR="00:0C:29:59:1C:19"

NM_CONTROLLED="yes"

ONBOOT="yes"

IPADDR=192.168.1.88

NETMASK=255.255.255.0

GATEWAY=192.168.1.1

 

添加默认网关

# route add default gw 192.168.2.1

 

服务开机自启动的三种方法

1种

[root@salt-server ~]# chkconfig sshd on

[root@salt-server ~]# chkconfig --list sshd

sshd            0:off   1:off   2:on    3:on    4:on    5:on    6:off

2种

[root@salt-server ~]# cat /etc/rc.local

3种

ln -s 在/etc/rc.d/rc*.d目录中建立/etc/init.d/服务的软链接(*代表0~6七个运行级别之一)

 

linux shell中$$、$#、#!、$*、$?、$@、$-、$0~$9含义

$$

shell本身PID(process ID)

#*

所有参数列表。如"$*"用「"」括起来的情况、以"$1 $2 … $n"的形式输出所有参数。

$@

所有参数列表。如"$@"用「"」括起来的情况、以"$1" "$2" … "$n" 的形式输出所有参数。

$#

添加到shell参数的个数

$?

最后运行的命令的结束代码(返回值)

$0~$9

$0代表shell本身的名字, $1~$9shell 后面可以最多有9个参数

$-

使用Set命令设定的Flag一览

 

自动修复磁盘

#fsck.ext4 -p /dev/sda2

相关文章

家里新装了宽度,怎么挑选路由器

2024-09-12 21:49:25    浏览: 154

中国人使用最多的十大路由器品牌,TP-LINK、华为、小米、水星路由器上榜

2024-09-12 21:43:21    浏览: 56

手机wifi显示已连接,却还是上不了网怎么办

2024-01-23 22:03:27    浏览: 121

普通用户装光纤宽带,能不折腾就别折腾,尤其是“老破小”

2023-01-28 19:43:36    浏览: 142

光猫可以设置WiFi,为什么还要买路由器?

2023-01-28 19:39:48    浏览: 165