LINUX C ¶¨Ê±Æ÷
¡¾ÊµÏÖ¹¦ÄÜ¡¿£ºLinuxϵÄC±à³Ì£º±àдһ¸ö³ÌÐò£¨¿â£©£¬ÊµÏÖ¶¨Ê±Æ÷£¨¼ÆʱÆ÷£©µÄ¹¦ÄÜ£¬ËüÄÜΪÓû§ÌṩÔÚͬһ½ø³ÌÖжà´ÎʹÓõĶ¨Ê±Æ÷¡£ÕâÀïÒªÇóÓÃÐźÅÀ´ÊµÏÖ¡£
¡¾½âÌâ˼·¡¿£º±àдһ¸ö½á¹¹ÌåTimer´ú±íÒ»¸ö¼ÆʱÆ÷£¬È»ºóÔÙ¶¨ÒåTimerÀàÐ͵ÄÊý×émyTimer[N]£¬ÓÃÀ´±£´æÎÒÃÇÉèÖõĶ¨Ê±Æ÷£»ÔÙ¶¨Ò庯ÊýsetTimer£¨£©Éú³É¼ÆʱÆ÷£¬²¢½«Éú³ÉµÄ¼ÆʱÆ÷±£´æµ½myTimerÖУ¬ÕâÑùͨ¹ý¶à´Îµ÷Ó㬾ͿÉÒÔÔÚͬһ¸ö½ø³ÌÖÐÉú³É¶à¸ö¼ÆʱÆ÷£»¶¨Òåtimeout()ÐźŴ¦Àíº¯Êý£¬Ã¿¸ôÒ»Ãë²úÉúÒ»¸öÐźţ¬Í¨¹ýµ÷ÓÃtimeout()¶ÔËùÓеĶ¨Ê±Æ÷ɨÃèÒ»±é£¬¼ì²éÄÄЩ¼ÆʱÆ÷³¬Ê±¡£
¡¾³ÌÐò´úÂë¡¿£ºÈçÏÂ
#include<stdlib.h>
#include<unistd.h>
#include<signal.h>
#include<time.h>
#include<sys/time.h>
#define N 100 //ÉèÖÃ×î´óµÄ¶¨Ê±Æ÷¸öÊý
int i=0,t=1; //i´ú±í¶¨Ê±Æ÷µÄ¸öÊý£»t±íʾʱ¼ä£¬ÖðÃëµÝÔö
struct Timer //Timer½á¹¹Ì壬ÓÃÀ´±£´æÒ»¸ö¶¨Ê±Æ÷µÄÐÅÏ¢
{
int total_time; //ÿ¸ôtotal_timeÃë
int left_time; //»¹Ê£left_timeÃë
int func; //¸Ã¶¨Ê±Æ÷³¬Ê±£¬ÒªÖ´ÐеĴúÂëµÄ±êÖ¾
}myTimer[N]; //¶¨ÒåTimerÀàÐ͵ÄÊý×飬ÓÃÀ´±£´æËùÓеĶ¨Ê±Æ÷
void setTimer(int t,int f) //н¨Ò»¸ö¼ÆʱÆ÷
{
struct Timer a;
a.total_time=t;
a.left_time=t;
a.func=f;
myTimer[i++]=a;
}
void timeout() //Åж϶¨Ê±Æ÷ÊÇ·ñ³¬Ê±£¬ÒÔ¼°³¬Ê±Ê±ËùÒªÖ´ÐеĶ¯×÷
{
printf("Time: %d\n",t++);
int j;
for(j=0;j<i;j++)
{
if(myTimer[j].left_time!=0)
myTimer[j].left_time--;
else
{
switch(myTimer[j].func){ //ͨ¹ýÆ¥ÅämyTimer[j].func£¬ÅжÏÏÂÒ»²½Ñ¡ÔñÄÄÖÖ²Ù×÷
 
Ïà¹ØÎĵµ£º
groups ²é¿´µ±Ç°µÇ¼Óû§µÄ×éÄÚ³ÉÔ±
groups gliethttp ²é¿´gliethttpÓû§ËùÔÚµÄ×é,ÒÔ¼°×éÄÚ³ÉÔ±
whoami ²é¿´µ±Ç°µÇ¼Óû§Ãû
/etc/groupÎļþ°üº¬ËùÓÐ×é
/etc/shadowºÍ/etc/passwdϵͳ´æÔÚµÄËùÓÐÓû§Ãû
Ìí¼ÓÓû§abcµ½rootȺ×飺
gpasswd -a abc root ......
×ܾõµÃÔÚITÐÐÒµÀï»ì£¬Ñ§±à³ÌÓïÑÔҪѧϰC²ÅÏñÑù£¬¿ª·¢ÒªÔÚLinuxϲÅÄÜ·¢»ÓºÃ£¬ºÇºÇ£¬Ëæ¿Ú˵µÄ£¬²»¹ý¸öÈËÈÏΪÏëÉîÈëµÄѧϰ¼ÆËã»ú֪ʶ£¬»¹ÊÇÓ¦¸ÃѧϰLinux²Ù×÷ϵͳ£¬ËùÒÔ´Ó½ñÌ쿪ʼÿÌì³é³öÒ»¸öСʱѧϰ£¬ÔÚ´Ë×öһЩѧϰ¼Ç¼£¬ÒÔ¹©ÒÔºó²éѯ×ܽᡣ
½ñÌìÊÇ°²×°£¬ÊÇÔÚVMwareÏ°²×°µÄRed hat 9,°²×°Ï൱˳³©£¬Ò»Â·nextÏÂÈ¥£¬¾ÍOKÁ ......
LinuxÖն˻·¾³Ï£¬ÀûÓÃÖÕ¶ËÃüÁîÐòÁпÉÒÔÉèÖÃ×ÖÌåµÄÑÕÉ«£¬Æä¸ñʽÈçÏ£º
<ESC>[<C1>;<C2>;<C3>m
ÆäÖÐ<ESC>µÄֵΪ ......