LINUXÏÂÎļþ²Ù×÷º¯Êý
LinuxµÄÎļþ²Ù×÷APIÉæ¼°µ½´´½¨¡¢´ò¿ª¡¢¶ÁдºÍ¹Ø±ÕÎļþ¡£
1.linux API
¡¡¡¡´´½¨
int creat(const char *filename, mode_t mode);
¡¡¡¡²ÎÊýmodeÖ¸¶¨Ð½¨ÎļþµÄ´æȡȨÏÞ£¬ËüͬumaskÒ»Æð¾ö¶¨ÎļþµÄ×îÖÕȨÏÞ£¨mode&umask£©£¬ÆäÖÐumask´ú±íÁËÎļþÔÚ´´½¨Ê±ÐèҪȥµôµÄһЩ´æȡȨÏÞ¡£umask¿Éͨ¹ýϵͳµ÷ÓÃumask()À´¸Ä±ä£º
int umask(int newmask);
´ò¿ª
int open(const char *pathname, int flags);
int open(const char *pathname, int flags, mode_t mode);
¡¡¡¡openº¯ÊýÓÐÁ½¸öÐÎʽ£¬ÆäÖÐpathnameÊÇÎÒÃÇÒª´ò¿ªµÄÎļþÃû(°üº¬Â·¾¶Ãû³Æ£¬È±Ê¡ÊÇÈÏΪÔÚµ±Ç°Â·¾¶ÏÂÃæ)£¬flags¿ÉÒÔÈ¥ÏÂÃæµÄÒ»¸öÖµ»òÕßÊǼ¸¸öÖµµÄ×éºÏ£º
±êÖ¾
º¬Òå
O_RDONLY
ÒÔÖ»¶ÁµÄ·½Ê½´ò¿ªÎļþ
O_WRONLY
ÒÔֻдµÄ·½Ê½´ò¿ªÎļþ
O_RDWR
ÒÔ¶ÁдµÄ·½Ê½´ò¿ªÎļþ
O_APPEND
ÒÔ×·¼ÓµÄ·½Ê½´ò¿ªÎļþ
O_CREAT
´´½¨Ò»¸öÎļþ
O_EXEC
Èç¹ûʹÓÃÁËO_CREAT¶øÇÒÎļþÒѾ´æÔÚ£¬¾Í»á·¢ÉúÒ»¸ö´íÎó
O_NOBLOCK
ÒÔ·Ç×èÈûµÄ·½Ê½´ò¿ªÒ»¸öÎļþ
O_TRUNC
Èç¹ûÎļþÒѾ´æÔÚ£¬Ôòɾ³ýÎļþµÄÄÚÈÝ
¡¡¡¡O_RDONLY¡¢O_WRONLY¡¢O_RDWRÈý¸ö±êÖ¾Ö»ÄÜʹÓÃÈÎÒâµÄÒ»¸ö¡£
mode¿ÉÒÔÊÇÒÔÏÂÇé¿öµÄ×éºÏ£º
±êÖ¾
º¬Òå
S_IRUSR
Óû§¿ÉÒÔ¶Á
S_IWUSR
Óû§¿ÉÒÔд
S_IXUSR
Óû§¿ÉÒÔÖ´ÐÐ
S_IRWXU
Óû§¿ÉÒÔ¶Á¡¢Ð´¡¢Ö´ÐÐ
S_IRGRP
×é¿ÉÒÔ¶Á
S_IWGRP
×é¿ÉÒÔд
S_IXGRP
×é¿ÉÒÔÖ´ÐÐ
S_IRWXG
×é¿ÉÒÔ¶ÁдִÐÐ
S_IROTH
ÆäËûÈË¿ÉÒÔ¶Á
S_IWOTH
ÆäËûÈË¿ÉÒÔд
S_IXOTH
ÆäËûÈË¿ÉÒÔÖ´ÐÐ
S_IRWXO
ÆäËûÈË¿ÉÒÔ¶Á¡¢Ð´¡¢Ö´ÐÐ
S_ISUID
ÉèÖÃÓû§Ö´ÐÐID
S_ISGID
ÉèÖÃ×éµÄÖ´ÐÐID
¡¡¡¡³ýÁË¿ÉÒÔͨ¹ýÉÏÊöºê½øÐГ»ò”Âß¼²úÉú±êÖ¾ÒÔÍ⣬ÎÒÃÇÒ²¿ÉÒÔ×Ô¼ºÓÃÊý×ÖÀ´±íʾ£¬Linux×ܹ²ÓÃ5¸öÊý×ÖÀ´±íʾÎļþµÄ¸÷ÖÖȨÏÞ£ºµÚһλ±íʾÉèÖÃÓû§ID£»µÚ¶þλ±íʾÉèÖÃ×éID£»µÚÈýλ±íʾÓû§×Ô¼ºµÄȨÏÞλ£»µÚËÄλ±íʾ×éµÄȨÏÞ£»×îºóһλ±íʾÆäËûÈ˵ÄȨÏÞ¡£Ã¿¸öÊý×Ö¿ÉÒÔÈ¡1(Ö´ÐÐȨÏÞ)¡¢2(дȨÏÞ)¡¢4(¶ÁȨÏÞ)¡¢0(ÎÞ)»òÕßÊÇÕâЩֵµÄºÍ¡£ÀýÈ磬Ҫ´´½¨Ò»¸öÓû§¿É¶Á¡¢¿Éд¡¢¿ÉÖ´ÐУ¬µ«ÊÇ×éûÓÐȨÏÞ£¬ÆäËûÈË¿ÉÒÔ¶Á¡¢¿ÉÒÔÖ´ÐеÄÎļþ£¬²¢ÉèÖÃÓû§IDλ¡£ÄÇô£¬ÎÒÃÇÓ¦¸ÃʹÓõÄģʽÊÇ1(ÉèÖÃÓû§ID)¡¢0(²»ÉèÖÃ×éID)¡¢7(1+2+4£¬¶Á¡¢Ð´¡¢Ö´ÐÐ)¡¢0(ûÓÐȨÏÞ)¡¢5(1+4£¬¶Á¡¢Ö´ÐÐ)¼´10705£º
open("test", O_CREAT, 10705);
¡¡¡¡ÉÏÊöÓï¾äµÈ¼ÛÓÚ£º
open("test", O_CREAT, S_IRWXU | S_IROTH | S_
Ïà¹ØÎĵµ£º
Linux·þÎñ£¨Linux services£©¶ÔÓÚÿ¸öÓ¦ÓÃLinuxµÄÓû§À´Ëµ¶¼ºÜÖØÒª¡£¹Ø±Õ²»ÐèÒªµÄ·þÎñ£¬¿ÉÒÔÈÃLinuxÔËÐеĸü¸ßЧ£¬µ«²¢²»ÊÇËùÓеÄLinux·þÎñ¶¼¿ÉÒԹرա£½ñÌì°²×°ÁËÒ»´ÎCentOs Linux£¬·¢ÏÖLinuxÆô¶¯µÄʱºòÆô¶¯Á˺öà·þÎñ£¬´ó²¿·Ö¶¼²»ÖªµÀÊǸÉʲôµÄ¡£Òò´Ë×ÅÖØÁ˽âÁËÒ»ÏÂÄÇЩLinux·þÎñ£¨Linux services£©¿ÉÒԹرգ¬ÄÇЩLinux· ......
Õª×Ô£ºhttp://www.ibm.com/developerworks/cn/linux/l-threading.html
LinuxThreads ÏîÄ¿×î³õ½«¶àÏ̵߳ĸÅÄîÒýÈëÁË Linux®£¬µ«ÊÇ LinuxThreads ²¢²»×ñÊØ
POSIX Ï̱߳ê×¼¡£¾¡¹Ü¸üÐ嵀 Native POSIX Thread
Library£¨NPTL£©¿âÌî²¹ÁËһЩ¿Õ°×£¬µ«ÊÇÕâÈÔÈ»´æÔÚһЩÎÊÌâ¡£±¾ÎÄΪÄÇЩÐèÒª½«×Ô¼ºµÄÓ¦ÓóÌÐò´Ó LinuxTh ......
ÍøÂçÅäÖÃÎļþ LINUX ÔÚ °²×°ÖÐ »ù±¾µÄÅäÖà ¶¼ÒѾÍê³ÉÁË ¶¼ÒÔÎı¾·½Ê½ ±£´æÔÚ/etcĿ¼ÏÂ
.
ÍøÂçÅäÖÃÎļþ£º/etc/sysconfig/network
²é¿´ÃüÁ
[root@localhost ~]# cat /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=localhost.localdomai ......
¸Õ¿ªÊ¼Ñ§Linux£¬¿´µ½ÄÇЩ·×·±¸´ÔÓµÄĿ¼ÕæÊǸоõÓеãÊÖ×ãÎ޴룬ÏÖÔÚ×ÜËãÖªµÀ×Ô¼ºµÄÈí¼þÓ¦¸Ã×°ÔÚ/usrĿ¼Ï£¬ºÇºÇ¡«¡«
ÏÂÃæÊǸ÷¸öĿ¼µÄ˵Ã÷£º
/bin
¸ÃĿ¼Öдæ·ÅLinuxµÄ³£ÓÃÃüÁÔÚÓеİ汾ÖÐÊÇһЩºÍ¸ùĿ¼ÏÂÏàͬµÄĿ¼¡£
/boot
¸ÃĿ¼Ï´æ·ÅµÄ¶¼ÊÇϵͳÆô¶¯Ê±ÒªÓõ½µÄ³ÌÐò£¬µ±ÓÃliloÒýµ¼Linuxʱ£¬»áÓõ½Õâ ......
script.txt
username
password
ascii
lcd d:/src
cd /home/bear/src
put main.c
put main.h
bye
µ÷Ó÷½·¨£º ftp -s:script.txt 109.168.0.2 ......