LinuxÏ»ñÈ¡MACµØÖ·
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <netinet/if_ether.h>
#include <string.h>
#include <netinet/ether.h>
#include<unistd.h>
int main(int argc, char **argv)
{
printf("helloworld\n");
int nSocket;
struct ifreq struReq;
nSocket = socket(PF_INET,SOCK_STREAM,0);
memset(&struReq,0,sizeof(struReq));
if(argc < 2)
strncpy(struReq.ifr_name, "eth0", sizeof(struReq.ifr_name));
else
strncpy(struReq.ifr_name, argv[1], sizeof(struReq.ifr_name));
ioctl(nSocket,SIOCGIFHWADDR,&struReq);
fprintf(stderr, "%d-%s\n", __LINE__, strerror(errno));
printf("%s \n", ether_ntoa( (const ether_addr*)(struReq.ifr_ifru.ifru_hwaddr.sa_data)));
close(nSocket);
}
man reference
http://linux.die.net/man/7/netdevice
Ïà¹ØÎĵµ£º
±ÏÒµÉè¼ÆÓõ½Ò»Ð©½Ó¿Ú²âÊÔ´úÂ룬ÆäÖоÍÓд®¿ÚµÄ²âÊÔ£¬ÕâÆäÖлù±¾½è¼øÁË»ªÇåÔ¶¼ûÄDZ¾ÊéÀïÃæµÄ´úÂ룬¶Á´®¿Ú³ÌÐò½»²æ±àÒëµ½¿ª·¢°åÖУ¬Ð´´®¿Ú³ÌÐòÔÚPC¶ËÖ´ÐС£´úÂëºÜ¼òµ¥£¬ÒòΪ´®¿ÚÔÚlinuxÏÂÒ²Ö»ÊǸöÎļþ£¬Ö»ÐèÒª´ò¿ªÕâÎļþ½øÐжÁд²Ù×÷¾ÍºÃÁË¡£ÆäÖÐʹÓÃÁË2¸öº¯Êý£¬·Ö±ðÊÇÅäÖö˿ںʹò¿ª¶Ë¿ÚµÄº¯Êý£¬Õâ2¸öº¯ ......
1£¬Ê×ÏÈSERVERÓëCLIENT¶¼ÐèÒª°²×°RSYNC
2£¬Æä´ÎÔÚSERVERµÄ/etc/ÏÂÃæ½¨Á¢rsyncd.conf
ÄÚÈÝ¿ÉÒÔ°´ÕÕÏÂÃæµÄд·¨
[root@vm-base-01 local]# more /etc/rsyncd.conf
uid =
root &n ......
Linux, named after the inventor, Linus Torvalds, is a so different OS for everyone against Windows. To everyone who used to use Windows, Linux need us to do more for everything which we usually do by computer, such as playing a video.
Someone says, Linux is for the ones who are good at the computer ......
Linux select()Ïê½â selectϵͳµ÷ÓÃÊÇÓÃÀ´ÈÃÎÒÃǵijÌÐò¼àÊÓ¶à¸öÎļþ¾ä±ú(file descriptor)µÄ״̬±ä»¯µÄ¡£³ÌÐò»áÍ£ÔÚselectÕâÀïµÈ´ý£¬Ö±µ½±»¼àÊÓµÄÎļþ¾ä±úÓÐijһ¸ö»ò¶à¸ö·¢ÉúÁË״̬¸Ä±ä¡£ ÎļþÔÚ¾ä±úÔÚLinuxÀïºÜ¶à£¬Èç¹ûÄãmanij¸öº¯Êý£¬ÔÚº¯Êý·µ»ØÖµ²¿·Ö˵µ½³É¹¦ºóÓÐÒ»¸öÎļþ¾ä±ú±»´´½¨µÄ¶¼Êǵģ¬Èçman socket¿ÉÒÔ¿´µ½&ldqu ......
±à¼gedit /etc/fstab:
//192.168.1.1/winshare /mnt/share defaults,auto,username=windowsÓû§Ãû, password=windowsÃÜÂë 0 0
±¸×¢£º
£¨1£©ÖÕ¶ËÃüÁîÐйÒÔØ£ºmount //192.168.1.1/winshare /mnt/share -o user=windowsÓû§Ãû%windowsÃÜÂë
£¨2£©etc/rc.d/rcÔò¸ù¾ÝÆä²ÎÊýÖ¸¶¨µÄÔËÐÐģʽ(ÔËÐм¶±ð£¬ÔÚinittabÎļþÖпÉÒÔÉèÖ ......