linux批量更改后缀名

一.rename解决

1. Ubuntu系统下

rename ‘s//.c//.h/’ ./*

把当前目录下的后缀名为.c的文件更改为.h的文件

2. CentOS5.5系统下

rename .c .h *.c

把当前目录下的后缀名为.c的文件更改为.h的文件

二.shell 脚本解决

#!/bin/bash

#http://blog.csdn.net/longxibendi
find ./ -name *.c | while read i
do
echo “$i”;
mv $i.c $i.h
done

三.find xargs 解决

find ./ -name “*.c” | awk -F “.” ‘{print $2}’ | xargs -i -t mv ./{}.c ./{}.h

注意,第三种方案是递归的更改,会更改当前目录下及其子目录下所有匹配文件

四.参考:

http://blog.csdn.net/longxibendi/archive/2010/09/16/5889055.aspx

Kernel Panic after Yum Update – CentOS with Hyper-V Linux Integration Components

I am runnning CentOS 5.5 in a VM on Hyper-V. I created a fresh installation. I then installed Hyper-V Linux Integration Components. After Installing them I ran yum update.

After running a “yum update”, and rebooting I received this error.

Unable to access resume device (/dev/VolGroup00/LogVol01)
mount: could not find filesystem ‘/dev/root’
setuproot: moving /dev failed: No such file or directory
setuproot: error mounting /proc: No such file or directory
setuproot: error mounting /sys: No such file or directory
switchroot: mount failed: No such file or directory
Kernel panic – not syncing: Attempted to kill init!

During the yum update process, it updated my kernel. Kernels that are installed after Hyper-V Linux Integration Components don’t always mesh well together. Here is how I fixed my issue.

While booting, grub will ask you to hit any key to boot into the menu.

Hit any key and you will see a list of the Linux kernels on your machine.

Mine looks like:

CentOS (2.6.19-194.26.1.el5)
CentOS (2.6.18-194.el5)

The first one(newest) is booting by default and causing the issues. I will select my old kernel for the time being so that I can boot into linux and fix the issue with the new kernel.

So I will select CentOS (2.6.18-194.el5) and boot into linux. At this point, it should boot into linux normally.

Now, virtually put in your Linux Integration Components V2.1 CD into the VM.
As root, run:

mkdir /opt/linux_ic_v21_rtm
cp -r /media/CDROM/* /opt/linux_ic_v21_rtm
cd /opt/linux_ic_v21_rtm
grep -ilR uname * | xargs sed -i ‘s/uname \-r/echo “2.6.19-194.26.1.el5″/g’
make && make install
reboot

Replace 2.6.19-194.26.1.el5 with the kernel that is giving you grief. If you forgot which kernel it was you can double check the /boot/grub/grub.conf file. Chances are its the one on the top.

After the reboot, it should be able to boot into the new kernel.

Squid配置

Squid代理服务器简介

Squid是一种在Linux系统下使用的优秀的代理服务器软件。

squid不仅可用在Linux系统上,还可以用在AIX、Digital Unix、FreeBSD、HP-UX、Irix、NetBSD、Nextstep、SCO和Solaris等系统上。

Squid是一个缓存internet数据的一个软件,它接收用户的下载申请,并自动处理所下载的数据。也就是说,当一个用户象要下载一个主页时,它向Squid发出一个申请,要Squid替它下载,然后Squid 连接所申请网站并请求该主页,接着把该主页传给用户同时保留一个备份,当别的用户申请同样的页面时,Squid把保存的备份立即传给用户,使用户觉得速度相当快。

对于Web用户来说,Squid是一个高性能的代理缓存服务器,可以加快内部网浏览Internet的速度,提高客户机的访问命中率。Squid不仅支持HTTP协议,还支持FTP、gopher、SSL和WAIS等协议。

实验环境:

系统 redhat linux 5.4
外网 eth0:192.168.0.1
内网 eth1:192.168.1.254
Squid Cache: Version 3.1.7

RPM安装,这里就不说明了。下载地址:http://www.squid-cache.org/

修改配置文件

[root@a ~]# cat /etc/squid/squid.conf

配置文件说明

定义acl访问控制元素:ip地址、端口

acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1

acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl localnet src fc00::/7 # RFC 4193 local private network range
acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines

acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT

acl worktime time 8:00-23:59 //定义工作时间
acl worktime time 00:00-5:59
http_access allow mynetwork !worktime //只允许非工作时间上网

访问控制设置
http_access allow manager localhost
http_access deny manager

# Deny requests to certain unsafe ports
http_access deny !Safe_ports 禁止非安全端口的访问

# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports

http_access allow localnet
http_access allow localhost

# And finally deny all other access to this proxy
http_access allow all 最好一条http_access设置默认访问规则

# Squid normally listens to port 3128
http_port 192.168.1.254:3128 transparent 代理服务器监听的地址及端口,transparent 为透明代理模式

# We recommend you to use at least the following line.
hierarchy_stoplist cgi-bin ?

# Uncomment and adjust the following to add a disk cache directory.
cache_dir ufs /var/spool/squid 1000 8 128 配置缓存文件的文件格式,缓存大小,缓存目录数

# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid

# Add any of your own refresh_pattern entries above these.
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320

visible_hostname 192.168.1.254
cache_mem 128 MB //squid服务器占用内存大小
forwarded_for off //不传递被代理地址
via off //不传递代理服务器信息

初始化squid代理服务器

squid -z

开启路由功能,并将下面的命令写入/etc/rc.d/rc.local 文件,使其开机自动开启路由功能

echo ‘1’ >/proc/sys/net/ipv4/ip_forward

配置iptables防火墙

自动将http请求转发到代理服务器上

iptables -t nat -A PREROUTING -i eth1 -p tcp –dport 80 -j REDIRECT –to-ports 3128

设置源地址映射

iptables -t nat -A POSTROUTING -j SNAT –to-source 192.168.1.254 (外网地址)

iptables -P INPUT ACCEPT

启动squid代理服务

[root@a ~]# service squid restart

查看squid代理服务器缓存日志

[root@a ~]# tail -f /var/log/squid/access.log

个人感觉使用缓存服务器之后网页访问速度有大幅度的加快。

Debian中网卡的设置

在Debian中网卡的设置可以通过/etc/network/interfaces文件来进行,具体可分为三种不同的配置方式:DHCP自动获取、静态分配IP地址和PPPoE宽带拨号。

具体设置如下:在进行配置之前,首先进入/etc/network目录中,编辑interfaces文件:

网卡通过DHCP自动获取IP地址

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

#
# The loopback network interface(配置环回口)

# 开机自动激lo接口
auto lo
# 配置lo接口为环回口
iface lo inet loopback

#
# The primary network interface (配置主网络接口)

#开机自动激活eth0接口
auto eth0
#配置eth0接口为DHCP自动获取
iface eth0 inet dhcp

网卡静态分配IP地址

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

#
# The loopback network interface(配置环回口)

# 开机自动激lo接口
auto lo
# 配置lo接口为环回口
iface lo inet loopback

#
# The primary network interface (配置主网络接口)

#开机自动激活eth0接口
auto eth0
#配置eth0接口为静态设置IP地址
iface eth0 inet static
address 10.16.3.99
netmask 255.255.255.0
network 10.16.3.0
broadcast 10.16.3.255
gateway 10.16.3.1

# dns-* options are implemented by the resolvconf package, if installed(DNS设置)
dns-nameservers 61.153.177.196 61.153.177.197
dns-search fireteam.org

网卡进行PPPoE宽带拨号配置

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

#
# The loopback network interface(配置环回口)

# 开机自动激lo接口
auto lo
# 配置lo接口为环回口
iface lo inet loopback

#
# The primary network interface (配置主网络接口)

#开机自动激活eth0接口
auto eth0
#配置eth0接口为静态设置IP地址
iface eth0 inet static
address 10.16.3.99
netmask 255.255.255.0
network 10.16.3.0
broadcast 10.16.3.255

配置完毕后,重启计算机或网络服务即可将网卡配好。如进行PPPoE宽带拨号,可运行pppoeconf命令进行配置。

解密DirectAdmin的Custombuild

1. What is custombuild?
Custombuild is a tool, which can install/update:

  • Apache 1.3, 2.0 or 2.2
  • AWstats
  • Autoconf
  • Automake
  • cURL
  • Dovecot
  • Exim configuration files
  • FreeType
  • GD
  • libiconv
  • libjpeg
  • libpng
  • libmcrypt
  • libmhash
  • mod_perl
  • MySQL
  • PHP (with or without suPHP) 4, 5 or 6
  • ProFTPD
  • Pure-FTPd
  • SpamAssassin
  • Webalizer
  • Zend Optimizer
  • Zlib

Update web-applications as:

  • Atmail Open webmail
  • Roundcube webmail
  • Squirrelmail webmail
  • phpMyAdmin
  • UebiMiau webmail

2. Why should I use it?
Custombuild is able to install PHP with suPHP, all versions of PHP (4,5,6), Pure-FTPd, SpamAssassin, ProFTPD, MySQL, Exim, RoundCube webmail, Atmail lite webmail, and so on. It has an options file, which allows you to use 2 copies of PHP, choose Apache 2.0 or 2.2, option to rewrite all configs if they got damaged etc. It can also show (./build versions) or update all needed software with only 1 command (./build update_versions). CustomBuild can send you email notifications about the updates too.

3. How to install custombuild?
1.1:

Code:
cd /usr/local/directadmin
wget http://files.directadmin.com/services/custombuild/1.1/custombuild.tar.gz
tar xvzf custombuild.tar.gz
cd custombuild
./build

1.2 BETA:

Code:
cd /usr/local/directadmin
wget http://files.directadmin.com/services/custombuild/1.2/custombuild.tar.gz
tar xvzf custombuild.tar.gz
cd custombuild
./build

When you edit options.conf file, run:

Code:
./build update_data

You need to run this command for the first time:

Code:
./build all d

4. How to use options.conf?

  • Do not set both CLI and CGI of the same PHP version to “yes”.
  • After the changes every time run “./build update_data”

5. How to see what’s set in the options.conf file?
Use “./build options” to see what’s set in the options.conf file. The output will be something like:

Quote:
Apache: 1.3.37
Dovecot: 1.0.3
MySQL: 5.0.45
PHP: 5.2.3 as CLI and 4.4.7 as CGI with mail() header patch
Run “clean” every time: yes

6. What each option does in options.conf?

PHP options:

  • default_php – this option is only used when 2 versions of PHP are installed on the system. Possible values: 4 (available only in 1.1 version of CustomBuild), 5, 6 (available from 1.2 version of CustomBuild) (default: the latest version of PHP)
  • php5_ver – select PHP5 branch. Possible values: 5.2, 5.3 (default: 5.2)
  • phpX_cli – install/update PHP as CLI (default option) using “./build php” or “./build all”. Possible values: yes/no (default: yes (for the latest version of PHP).
  • phpX_cgi – install/update PHP as CGI using “./build php” or “./build all”. Possible values: yes/no (default: no).
  • php_ini – update PHP configuration file using “./build php-ini” or “./build all”. Possible values: yes/no (default: no). This option is only available from CustomBuild 1.2.
  • php_ini_type – this option is used to set what type of php.ini file CustomBuild needs to use while executing “./build php-ini”. Possible values: dist/recommended (default: recommended). This option is only available from CustomBuild 1.2.
  • zend – install/update Zend Optimizer using “./build zend” or “./build all”. Possible values: yes/no (default: no).

MySQL options:

  • mysql – this option is used to choose the version of MySQL. Possible values: 4.1, 5.0, 5.1 (default: 5.0).
  • mysql_inst – install/update MySQL using “./build mysql” or “./build all”. Possible values: yes/no (default: no).
  • mysql_backup – backup MySQL every time with MySQL update. Possible values: yes/no (default: yes).

Apache options:

  • apache_ver – this option is used to choose the version of Apache. Install/update it using “./build apache”. Possible values: 1.3, 2.0, 2.2 (default: 2.2).

Web applications:

  • phpmyadmin – install/update phpMyAdmin using “./build phpmyadmin” or “./build all”. Possible values: yes/no (default: yes).
  • atmail – install/update Atmail Open webmail using “./build atmail” or “./build all”. Possible values: yes/no (default: no).
  • squirrelmail – install/update SquirrelMail webmail using “./build squirrelmail” or “./build all”. Possible values: yes/no (default: yes).
  • roundcube – install/update RoundCube webmail using “./build roundcube” or “./build all”. Possible values: yes/no (default: yes).
  • uebimiau – install/update UebiMiau webmail using “./build uebimiau” or “./build all”. Possible values: yes/no (default: no).

Mail options:

  • exim – install/update Exim using “./build exim” or “./build all”. Possible values: yes/no (default: no). This option is only available from CustomBuild 1.2.
  • mail-header-patch – use PHP mail() header patch whith PHP installation/update. Possible values: yes/no (default: yes). No longer available since PHP 5.3.0.
  • dovecot – install/update Dovecot using “./build dovecot” or “./build all”. Possible values: yes/no (default: yes).
  • eximconf – update exim configuration file (/etc/exim.conf) using “./build exim_conf” or “./build all”. Possible values: yes/no (default: no).

Jailed shell options:

  • jail – install/update jailed shell programs using “./build all_jail”. Possible values: yes/no (default: no).

FTP options:

  • proftpd – install/update ProFTPD using “./build proftpd” or “./build all”. Possible values: yes/no (default: yes).
  • pureftpd – install/update Pure-FTPD using “./build pureftpd” or “./build all”. Possible values: yes/no (default: no).

Statistics options:

  • awstats – install/update AWstats using “./build awstats” or “./build all”. Possible values: yes/no (default: no).
  • webalizer – install/update webalizer using “./build webalizer” or “./build all”. Possible values: yes/no (default: yes).

Crontab options:

  • cron – enable crontab for CustomBuild, use “./build cron” to set-up. Possible values: yes/no (default: no).
  • email – set email for notifications. Possible values: any email address (default: [email protected]).
  • notifications – enable email notifications about the updates. Possible values: yes/no (default: yes).
  • da_autoupdate – Update DirectAdmin automatically when update is available. Possible values: yes/no (default: yes).
  • updates – update software/applications automatically when updates are available. Possible values: yes/no (default: no).
  • webapps_updates – update (automatically) only web applications (as phpMyAdmin, RoundCube, Atmail, SquirrelMail etc.). Possible values: yes/no (default: no).

CustomBuild options:

  • custombuild – version of the CustomBuild script that you want to use. Possible values: 1.1/1.2 (default: your version).
  • autover – this option is used to download versions.txt every time with every “./build” command. Possible values: yes/no (default: no).
  • bold – turn bolded text on/off. Possible values: yes/no (default: yes).
  • clean – execute “./build clean” every time. Possible values: yes/no (default: yes).
  • cleanapache – exclude apache from “./build clean”. Possible values: yes/no (default: no). This option is only available from CustomBuild 1.2.
  • clean_old_tarballs – execute “./build clean_old_tarballs” every time. Possible values: yes/no (default: yes).
  • clean_old_webapps -execute “./build clean_old_webapps” every time. Possible values: yes/no (default: yes).
  • fileserver – this option is used to set the server to download files from. Value “1” means files.directadmin.com server and value “2” means files4.directadmin.com server (Europe). Possible values: 1/2 (default: 1). This option is only available from CustomBuild 1.2.

7. How to use suPHP?

  • Do not set chmod >755 to directories or files in them.

8. Where the suPHP log is located?

Code:
/var/log/suphp.log

9. Why do I get “500 Internal server error”?
Check your suPHP log for any errors. The most common issues are:

  • file or directory has chmod >755
  • file or directory is not owned by the user.

10. How do I include this script by default with the DirectAdmin install?
Type the following before running the setup.sh:
CustomBuild 1.1:

Code:
echo "1.1" > /root/.custombuild

CustomBuild 1.2:

Code:
echo "1.2" > /root/.custombuild

11. I’ve messed up my apache (httpd) configs, how I can restore working versions?
Type:

Code:
./build rewrite_confs

12. How to make PHP6, PHP5 or PHP4 default for 1 host if both are installed as CGI?
Add this to .htaccess for PHP4 as default:

Code:
<FilesMatch "\.(inc|php|php3|php4|php5|php6|phtml|phps)$">
AddHandler x-httpd-php4 .php
</FilesMatch>

Add this to .htaccess for PHP5 as default:

Code:
<FilesMatch "\.(inc|php|php3|php4|php5|php6|phtml|phps)$">
AddHandler x-httpd-php5 .php
</FilesMatch>

Add this to .htaccess for PHP6 as default:

Code:
<FilesMatch "\.(inc|php|php3|php4|php5|php6|phtml|phps)$">
AddHandler x-httpd-php6 .php
</FilesMatch>

13. How to make PHP6, PHP5 or PHP4 default for 1 host if it’s installed as CLI?
Add the following code to .htaccess:

Code:
<FilesMatch "\.(inc|php|php3|php4|php5|php6|phtml|phps)$">
AddHandler application/x-httpd-php .php
</FilesMatch>

14. How to update everything what’s needed?
Firstly, you need to run:

Code:
./build update

To fetch the latest versions file.

Run this if you want to look what updates are available:

Code:
./build versions

Run this if you want to update everything what’s possible:

Code:
./build update_versions

15. I have installed PHP6 (or PHP5, PHP4) as CGI. How do I need configure them?
PHP4 configuration file is located here: /usr/local/etc/php4/cgi/php.ini
PHP5 configuration file is located here: /usr/local/etc/php5/cgi/php.ini
PHP6 configuration file is located here: /usr/local/etc/php6/cgi/php.ini
suPHP configuration file is located here: /usr/local/suphp/etc/suphp.conf

16. I have installed PHP6 (or PHP5, PHP4) as CGI. Where can I find the bin file?
PHP4: /usr/local/php4/bin/php
PHP5: /usr/local/php5/bin/php-cgi
PHP6: /usr/local/php6/bin/php-cgi

17. I have installed both PHP5 and PHP6 (or PHP4) as CGI, but I see a CLI version in /usr/local/bin/php. Why?
CLI version of PHP is needed for DirectAdmin. It must exist as CLI for the DirectAdmin skins.

18. When I restart apache I get this error: Invalid command ‘suPHP_UserGroup’. How can I solve it?
Probably you had compiled suPHP manually with –with-setid-mode=owner. You need to compile it again with –with-setid-mode=paranoid, or do:

Code:
cd /usr/local/directadmin/custombuild
./build update
./build clean
./build suphp

19. I have installed PHP6 (or PHP5, PHP4) as CGI, but I can not use IP/~user now. Why?
http://help.directadmin.com/item.php?id=176

20. I have installed PHP as CGI and I get the “Invalid command ‘php_admin_flag’, perhaps misspelled or defined by a module not included in the server configuration error now. What do I need to do?
You have an old copy of DirectAdmin templates that only work with PHP as CLI. You need to update your copy of DirectAdmin and execute this command:

Code:
echo "action=rewrite&value=httpd" >> /usr/local/directadmin/data/task.queue

21. How to fix “gcc: /usr/lib/mysql/libmysqlclient.so: No such file or directory“?

Code:
cp /usr/lib/libmysqlclient.* /usr/lib/mysql/

For 64-bit OS:

Code:
cp /usr/lib/libmysqlclient.* /usr/lib64/mysql/

22. I have installed PHP as CGI and I get some errors when trying to use the webmail. Why?
You get them because some folders/files are owned by apache, and they need to be owned by the user. Use this to fix the problem:
Squirrelmail:

Code:
chown -R webapps:webapps /var/www/html/squirrelmail

Uebimiau (/webmail):

Code:
chown -R webapps:webapps /var/www/html/webmail

Roundcube:

Code:
chown -R webapps:webapps /var/www/html/roundcube

23. Is it possible to use custom configuration files for PHP, Apache, SuPHP?
Yes it is, CustomBuild checks for “custom” directory in /usr/local/directadmin/custombuild. So, just use:

Code:
cd /usr/local/directadmin/custombuild
cp -Rp configure custom

It will create custom directory for you, and now you can just edit configuration files from the custom directory. If you want – you can have only 1 custom configuration file, all the others will be used from “configure” directory then (and will be updated with “./build update”).

24. I made a script that installs apache modules automatically, but I need to include their settings into the httpd.conf file. Is there an easy way to do that?
CustomBuild creates ability to include modules settings easily into the apache configuration file. You just need to create a file in /etc/httpd/conf/extra (or the other directory) and include it in /etc/httpd/conf/extra/httpd-includes.conf. It will automatically load your settings and CustomBuild won’t rewrite the file with “./build rewrite_confs”. If you need a custom PHP or Apache configuration file – just upload it to custom directory. E.g. if you have /usr/local/directadmin/custombuild/custom/ap2/configure.php5 file it will use it instead of /usr/local/directadmin/custombuild/configure/ap2/configure.php5.

25. How to fix “configure: error: Size of “void *” is less than size of “long”“?
You do not have /usr/local/lib in /etc/ld.so.conf file. Use the following commands to fix the problem:

Code:
touch /etc/ld.so.conf
echo "/usr/local/lib" >> /etc/ld.so.conf
ldconfig

26. Is it possible to see what configuration files CustomBuild is using at the moment?
Yes, it is. CustomBuild has a new feature now:

Code:
./build used_configs

It will show something like:

Quote:
Apache configuration file: /usr/local/directadmin/custombuild/configure/ap2/configure.apache
PHP4 configuration file: /usr/local/directadmin/custombuild/custom/suphp/configure.php4
PHP5 configuration file: /usr/local/directadmin/custombuild/custom/ap2/configure.php5
ProFTPD configuration file: /usr/local/directadmin/custombuild/configure/proftpd/configure.proftpd

It will detect files from “custom” folder too.

27. I can not start apache because of “Invalid command ‘suPHP_Engine’, perhaps misspelled or defined by a module not included in the server configuration” error. What is wrong?
You have suPHP compiled in “owner” instead of “paranoid” mode. Use the following command to fix the problem:

Code:
./build suphp

28. Is it possible to change an option without editing options.conf file?
Yes, it is. Just run:

Code:
./build set option_name value

29. Is it possible to make PHP more secure using the CustomBuild script?
Yes, it is. You need to run “./build secure_php”. At the moment it disables some dangerous PHP functions as:

Code:
exec, system, passthru, shell_exec, escapeshellarg, escapeshellcmd, proc_close, proc_open, dl, popen, show_source

If you have any requests for the FAQ – feel free to post them into this thread.

重置DirectAdmin安装的Mysql的Root密码,并运行Mysql_secure_installation

DirectAdmin默认会安装WEB环境,装完的MYSQL没有给我们root密码,没法直接运行mysql_secure_installation。怎么办呢?

以下就是解决办法:

1.获得directadmin的mysql管理员密码。

路径是/usr/local/directadmin/conf/mysql.conf

2.利用mysql已经创建的MYSQL管理员账户重置ROOT密码。

mysql -u da_admin -p

mysql> SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘newpass’);

3.运行mysql_secure-installation

会提示输入root密码,输入你刚刚重置的密码即可。

PS:转载请注明出处,谢谢!

Debian/Ubuntu更换网卡换IP完美解决方案

第一步:修改网卡信息

 

修改文件/etc/udev/rules.d/z25_persistent-net.rules 文件,原来为:

protime-linux:/etc/udev/rules.d# cat z25_persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, probably run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single line.
# MAC addresses must be written in lowercase.
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM==”net”, DRIVERS==”?*”, ATTRS{address}==”00:0c:29:15:3a:48″, NAME=”eth0″
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM==”net”, DRIVERS==”?*”, ATTRS{address}==”00:0c:29:15:3a:52″, NAME=”eth1″
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM==”net”, DRIVERS==”?*”, ATTRS{address}==”00:0c:29:af:1c:c7″, NAME=”eth2″

修改后:

protime-linux:/etc/udev/rules.d# cat z25_persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, probably run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single line.
# MAC addresses must be written in lowercase.
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM==”net”, DRIVERS==”?*”, ATTRS{address}==”00:0c:29:15:3a:48″, NAME=”eth2″
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM==”net”, DRIVERS==”?*”, ATTRS{address}==”00:0c:29:15:3a:52″, NAME=”eth1″
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM==”net”, DRIVERS==”?*”, ATTRS{address}==”00:0c:29:af:1c:c7″, NAME=”eth0″

保存重启后可以看到原来的网络配置又回来了。
第二部:修改IP
debian的IP地址信息的文件是保存在/etc/network/interfaces,直接编辑该文件就可以。

#可以看到文件中的设置为动态IP的语句
iface eth0 inet dhcp

当然也可以设置为静态IP地址,如:

在 /etc/network/interfaces 中,删除 iface eth0 inet dhcp,添加一下内容

iface eth0 inet static
address 172.17.10.40
netmask 255.255.0.0
broadcast 172.17.0.255
network 172.17.0.0
gateway 172.17.10.100

重启网络
#/etc/init.d/networking restart

 

Linux设置网卡信息

建议通过终端字符方式下来修改
一修改IP地址
vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
IPADDR=192.168.1.33
NETMASK=255.255.255.0
ONBOOT=yes
TYPE=Ethernet
~

二修改网关
vi /etc/sysconfig/network

NETWORKING=yes
HOSTNAME=Shawn
GATEWAY=192.168.1.1

三重新启动网络配置
/etc/init.d/network restart

Ubuntu SSH: How To Enable Secure Shell in Ubuntu

SSH (Secure SHell) is possibly the best way to remotely access a Unix system – it’s very secure thanks to automatic encryption of all the traffic, and it’s also quite universal because you can do all sorts of things: access remote command line shell, forward graphics session output, establish network tunnels and set up port redirections. Today I’m going to show you how to get started with SSH in Ubuntu.

Installing SSH server in Ubuntu
By default, your system will have no SSH service enabled, which means you won’t be able to connect to it remotely using SSH protocol (TCP port 22). This means that installing SSH server will be one of the first post-install steps on your system.

The most common SSH implementation is OpenSSH server, and that’s exactly what you want to install.

Log in with your standard username and password, and run the following command to install openssh-server. You should be using the same username that you specified when installing Ubuntu, as it will be the only account with sudo privileges to run commands as root:

ubuntu$ sudo apt-get install openssh-server
[sudo] password for greys:
Reading package lists… Done
Building dependency tree
Reading state information… Done
Suggested packages:
rssh molly-guard openssh-blacklist openssh-blacklist-extra
The following NEW packages will be installed:
openssh-server
0 upgraded, 1 newly installed, 0 to remove and 75 not upgraded.
Need to get 285kB of archives.
After this operation, 782kB of additional disk space will be used.
Get:1 http://ie.archive.ubuntu.com jaunty/main openssh-server 1:5.1p1-5ubuntu1 [
285kB]
Fetched 285kB in 0s (345kB/s)
Preconfiguring packages …
Selecting previously deselected package openssh-server.
(Reading database … 101998 files and directories currently installed.)
Unpacking openssh-server (from …/openssh-server_1%3a5.1p1-5ubuntu1_i386.deb) .
..
Processing triggers for ufw …
Processing triggers for man-db …
Setting up openssh-server (1:5.1p1-5ubuntu1) …
Creating SSH2 RSA key; this may take some time …
Creating SSH2 DSA key; this may take some time …
* Restarting OpenBSD Secure Shell server sshd [ OK ]Verifying your SSH server works
While you’re still on your local desktop session, you can use the ps command to confirm that SSH daemon (sshd) is running:

ubuntu$ ps -aef | grep sshd
root 24114 1 0 15:18 ? 00:00:00 /usr/sbin/sshdNow that you see it’s there, it’s time to try connecting:

ubuntu$ ssh localhostSince this is the first time you’re trying to connect using SSH, you’ll have to answer yes to the following question:

The authenticity of host ‘localhost (::1)’ can’t be established.
RSA key fingerprint is 18:4d:96:b3:0d:25:00:c8:a1:a3:84:5c:9f:1c:0d:a5.
Are you sure you want to continue connecting (yes/no)? yes… you’ll then be prompted for your own password (remember, the system treats such connection request as if you were connecting remotely, so it can’t trust you without confirming your password):

Warning: Permanently added ‘localhost’ (RSA) to the list of known hosts.
greys@localhost’s password:.. and finally you’ll see the usual Ubuntu (Jaunty in this example) banner and prompt:

Linux ubuntu 2.6.28-11-generic #42-Ubuntu SMP Fri Apr 17 01:57:59 UTC 2009 i686

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

To access official Ubuntu documentation, please visit:

http://help.ubuntu.com/

Last login: Fri May 15 15:18:34 2009 from ubuntu
ubuntu$That’s it, providing you have your networking configured and you know your IP address or hostname, you can start connecting to your Ubuntu box from remote systems, using the same command. Enjoy!