2011年9月30日星期五

linux中的cron服务

[root@huage ~]# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 1 * * * root run-parts /etc/cron.daily
03 2 * * 0 root run-parts /etc/cron.weekly
04 3 1 * * root run-parts /etc/cron.monthly

       The first four lines are variables used to configure the environment in which the cron tasks are run. The SHELL variable tells the system which shell environment to use (in this example the bash shell), while the PATH variable defines the path used to execute commands. The output of the cron tasks are emailed to the username defined with the MAILTO variable. If the MAILTO variable is defined as an empty string (MAILTO=""), email is not sent. The HOME variable can be used to set the home directory to use when executing commands or scripts.
 
      As shown in the /etc/crontab file, the run-parts script executes the scripts in the /etc/cron.hourly/, /etc/cron.daily/, /etc/cron.weekly/, and /etc/cron.monthly/ directories on an hourly, daily, weekly, or monthly basis respectively. The files in these directories should be shell scripts.

      If a cron task is required to be executed on a schedule other than hourly, daily, weekly, or monthly, it can be added to the /etc/cron.d/ directory. All files in this directory use the same syntax as /etc/crontab.

      Users other than root can configure cron tasks by using the crontab utility. All user-defined crontabs are stored in the /var/spool/cron/ directory and are executed using the usernames of the users that created them. To create a crontab as a user, login as that user and type the command crontab -e to edit the user's crontab using the editor specified by the VISUAL or EDITOR environment variable. The file uses the same format as /etc/crontab. When the changes to the crontab are saved, the crontab is stored according to username and written to the file /var/spool/cron/username.

      The cron daemon checks the /etc/crontab file, the /etc/cron.d/ directory, and the /var/spool/cron/ directory every minute for any changes. If any changes are found, they are loaded into memory. Thus, the daemon does not need to be restarted if a crontab file is changed.

Controlling Access to Cron
      The /etc/cron.allow and /etc/cron.deny files are used to restrict access to cron. The format of both access control files is one username on each line. Whitespace is not permitted in either file. The cron daemon (crond) does not have to be restarted if the access control files are modified. The access control files are read each time a user tries to add or delete a cron task.

      The root user can always use cron, regardless of the usernames listed in the access control files.

      If the file cron.allow exists, only users listed in it are allowed to use cron, and the cron.deny file is ignored.

      If cron.allow does not exist, users listed in cron.deny are not allowed to use cron.

2011年9月28日星期三

经典实用的Shell命令

1.[root@desktop huage]# yum provides */filename
   查找filename是由哪个RPM包提供

2.[root@desktop huage]# locate filename
   快速查找名为filename的文件

3.[root@desktop huage]#rename .JPG .jpg *.JPG
   批量修改文件的后缀名(适用于redhat分支)

4.[root@desktop huage]#ls |grep jpg|awk -F'.' '{print $1}'|xargs -i mv {}.jpg {}.JPG
   批量修改文件的后缀名(两组单引号之间有个空格)

   [root@desktop huage]# ls |grep jpg|awk -F'.' '{print $1}'|xargs -i -t mv {}.jpg {}.JPG
   批量修改文件的后缀名(-t:详细显示xargs命令后面的操作)

5.[root@Server huage]# ls |grep -v  rpm$ |xargs -i -t rm -rf {}
   删除当前目录下所有后缀不是rpm的文件(包括目录文件)

6.[root@Server huage]# ls -F |egrep -v "rpm$|/$" |xargs -i -t rm -rf {}
   删除当前目录下所有后缀不是rpm的文件(不包括目录文件)

7.[root@Server huage]# find . -type f -print |grep -v rpm$ |xargs -i -t rm -rf {}
   删除当前目录及其子目录下所有后缀不是rpm的文件

8.[root@Server huage]# ls -lSh
   用易于人类读写的单位按从大到小的顺序排序(主要用于文件的排序,不统计目录的具体大小)

9.[root@Server huage]# ls -lShr
   用易于人类读写的单位按从小到大的顺序排序(主要用于文件的排序,不统计目录的具体大小)

10.[root@Server huage]# ls |xargs du -sh |sort -h
     用易于人类读写的单位按从小到大的顺序排序(包括目录)

11.[huage@fedora ~]$ script
     记录接下来的所有终端输出

12.[huage@fedora ~]$ script huage
     记录所有终端输出到文件huage

13.[huage@fedora ~]$ time shell-command
     对shell-command命令计时,time后直接跟shell命令即可

14.[root@Server tmp]# find . -type f -exec chmod 644 {} \;
     或者:
     [root@Server tmp]# find . -type f -exec chmod 644 {} +
     将当前目录及其子目录下的所有文件的权限设为644

15.[root@Server tmp]# find . -type d -exec chmod 755 {} \;
     或者:
     [root@Server tmp]# find . -type d -exec chmod 755 {} +
     将当前目录及其子目录的权限设为755

16.[root@fedora huage]# find . -type f |xargs chmod 644
     将当前目录及其子目录下的所有文件的权限设为644(如果目录名中包含空格,则chmod对该目录无效)

17.[root@fedora huage]# find . -type d |xargs chmod 755
     将当前目录及其子目录的权限设为755(如果目录名中包含空格,则chmod对该目录无效)

注:在18和19例中,如果文件(包括目录文件)名中包含空格,则chmod命令对该文件无效,实际上是xargs命令无法正确处理文件名中包含空格的文件和目录文件。

28.[root@fedora huage]# python -m SimpleHTTPServer
     通过python的SimpleHTTPServer模块来快速搭建一个HTTP Server,之后可以通过 
     http://server-ip:8000或者http://localhost:8000来访问

19.[root@fedora huage]#
mail admin@huage.com -s "Backuping HUA is successfully done" < /root/huage/backup
用一条命令来发送邮件给admin@huage.com,且主题为"Backuping HUA is successfully done",邮件正文内容为"/root/huage/backup"。

20.[root@fedora huage]# mail huage@gmail.com -s "Backuping ADG is successfully done" < /root/hauge/backup-adg -- -f admin@google.com -F "The Admin of Google"

      发送一封主题为"Backuping ADG is successfully done"、邮件正文为"/root/hauge/backup-adg"的内容、发件人为admin@google.com且发件人显示名称为"The Admin of Google"的邮件给huage@gmail.com

21.[root@fedora huage]# du -sh /home/huage/public_html |mail -s "Moving Successful" huage@gmail.com -- -f admin@google.com -F "The Admin of Google"

      发送一封以"Moving Successful"为主题、以"du -sh /home/huage/public_html"输出内容为邮件正文、以admin@google.com为发件人且发件人的显示名称为"The Admin of Google"的邮件给huage@gmail.com

自动备份网站根目录

Auto backup up the root directory of website(自动备份网站根目录):

root@huage [~/huage]# cat /usr/local/bin/hua-backup
#!/bin/bash
HUA=/home/huage/
NAME=hua-`date +%Y%m%d`.tgz
cd $HUA
rm -rf public_html/bmz_cache/*
echo "Cache is cleaned."
tar -zcvf $NAME public_html
echo "The backuping process is successfully done."
mail admin@huage.com -s "Backuping HUA is successfully done" < /root/huage/backup
echo "Everything is successful completion."
exit 0

然后使用"crontab -e"命令编辑root用户的crontab文件,加入如下一行:
"0 0 * * 0 /usr/local/bin/hua-backup >/dev/null 2>&1"
,然后保存文件到"/var/spool/cron/root"就行了。

注:虽然hua-backup脚本放在系统PATH路径中,但/etc/crontab单独定义了"PATH=/sbin:/bin:/usr/sbin:/usr/bin",所以此处的脚步文件仍然要写完整路径,否则计划不能成功执行。

2011年9月27日星期二

你们在哪里

西摩.西蒙斯:多年以后 他们会问我们 
                   他们占领这星球的时候 你们在哪里?
                   我们回答说
                   我们只是袖手旁观
                                              ——变形金刚3 

海盗湾宣言

      请记住,我们是关不掉的!各位,你们可能已经听说了,那些家伙又一次试图关闭我们。他们不会成功的。我们的带宽提供商是好人,所以我们决定把网站搬个地方,不让他们为难。海盗湾是不会沉没的。只要我们愿意,它将永远航行在互联网上。请记住这一点。自从2003年海盗湾上线以来,他们从我们这里得到的,只是一次又一次的失败。

      只要这个世界还有一个热爱自由的人存在,我们就不会下线。

      那些与互联网为敌的人们,你们是不会成功的。(多么激动人心的宣言啊!
    
                                                                                                                ——海盗湾
  

我们被判有罪

我们被判有罪,这真是相当令人惊奇的事,他们也可以罚款我们一亿美元,这无关紧要,因为我们不能也不会做出赔偿。

                          ——海盗湾的四名创始人之一彼得·桑德·科尔米索皮(Peter Sunde Kolmisoppi)

2011年9月26日星期一

Firefox经典实用扩展

1.Adblock Plus
有了Adblock Plus,广告已成往事

2.AutoProxy
翻墙必备,翻墙于无形,撞墙已成往事

3.Domain Hammer SEO Analysis
简洁实用的SEO工具

4.DownThemAll!
下载必备,支持断点续传,同时也能限速

5.Firebug
给力的Web开发工具,也可以用来查看访问一个网址所请求的所有HTTP Request

6.FireGestures
鼠标手势,好网民必备

7.Flagfox
显示当前网站服务器所在的地理位置和域名所属区域

8.Forecastfox
一个非常好的显示天气的扩展

9.IE Tab 2
使Firefox也能使用IE核心浏览一些必需用IE的网站(如网银)

10.LastPass
最好的密码管理工具,没有之一

11.ReminderFox
好用的事件提醒扩展

12.Tab Mix Plus(Firefox Add-ons中已经搜索不到了)
增强标签浏览体验

13.Tamper Data
追踪所有HTTP Request

14.Xmarks
最好的书签同步扩展,没有之一 

用screen命令来管理远程会话

screen -S http:创建一个名为http的会话
screen -ls:列出当前的所有screen会话
screen -d:分离所有会话,切换到Shell控制台
screen -d http:将名为http的会话分离出来
screen -r http:恢复一个状态为Detached的会话
screen -d -r http:先将一个状态为Attached的会话Detached掉,然后再Attached
screen -x   Attach to a not detached screen session. (Multi display mode).
screen -x http:将一个名为http且状态为Attached的screen会话Attach,之后所有处于http screen会话中的虚拟终端的所有操作都将同步,操作任何一个http screen会话,其他的http screen会话会显示相同的操作(适用于一人操作,其他人观看学习)

screen程序的快捷键:
Ctrl-a d:分离当前screen会话(先按住Ctrl,然后依次按a、d键),退到Shell控制台
exit:退出当前的screen终端

Shell Script的基本格式

1.开始行一般是命令解释器,由#!+解释器的路径构成,Shell脚本的命令解释器一般为bash,即/bin/bash,所以Bash Shell脚本的第一行一般为#!/bin/bash;

2.结束行一般是exit 0;

注:在linux的Shell脚本中"#!"是一个双字节的magic number,而在某些BSD系统中,其脚本开始行是由"#! /bin/sh"构成,即"!"感叹号后面加了个空格,然后再加脚本解释器的路径,在这些系统中"#! "是一个4字节的magic number。

运维法则

1.使用screen命令来管理会话
在远程管理中为避免出现突然断开连接造成的损失,登录后应使用screen命令来创建和管理虚拟终端,这样即使断开了,之前的会话也可以恢复;

2.用script命令来记录屏幕输出
有些输出可能会因为显示的行太多而不会再显示,特别是在控制台操作时,所以登录终端后应使用script命令来记录所有操作及终端输出;

3.备份配置文件
在修改任何配置之前都应该先备份配置文件,当确认新的配置文件无误的时候,再删除备份的就配置文件;

2011年9月25日星期日

linux下的任务计划之cron

1./etc/crontab文件
root@godontop [~]# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *   *  *   *  *  command to be executed

hour中的0表示午夜
crontab -l:显示当前用户的任务计划列表
crontab -u huage -l:显示用户huage的任务计划列表
crontab -e:编辑当前用户的任务计划列表
crontab -u huage -e:编辑用户huage的任务计划列表

crontab由6部分组成,前5列表示时间,第六列表示要执行的命令、脚本或程序等;
在时间列中,"*"星号表示所有可能的值,"-"中划线表示2个值闭区间内的所有值,","逗号(英文状态下)表示所有指定值都符合条件,"/"反斜杠表示除,或者说是每隔多长时间执行一次;

1,9,16 0-10 * */2 6 tar -zcvf www.tgz www
表示每隔一个月月内所有周六的午夜0点到上午10的1分、9分、16分执行打包任务

如何知人

一:问之以是非而观其志;
二:穷之以辞辨而观其变;
三:咨之以计谋而观其识;
四:告知以祸难而观其勇;
五:醉之以酒而观其性;
六:临之以利而观其廉;
七:期之以事而观其信。
                  
注:摘自诸葛亮《心书》。

2011年9月24日星期六

Windows下的防火墙汇总

1.Windows 防火墙
日志做的不错,前面就有ALLOW和DROP,可以一眼让人看出数据包有没有被丢弃,但有些程序被阻止并没有通知,这点让人很不爽,现在很多程序的运行都要调用其他程序,但Windows防火墙只提醒些主程序,完全不给力;

2.PC Tools Firewall Plus
除已信任的程序外,有任何的网络连接都会弹出窗口提醒,这让机器的运行变得透明起来,很好,但当应用程序升级后(酷我音乐盒),却一直弹,点击信任该程序也无效,让人烦了,直接卸了;

2011年9月23日星期五

Windows下使用SSH-D来翻墙

翻墙组合上场:
Firefox + AutoProxy + SSH-D + Bitvise Tunnelier
Firefox + AutoProxy + SSH-D的设置这里就不说了,主要讲Bitvise Tunnelier的设置。

1.填写服务器端的相关信息(如服务器的IP、端口、用户名和密码等);

2.设置相关的附加选项,如自动连接、不打开Terminal、不打开SFTP等;

3.设置本地代理,设置本地代理时,端口要与AutoProxy中的SSH-D端口一致;

4.成功连上服务器后,会看到"Initializing SOCKS / HTTP CONNECT proxy on 127.0.0.1:7070 succeeded.",至此Bitvise Tunnelier的设置全部OK。

linux下踢出已登录用户

linux下踢出已登录用户
[root@huage ~]# pkill -kill -t pts/1
 pts/1代表用户登录的终端号,可以用w命令查看

[root@huage ~]# w
 16:26:42 up 3 min,  2 users,  load average: 0.01, 0.03, 0.01
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/0    192.168.1.16     16:23    3:20   0.03s  0.00s man pkill
root     pts/2    192.168.1.16     16:24    0.00s  0.03s  0.00s w

2011年9月21日星期三

私生女

    一首长的女儿偶遇一打工妹,见打工妹与自己长得一个模子,便鄙夷地问道:你妈以前给首长当过服务员?打工妹说:俺娘从没出过村,倒是俺爹给一位首长当过警卫员。

2011年9月20日星期二

让Win7任务栏上的Windows Explorer指向我的电脑

1.按住Shift键,右键单击任务栏的Windows Explorer按钮,在弹出的右键菜单中选择"属性";

2.在弹出的"Windows 资源管理器 属性"对话框中,将目标改为"%windir%\explorer.exe ,",即在原来的目标后面加上一个空格和逗号(英文输入法状态下的逗号),以后再单击"Windows Explorer"按钮弹出的就不再是烦人的库了,而是"我的电脑"。

使用UltraISO来制作U盘启动盘

1.用UltraISO打开iso镜像文件;

2.选择"启动"——"写入硬盘映像" ;

3.在弹出的"写入硬盘映像"对话框中,"硬盘驱动器"处会自动选择插入的U盘,在"写入方式"处选择"USB-HDD",然后单击"写入"按钮,写完后单击"返回"按钮即可,至此U盘启动盘制作完成。

2011年9月19日星期一

安装Windows系统后应做的事情

1.关掉Windows防火墙
Windows自带的防火墙就是个废品,阻止了正常会话也不通知一下;

2.修改注册表,将桌面、下载、临时目录改到其他非系统分区;
将[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders]和[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders]中相应几项改到其他地方,如、E:\Desktop、E:\Downloads、E:\Temp;

3.修改页面文件的大小和位置;

Windows平台下的FTP服务器软件

1.FileZilla Server
开源的FTP服务器软件,小巧灵活、功能强大,是一款不可多得的好软件,比起商业FTP服务器软件毫不逊色,这是个人用过的Windows平台下最好的FTP服务器软件;

注:使用FileZilla Server时,请关掉Windows防火墙,Windows防火墙就是个废品,阻止了外部访问FileZilla Server,也不提示一下,差点让我放弃了FileZilla Server。

SSH客户端软件

1.Xshell
相当牛逼,支持多标签、支持密码保存、支持标签复制,针对家庭和学校用户免费,是多标签SSH Client的不二之选;

2.SecureCRT
也很牛逼,支持多标签、支持密码保存、支持标签复制,可惜是收费软件;

3.Poderosa
也很不错,可惜和Xshell比起来还是差了一节,支持多标签、免费,但不支持标签复制,保存回话不方便;

4.Bitvise Tunnelier
针对个人用户免费,功能强大,如果需要通过SSH-D翻墙,那Bitvise Tunnelier绝对是最明智的选择,可以保存回话、可以开多窗口、可以同时开SFTP回话。

注:用多标签SSH Client,就用Xshell,翻墙就用Bitvise Tunnelier。

2011年9月13日星期二

邮件客户端

邮件客户端软件对比:
1.网易闪电邮
速度快,但对于国外的普通网站的邮箱经常会出项登录错误,如果只作为国内邮箱的客户端可以考虑,但如果是作为国外邮箱的本地客户端,还是有所欠缺;

2.腾讯的foxmail
同上,对于普通国外网站的邮箱,会出现登录报错的情况,不易考虑;

3.Mozilla的Thunderbird
昨天第一次在windows上使用就喜欢上了,连接服务器的选项更丰富,多为国内外的本地邮件客户端都非常好,没有出现登录报错的情况。

注:以后用邮件客户端就用Thunderbird,Mozilla出品,精品开源软件。

2011年9月2日星期五

让Gmail自动转发符合指定条件的邮件

1.点击右上角的"Mail settings";

2.切换到"Forwarding and POP/IMAP"选项卡,点击下面的"Add a forwarding address";

3.转发地址添加好后就会在B的位置出现该邮箱的账号,因为是要转发符合规则的邮件,而不是简单的转发(即创建过滤器),所以A的位置就选择"Disable forwarding"

4.切换到"Filters"选项卡,点击右下角的"Create a new filter",之后便可根据需要自定义Filters

Linux下Mysql数据库忘记root密码的解决办法

系统环境:Red Hat Enterprise Linux Server 6

1.停止mysqld服务
  [root@Server huage]# service mysqld stop

2.以跳过授权的方式启动mysql
  [root@Server huage]# mysqld_safe --skip-grant-tables &

3.root用户登录mysql
  [root@Server huage]# mysql -u root

4.进入mysql数据库
mysql> use mysql

5.更新mysql数据库中的user表的rootpassword字段
mysql> update user set password=PASSWORD("new_password") where User="root";

6.刷新权限,使其立即生效,之后退出mysql,并重新启动mysql
mysql> flush privileges;
mysql> quit
[root@Server huage]# service mysqld restart

通过Alias来修改phpMyAdmin的默认访问路径

phpMyAdmin的配置文件phpMyAdmin.conf文件位于/etc/httpd/conf.d/目录下,所有位于/etc/httpd/conf.d/目录中的配置文件都是httpd的子配置文件,任何一个子配置文件的语法错误都可能导致httpd启动失败。
[root@fedora log]# httpd -t    //该命令可用于检查与httpd相关的配置文件的语法是否正确
phpMyAdminweb访问方式:
phpMyAdmin.conf中的Alias行决定了phpMyAdminweb访问路径:
[root@fedora log]# cat /etc/httpd/conf.d/phpMyAdmin.conf
phpMyAdmin Web based MySQL browser written in php
#
Allows only localhost by default
#
But allowing phpMyAdmin to anyone other than localhost should be considered
dangerous unless properly secured by SSL
#Alias /phpMyAdmin /usr/share/phpMyAdmin
#Alias /phpmyadmin /usr/share/phpMyAdmin
Alias /nima/shangbuqi  /usr/share/phpMyAdmin
<Directory /usr/share/phpMyAdmin/>
   Order Deny,Allow
   Deny  from All
   Allow from 127.0.0.1
   Allow from 192.168.18.0/24
   Allow from 192.168.1.0/24
   Allow from ::1
</Directory>
Alias /nima/shangbuqi  /usr/share/phpMyAdmin表明phpMyAdminweb访问路径为:
www.mydomain.com/nima/shangbuqi
下面的DenyAllow表示允许那些主机访问phpMyAdminOrder的顺序是"Deny,Allow",表示禁止所有IP访问,除了接下来Allow from中定义的主机外。
注:/nima/shangbuqi是个虚拟路径,在服务器上没有该目录,httpd.conf中定义的web服务器根目录下更不会有该目录。

如果在phpMyAdmin的登陆页面中示:"Cannot load mcrypt extension. Please check your PHP configuration.",则表明服务器没有安装php-mcrypt包。

远程连接mysql数据库提示:ERROR 1130的解决办法

linux下使用mysql客户端连接远程mysql服务器报错:
[root@Server huage]# mysql -h 88.88.88.88 -P 3306 -u root -p
Enter password: 
ERROR 1130 (HY000): Host 'my_wan_ip' is not allowed to connect to this MySQL server

出现这种情况是因为mysql服务器出于安全考虑,默认只允许本地登录数据库服务器。
解决办法:
将远程服务器上的mysql数据库中的user表中root用户所对应的Host字段"127.0.0.1"改为"%"即可。
mysql> use mysql
mysql> update user set Host="%" where Host="127.0.0.1";
mysql> flush privileges;
mysql> quit

杀毒软件汇总

1.Microsoft的MSE
支持windows server平台是亮点,但杀毒能力不行,还不如360,从此不再用MSE了,微软也许真的在没落了;

2.Avira AntiVir Personal
Avira AntiVir Personal俗称小红伞,比较强悍,但不能设置白名单,把哥的代理软件、黑客工具都找出来了,一个都不放过,不适合需要用到这些工具的人 ;

3.Avast! Free Antivirus
很强悍,而且有沙盒功能,但同样无法设置白名单,虽说可以提交误报文件,但厂商却不能随便填,还是相当于无法设置白名单;

4.Dr.Web CureIt!
优点:免费、无需安装(绿色版)、强悍;
缺点:无法在线升级,每次升级都得重新下载,也不支持实时扫描、实时防护,适合同其他杀
          毒软件一起使用或是中毒之后的杀毒、修复工作 

5. ClamWin Free Antivirus
优点:小巧、免费
缺点:查毒能力不够强悍,至少在检查PHP.Shell方面不够强大

6.金山毒霸
优点:免费、适合Windows用户,也比较轻巧
缺点:完全无视linux平台的威胁,从Linux服务器下载的PHP文件中包含PHP.Shell完全查不出
         来,对于需要把linux服务器上的文件下载下来查毒的用户不合适

7.AVG Anti-Virus Free 2012
只能以网络的方式安装,速度太鸡肋,不予置评

mysql数据库的基本操作

[root@Server vsftpd]# mysql -u root -p
Enter password: 
//登录mysql数据库
mysql> show databases;                           //查看数据库
mysql> use mysql                                    //使mysql数据库成为当前的数据库
mysql> show tables;                               //显示mysql数据库中的表
mysql> describe user;                            //显示user表的数据结构
mysql> CREATE DATABASE huage;          //创建数据库huage
mysql> DROP DATABASE huage;             //删除数据库huage
mysql> select from user;                    //显示user表中的内容

mysql> update user set Password=PASSWORD("godontop") where User="root";
//将user表中的root用户的密码改为godontop(PASSWORD函数用于加密密码字段) 

[root@huage ~]# mysqldump -u root -p --all-databases > all-databases.sql
Enter password:  

//输入root用户的密码后即可备份(导出)所有数据库

[root@huage ~]# mysql -u root -p < all-databases.sql
Enter password: 

//输入root用户的密码后即可还原(导入)所有数据库

2011年9月1日星期四

Apache模块中的指令

Alias /images /home/web/images

备注:在Alias语句中,目录后面不要再加"/"

nslookup工具详解

nslookup
[root@huage ~]# nslookup
> fuloon.com                             //默认查询A记录
Server: 8.8.8.8
Address: 8.8.8.8#53

Non-authoritative answer:
Name: fuloon.com
Address: 68.178.232.100
> kugou.com
Server: 8.8.8.8
Address: 8.8.8.8#53

Non-authoritative answer:
Name: kugou.com
Address: 61.143.251.175
Name: kugou.com
Address: 61.143.251.199
Name: kugou.com
Address: 61.143.251.173
Name: kugou.com
Address: 61.143.251.174
> set type=mx                           //查询MX记录
> fuloon.com
Server: 8.8.8.8
Address: 8.8.8.8#53

Non-authoritative answer:
fuloon.com mail exchanger = 10 ASPMX.L.GOOGLE.com.
fuloon.com mail exchanger = 20 ALT1.ASPMX.L.GOOGLE.com.
fuloon.com mail exchanger = 30 ALT2.ASPMX.L.GOOGLE.com.
fuloon.com mail exchanger = 40 ASPMX2.GOOGLEMAIL.com.
fuloon.com mail exchanger = 50 ASPMX3.GOOGLEMAIL.com.

Authoritative answers can be found from:
> kugou.com
Server: 8.8.8.8
Address: 8.8.8.8#53

Non-authoritative answer:
kugou.com mail exchanger = 10 mx.corpease.net.

Authoritative answers can be found from:
> set type=ns                           //查询NS记录
> fuloon.com
Server: 8.8.8.8
Address: 8.8.8.8#53

Non-authoritative answer:
fuloon.com nameserver = ns76.domaincontrol.com.
fuloon.com nameserver = ns75.domaincontrol.com.

Authoritative answers can be found from:
> kugou.com
Server: 8.8.8.8
Address: 8.8.8.8#53

Non-authoritative answer:
kugou.com nameserver = ns.kugou.net.

Authoritative answers can be found from:
> set type=a                             //查询A记录
> fuloon.com
Server: 8.8.8.8
Address: 8.8.8.8#53

Non-authoritative answer:
Name: fuloon.com
Address: 68.178.232.100
> kugou.com
Server: 8.8.8.8
Address: 8.8.8.8#53

Non-authoritative answer:
Name: kugou.com
Address: 61.143.251.175
Name: kugou.com
Address: 61.143.251.199
Name: kugou.com
Address: 61.143.251.173
Name: kugou.com
Address: 61.143.251.174
> set type=txt                          //查询TXT记录
> fuloon.com
Server: 8.8.8.8
Address: 8.8.8.8#53

Non-authoritative answer:
fuloon.com text = "google-site-verification=EDX1FNYOH7z8xgPq1kKvJULgk8qtYsdbLD94n82I0co"

Authoritative answers can be found from:
> kugou.com
Server: 8.8.8.8
Address: 8.8.8.8#53

Non-authoritative answer:
kugou.com text = "v=spf1 ptr:corpease.net -all"

Authoritative answers can be found from:
> set type=cname                        //查询CNAME记录
> email.fuloon.com
Server: 8.8.8.8
Address: 8.8.8.8#53

Non-authoritative answer:
email.fuloon.com canonical name = email.secureserver.net.

Authoritative answers can be found from:
> smtp.kugou.com
Server: 8.8.8.8
Address: 8.8.8.8#53

Non-authoritative answer:
smtp.kugou.com canonical name = smtp.corpease.net.

Authoritative answers can be found from:
> pop.kugou.com
Server: 8.8.8.8
Address: 8.8.8.8#53

Non-authoritative answer:
pop.kugou.com canonical name = pop.corpease.net.

Authoritative answers can be found from:
> www.kugou.com
Server: 8.8.8.8
Address: 8.8.8.8#53

Non-authoritative answer:
*** Can't find kugou.com: No answer

Authoritative answers can be found from:
kugou.com
origin = ns.kugou.net
mail addr = root.ns.kugou.net
serial = 2010101000
refresh = 3600
retry = 900
expire = 68400
minimum = 15
> server 208.67.222.222                 //将DNS临时改为OpenDNS
Default server: 208.67.222.222
Address: 208.67.222.222#53
> www.10086.cn
Server: 208.67.222.222
Address: 208.67.222.222#53

Non-authoritative answer:
Name: www.10086.cn
Address: 218.206.191.72
Name: www.10086.cn
Address: 218.206.191.70
> www.baidu.com
Server: 208.67.222.222
Address: 208.67.222.222#53

Non-authoritative answer:
www.baidu.com canonical name = www.a.shifen.com.
Name: www.a.shifen.com
Address: 220.181.111.147
> www.sina.com.cn
Server: 208.67.222.222
Address: 208.67.222.222#53

Non-authoritative answer:
www.sina.com.cn canonical name = jupiter.sina.com.cn.
jupiter.sina.com.cn canonical name = region.sina.csglb.txcdn.cn.
region.sina.csglb.txcdn.cn canonical name = g2.panthercdn.com.
Name: g2.panthercdn.com
Address: 66.114.50.80
Name: g2.panthercdn.com
Address: 66.114.50.13
> exit

[root@huage ~]#
[root@huage ~]# nslookup
> 208.67.222.222                         //根据IP查询对应的域名
Server: 8.8.8.8
Address: 8.8.8.8#53

Non-authoritative answer:
222.222.67.208.in-addr.arpa name = resolver1.opendns.com.

Authoritative answers can be found from:
> 8.8.8.8
Server: 8.8.8.8
Address: 8.8.8.8#53

Non-authoritative answer:
8.8.8.8.in-addr.arpa name = google-public-dns-a.google.com.

Authoritative answers can be found from:
> 72.232.194.162
Server: 8.8.8.8
Address: 8.8.8.8#53

Non-authoritative answer:
162.194.232.72.in-addr.arpa name = www.centos.org.

Authoritative answers can be found from:
>

备注:
1.nslookup工具在windows下linux通用,nslookup是bind-utils包中的可执行文件;
2.windows下查看DNS缓存的命令是"ipconfig /displaydns ",清除DNS缓存的命令是"ipconfig /flushdns";