centos升级内核教程

当前系统为CentOS Linux release 6.0 (Final),内核版本为2.6.32-71.el6.i686.由于最近内核出现最新的漏洞(linux kernel 又爆内存提权漏洞,>=2.6.39 内核无一幸免 http://blog.zx2c4.com/749 和http://www.haohtml.com/news/netsafe/47456.html),所以将内核升级至3.2.2最新版本.

1.查看当前系统内核

[root@bogon linux-3.2.2]# uname -r
2.6.32-71.el6.i686

2.下载linux-3.2.2内核包

cd ~
wget -c http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.2.2.tar.bz2
tar jxvf  linux-3.2.2.tar.bz2
cd linux-3.2.2

3.配置内核并安装

make mrproper #清除环境变量,即清除配置文件
make menuconfig #在菜单模式下选择需要编译的内核模块

Continue reading

Linux中各种文件系统基本特性ext2,ext3,ext4

各种文件系统基本特性
Ext2Ext2 文件系统是Linux 特有的文件系统,它拥有传统UNIX 文件系统的许多特性,如块、inode
和目录等概念。Ext2 非常健壮,具有很多优良的性能。同时,Ext2 也是可扩展的,它提供
的扩展功能允许用户在不格式化文件系统的情况下使用新的特性。
—————————————————-
最大文件大小: 1TB
最大文件极限: 仅受文件系统大小限制
最大分区/文件系统大小: 4TB
最大文件名长度: 255 字符
缺省最小/最大块大小: 1024/4096 字节
缺省inode 分配: 每4096 字节为1
在强制FS 检查前的最大装载: 20(可配置)
—————————————————- Continue reading

lsof命令详解

卸载移动存储时经常提示device busy,也可能误删了一个正在打开的文件。。。。
这时候可以试试lsof

lsof简介 

lsof(list open files)是一个列出当前系统打开文件的工具。在linux环境下,任何事物都以文件的形式存在,通过文件不仅仅可以访问常规数据,还可以访问网络连接和硬件。所以如传输控制协议 (TCP) 和用户数据报协议 (UDP) 套接字等,系统在后台都为该应用程序分配了一个文件描述符,无论这个文件的本质如何,该文件描述符为应用程序与基础操作系统之间的交互提供了通用接口。因为应用程序打开文件的描述符列表提供了大量关于这个应用程序本身的信息,因此通过lsof工具能够查看这个列表对系统监测以及排错将是很有帮助的。

lsof使用 

lsof输出信息含义
在终端下输入lsof即可显示系统打开的文件,因为 lsof 需要访问核心内存和各种文件,所以必须以 root 用户的身份运行它才能够充分地发挥其功能。

COMMAND    PID      USER   FD      TYPE     DEVICE     SIZE       NODE      NAME
init       1         root  cwd      DIR       3,3       1024       2         /
init       1         root  rtd      DIR       3,3       1024       2         /
init       1         root  txt      REG       3,3       38432      1763452  /sbin/init
init       1         root  mem      REG       3,3       106114     1091620  /lib/libdl-2.6.so
init       1         root  mem      REG       3,3       7560696    1091614  /lib/libc-2.6.so
init       1         root  mem      REG       3,3       79460      1091669  /lib/libselinux.so.1
init       1         root  mem      REG       3,3       223280     1091668  /lib/libsepol.so.1
init       1         root  mem      REG       3,3       564136     1091607  /lib/ld-2.6.so
init       1         root  10u      FIFO      0,15                  1309     /dev/initctl

每行显示一个打开的文件,若不指定条件默认将显示所有进程打开的所有文件。 Continue reading

在FreeBSD系统中用pkill命令踢出SSH在线登录用户

FreeBSD是一个多用户多任务的操作系统,用户可以在不同地方通过ssh连上FreeBSD服务器,在系统中我们可以使用w命令来查看当前在线登录用户。

[root@host01 ~]# w

03:05:23 up 19 min, 3 users, load average: 0.00, 0.03, 0.05
USER TTY FROM   LOGIN@ IDLE WHAT
root p0 192.168.0.2 01:39 6:52 /usr/bin/perl
root p1 192.168.0.31 01:45 0.00s w
root p2 192.168.0.23 01:52 2.00s -bash

看到了吧,已经有3个用户登录到服务器了。接下来使用who am i 看那个是自己的登录终端,下面自己是pts/1

[root@host01 ~]# who am i
root p1 2009-08-02 03:06 (192.168.0.31)

接下来使用pkill命令将要其它的用户踢出,这里为p0和p2。 Continue reading

VSFTP中”Fixing 500 OOPS: vsftpd: refusing to run with writable root inside chroot ()”的解决办法!

今天在参考以前写的在FreeBSD下配置vsftpd教程http://blog.haohtml.com/archives/7213的时候.发现以下错误:

After upgrading vsftpd to 2.3.5 you may be getting the following message when trying to log in.

500 OOPS: vsftpd: refusing to run with writable root inside chroot ()

This is due to the following update:

– Add stronger checks for the configuration error of running with a writeable
root directory inside a chroot(). This may bite people who carelessly turned
on chroot_local_user but such is life.

The problem is that your users root directory is writable(用户根目录可写), which isn’t allowed when using chroot restrictions in the new update. The following command will fix this problem, replace the directory with your users root:

chmod a-w /home/user

好吧,我们如果启用chroot,必须保证ftp根目录不可写,这样对于ftp根直接为网站根目录的用户不方便,所以建议假如ftp根目录是/home/user,那么网站结构可以这样分,/home/user/log为日志目录,/home/user/web为网站根目录,这样我们就可以去掉/home/user目录的写入权限而不影响网站的正常运行

FreeBSD中重新分区提示”ERROR: Unable to write data to disk ad0! To edit the lables on a running system set sysctl kern.geom.debugflags=16 and try again.”的解决办法

今天将FreeBSD系统重新安装系统的时候.将原来的分区全部删除.进行重新分区,而按下W进行分区保存的时候.提示以下错误:

ERROR: Unable to write data to disk ad0! To edit the lables on a running system set sysctl kern.geom.debugflags=16 and try again.

解决办法如下:

用root权限运行以下任何一条命令:
#sysctl -w kern.geom.debugflags=16
或者
#sysctl  kern.geom.debugflags=16

你可以用sysctl -a查询你系统的所有内核子系统的配置参数,在具备权限的情况下,你可以修改配置变量,其中有一些只读的属性无法修改,有一些属性只能在开机时设定而不是运行时动态修改的也不能改(这些参数/属性在/boot/loader.conf中调整和修改)