Linux×Ö·ûÉ豸Çý¶¯³ÌÐò¿ª·¢
LinuxϵÄÉ豸Çý¶¯³ÌÐò±»×é֯Ϊһ×éÍê³É²»Í¬ÈÎÎñµÄº¯ÊýµÄ¼¯ºÏ£¬Í¨¹ýÕâЩº¯ÊýʹµÃWindowsµÄÉ豸²Ù×÷ÓÌÈçÎļþÒ»°ã¡£ÔÚÓ¦ÓóÌÐò¿´À´£¬Ó²¼þÉ豸ֻÊÇÒ»¸öÉ豸Îļþ£¬Ó¦ÓóÌÐò¿ÉÒÔÏó²Ù×÷ÆÕͨÎļþÒ»Ñù¶ÔÓ²¼þÉ豸½øÐвÙ×÷£¬Èçopen ()¡¢close ()¡¢read ()¡¢write () µÈ¡£
LinuxÖ÷Òª½«É豸·ÖΪ¶þÀࣺ×Ö·ûÉ豸ºÍ¿éÉ豸¡£×Ö·ûÉ豸ÊÇÖ¸É豸·¢ËͺͽÓÊÕÊý¾ÝÒÔ×Ö·ûµÄÐÎʽ½øÐУ»¶ø¿éÉ豸ÔòÒÔÕû¸öÊý¾Ý»º³åÇøµÄÐÎʽ½øÐС£×Ö·ûÉ豸µÄÇý¶¯Ïà¶Ô±È½Ï¼òµ¥¡£
¡¡¡¡ÏÂÃæÎÒÃÇÀ´¼ÙÉèÒ»¸ö·Ç³£¼òµ¥µÄÐéÄâ×Ö·ûÉ豸£ºÕâ¸öÉ豸ÖÐÖ»ÓÐÒ»¸ö4¸ö×Ö½ÚµÄÈ«¾Ö±äÁ¿int global_var£¬¶øÕâ¸öÉ豸µÄÃû×Ö½Ð×ö"gobalvar"¡£¶Ô"gobalvar"É豸µÄ¶ÁдµÈ²Ù×÷¼´ÊǶÔÆäÖÐÈ«¾Ö±äÁ¿global_varµÄ²Ù×÷¡£
¡¡¡¡Çý¶¯³ÌÐòÊÇÄں˵ÄÒ»²¿·Ö£¬Òò´ËÎÒÃÇÐèÒª¸øÆäÌí¼ÓÄ£¿é³õʼ»¯º¯Êý£¬¸Ãº¯ÊýÓÃÀ´Íê³É¶ÔËù¿ØÉ豸µÄ³õʼ»¯¹¤×÷£¬²¢µ÷ÓÃregister_chrdev() º¯Êý×¢²á×Ö·ûÉ豸£º
static int __init gobalvar_init(void)
{
¡¡if (register_chrdev(MAJOR_NUM, " gobalvar ", &gobalvar_fops))
¡¡{
¡¡¡¡//…×¢²áʧ°Ü
¡¡}
¡¡else
¡¡{
¡¡¡¡//…×¢²á³É¹¦
¡¡}
}
¡¡¡¡ÆäÖУ¬register_chrdevº¯ÊýÖеIJÎÊýMAJOR_NUMΪÖ÷É豸ºÅ,"gobalvar"ΪÉ豸Ãû£¬gobalvar_fopsΪ°üº¬»ù±¾º¯ÊýÈë¿ÚµãµÄ½á¹¹Ì壬ÀàÐÍΪfile_operations¡£µ±gobalvarÄ£¿é±»¼ÓÔØʱ£¬gobalvar_init±»Ö´ÐУ¬Ëü½«µ÷ÓÃÄں˺¯Êýregister_chrdev£¬°ÑÇý¶¯³ÌÐòµÄ»ù±¾Èë¿ÚµãÖ¸Õë´æ·ÅÔÚÄں˵Ä×Ö·ûÉ豸µØÖ·±íÖУ¬ÔÚÓû§½ø³Ì¶Ô¸ÃÉ豸ִÐÐϵͳµ÷ÓÃʱÌṩÈë¿ÚµØÖ·¡£
¡¡¡¡ÓëÄ£¿é³õʼ»¯º¯Êý¶ÔÓ¦µÄ¾ÍÊÇÄ£¿éжÔغ¯Êý£¬ÐèÒªµ÷ÓÃregister_chrdev()µÄ"·´º¯Êý" unregister_chrdev()£º
static void __exit gobalvar_exit(void)
{
¡¡if (unregister_chrdev(MAJOR_NUM, " gobalvar "))
¡¡{
¡¡¡¡//…жÔØʧ°Ü
¡¡}
¡¡else
¡¡{
¡¡¡¡//…жÔسɹ¦
¡¡}
}
¡¡¡¡Ëæ×ÅÄں˲»¶ÏÔö¼ÓÐµĹ¦ÄÜ£¬file_operations½á¹¹ÌåÒÑÖð½¥±äµÃÔ½À´Ô½´ó£¬µ«ÊÇ´ó¶àÊýµÄÇý¶¯³ÌÐòÖ»ÊÇÀûÓÃÁËÆäÖеÄÒ»²¿·Ö¡£¶ÔÓÚ×Ö·ûÉ豸À´Ëµ£¬ÒªÌṩµÄÖ÷ÒªÈë¿ÚÓУºopen ()¡¢release ()¡¢read ()¡¢write ()¡¢ioctl ()¡¢llseek()¡¢poll()µÈ¡£
¡¡¡¡open()º¯Êý¡¡¶ÔÉ豸ÌØÊâÎļþ½øÐÐopen()ϵͳµ÷ÓÃʱ£¬½«µ÷ÓÃÇý¶¯³ÌÐòµÄopen () º¯Êý£º
int (*open)(struct inode * ,struct file *);
¡¡¡¡ÆäÖвÎÊýinodeΪÉ豸ÌØÊâÎļþµÄinode (Ë÷Òý½áµã) ½á¹¹µÄÖ¸Õ룬²ÎÊýfileÊÇÖ¸ÏòÕâÒ»É豸µÄÎļþ½á¹¹µÄÖ¸Õë¡£open()µ
Ïà¹ØÎĵµ£º
Çл»µ½rootÓû§ÏÂ,
service iptables status ÓÃÓڲ鿴ÊÇ·ñÓпªÆô·À·½Ç½.
service iptables stop ÓÃÓڹرշÀ»ðǽ.
service iptables start ÓÃÓÚ´ò¿ª·À»ðǽ.
·À»ðǽµÄ¿ªÆôÓÐʱ»áÏÞÖÆÍⲿ·ÃÎÊ·þÎñÆ÷ÉϵĶ˿Úʧ°Ü. ......
LinuxϵĽø³ÌͨÐÅÊֶλù±¾ÉÏÊÇ´ÓUnixƽ̨ÉϵĽø³ÌͨÐÅÊֶμ̳жøÀ´µÄ¡£¶ø¶ÔUnix·¢Õ¹×ö³öÖØ´ó¹±Ï×µÄÁ½´óÖ÷Á¦AT&TµÄ±´¶ûʵÑéÊÒ¼°BSD£¨¼ÓÖÝ´óѧ²®¿ËÀû·ÖУµÄ²®¿ËÀûÈí¼þ·¢²¼ÖÐÐÄ£©ÔÚ½ø³Ì¼äͨÐÅ·½ÃæµÄ²àÖصãÓÐËù²»Í¬¡£Ç°Õ߶ÔUnixÔçÆڵĽø³Ì¼äͨÐÅÊֶνøÐÐÁËϵͳµÄ¸Ä½øºÍÀ©³ä£¬ÐγÉÁË“ ......
LinuxϵͳµÄSNMP·þÎñÉèÖÃ
1) °²×°SNMP
ÂÔ£¬Çë²ÎÔÄLINUXϵͳSNMP°²×°ËµÃ÷£¬Ò»°ãÇé¿öÏÂLinuxÖеľùÒѾ×Ô¶¯°²×°ÁËSNMP·þÎñ¡£ÒÔÏÂÃüÁî¿ÉÒÔ¼ì²âSNMP·þÎñÊÇ·ñ°²×°ÒÔ¼°°²×°µÄÎļþ°ü¡£
[root@idc ~]# rpm -qa |grep snmp
net-snmp-libs-5.1.2-11.EL4.7
net-snmp-5.1.2-11.EL4.7
2) ÅäÖÃSNMP
°´ÕÕÈçÏ·½Ê½ÐÞ¸Ä/etc ......
RHEL5´î½¨DNS·þÎñÆ÷ʵÏÖÃû³Æ½âÎö Èý
£¨¶þ£©named.confÎļþ˵Ã÷£º
´ËÎļþÐèÓû§×Ô¼º´´½¨£¬¿É´Ó/usr/share/doc/bind-9.3.3/sample/etcÖи´ÖƵ½/var/named/chroot/etc/Ŀ¼ÏÂ
// Sample named.conf BIND DNS server 'named' configuration file
// for the Red Hat BIND distribution.
// See the BIND ......
Ç°¼¸Ìì°ÑϵͳµÄrootÃÜÂë¸øÍüÁË£¬²»ÖªµÀÔõô½â¾ö£¬µ½ÍøÉÏËÑÁ˸ö½â¾ö°ì·¨£¬Óë´ó¼Ò¹²Ïí¡£
ÔÚ³öÏÖϵͳѡÔñ½çÃæʱ£¬ÔÚRed Hat LinuxµÄÑ¡ÏîÉÏ°´“e”¼ü£¬È»ºó»á³öÏÖÈý¸öÑ¡ÏÔÚµÚ¶þÏîÀàËÆ“ kernel /vmlinuz-2.4.20-8 ro root=LABEL=/”ÉÏ°´“e”¼ü½øÐб༣¬ÔÚ“ro”»òÕß&l ......