mmap – an effective way of reading/writing large files

When operating with files in programming, we often read entire file content into physical memory. While writing the code doesn’t take much time, what happens behind the scenes is far more complex. During the process, your program has to invoke multiple system calls between buffers in kernel and user spaces back and forth which is considered inefficient. When reading a large file, mmap(memory-mapped file) is preferred in the terms of performance.

Continue reading mmap – an effective way of reading/writing large files

Linux Iptables防火墙配置语句

  1. 首先放行回路接口与已建立链接以及ping响应:
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p icmp --icmp-type 0 -m state --state ESTABLISHED,RELATED -j ACCEPT
  1. 紧接着放行指定端口:
iptables -A INPUT -p tcp --dport 22 -j ACCEPT # 放行ssh端口
iptables -A INPUT -p 协议(tcp/udp) --dport 端口号 -j ACCEPT
iptables -A OUTPUT -p 协议 --sport 端口号 -j ACCEPT
  1. 拒绝所有其他链接:
iptables -A INPUT -j REJECT
  1. 保存iptables配置

service Iptables save 或者 iptables-save

CentOS/Linux Samba共享服务简单配置教程

samba服务就是windows系统上面的局域网文件/打印机共享,这里博主简单的教大家配置一下,这次配置的内容比较少,就配置一个用户,然后开放用户写入权限,禁止匿名登入。

CentOS/Linux Samba共享服务简单配置教程 - 1
首先进入etc/samba目录,然后编辑smb.conf配置文件

Continue reading CentOS/Linux Samba共享服务简单配置教程

Linux/CentOS配置DHCP服务器实现单网卡多网段分配地址

dhcp里面实现单网卡多网段的参数是share-network参数,而单网卡多网段的IP地址分配主要还是靠网关,客户机连接到哪个网关那么就分配那个网关的网段,不多说了,自己也不是很清楚,怕误导了你们。

Linux/CentOS配置DHCP服务器实现单网卡多网段分配地址 - 1
插入光盘,然后挂载/dev/cdrom到/mnt目录下,之后进入mnt目录

Continue reading Linux/CentOS配置DHCP服务器实现单网卡多网段分配地址