Linux shared library Loading function
Link from: http://www.faqs.org/docs/Linux-mini/C++-dlopen.html
//1. == main.cpp =============================================
// How to build?
// g++ -o main main.cpp -ldl
//=======================================================
#include <iostream>
#include <dlfcn.h>
int main() {
using std::cout;
using std::cerr;
cout << "C++ dlopen demo\n\n";
// open the library
cout << "Opening hello.so...\n";
void* handle = dlopen("./hello.so", RTLD_LAZY);
if (!handle) {
cerr << "Cannot open library: " << dlerror() << '\n';
return 1;
}
// load the symbol
cout << "Loading symbol hello...\n";
typedef void (*hello_t)();
hello_t hello = (hello_t) dlsym(handle, "hello");
if (!hello) {
cerr << "Cannot load symbol 'hello': " << dlerror() <<
'\n';
dlclose(handle);
return 1;
}
// use it to do the calculation
cout << "Calling hello...\n";
hello();
// close the library
cout << "Closing library...\n";
dlclose(handle);
}
// 2=====hello.cpp ========================================
// How to build?
// g++ -c -fPIC hello.cpp
// g++ -shared -o hello.so
-fPIC hello.o
//======================================================
#include <
Ïà¹ØÎĵµ£º
1.±ä¸üÓû§£º su root »ò su - ×¢Ò⣨ÈôÖ»ÓÃsu£¬ÔòÖ»»»Óû§£¬²»»»shell£©¡£
2.´´½¨Îļþ¼Ð£º mkdir -m777 tool ´´½¨too²¢ÉèÖÃȨÏÞ mkdir -p tool2/tool3 Á¬¼¶´´½¨Îļþ¼Ð¡£
3.ɾ³ýÎļþ»òÎļþ¼Ð£º rm -r tool2 µÝ¹éɾ³ý£¬Á¬Í¬×ÓĿ¼һÆðɾ³ý¡£ rm -fr ²»ÓÃÌáʾ£¬Ö±½ÓÇ¿ÖÆµÝ¹éɾ³ý¡£
4.ÒÆ¶¯Ä¿Â¼£º mv -iv ......
·þÎñÃû ±ØÐ裨ÊÇ/·ñ£©ÓÃ;ÃèÊö ×¢½â
acon ·ñ ÓïÑÔÖ§³Ö ÌØ±ðÖ ......
Ubuntu 9.10ÂÒÂë Ò»¡¢rtx 2007°²×° ΪÁËÍÑÀëWindowsµÄ¿àº£,ºÃ²»ÈÝÒ×תµ½UbuntuÏÂÀ´,µ«¹«Ë¾Ò»Ö±Óм¸¸öÈí¼þÖ»ÓÐwindowsÄÜÅÜ,ÏÖÔÚ»ù±¾ÎÒËùÓеŦÄܶ¼ÔÚlinuxÏÂÁË.×îÂé·³µÄ¾ÍÕâ¸öRTX.ÉÏ´ÎÓÐÈËÁôÑÔÎÊÎÒÔõô°²×°,ÏÖÔÚÎҺò»ÈÝÒ׸øËûÕûÎȶ¨ÁË,д¸ö·½·¨ÉÏÀ´. ×¼±¸»·¾³,ÎÒµÄÊÇUbuntu 9.04 ,wine-1.1.25,ÎÒÓõÄRTX°æ±¾Îª2007 Beta0 ......
ËÄ¡¢quota
1.×÷ÓÃ
quotaÃüÁîÓÃÀ´ÏÔʾ´ÅÅÌʹÓÃÇé¿öºÍÏÞÖÆÇé¿ö£¬Ê¹ÓÃȨÏÞ³¬¼¶Óû§¡£
2.¸ñʽ
quota [£g][£u][£v][£p] Óû§Ãû ×éÃû
3.²ÎÊý
£g£ºÏÔʾÓû§ËùÔÚ×éµÄ´ÅÅÌʹÓÃÏÞÖÆ¡£
£u£ºÏÔʾÓû§µÄ´ÅÅÌʹÓÃÏÞÖÆ¡£
£v£ºÏÔʾûÓзÖÅä¿Õ¼äµÄÎļþϵͳµÄ·ÖÅäÇé¿ö¡£
£p£ºÏÔʾ¼ò»¯ÐÅÏ¢¡£
4.Ó¦ÓÃʵÀý
ÔÚÆóÒµÓ¦ÓÃÖдÅÅÌÅä ......
²é¿´ÎļþÄÚÈݵÄÌØÊâ·½·¨
¡¡¡¡ÏàÐÅ×î»ù±¾µÄcatºÍless,moreÄãÒѾºÜÊìϤÁË£¬Èç¹ûÓÐÌØÊâµÄÒªÇóÄØ£º
1. Èç¹ûÄãÖ»Ïë¿´ÎļþµÄǰ5ÐУ¬¿ÉÒÔʹÓÃheadÃüÁÈ磺
head -5 /etc/passwd
2. Èç¹ûÄãÏë²é¿´ÎļþµÄºó10ÐУ¬¿ÉÒÔʹÓÃtailÃüÁÈ磺
tail -10 /etc/passwd
tail -f /var/log/messages
²ÎÊý-fʹtail²»Í£µØÈ¥¶Á×îеÄÄÚÈÝ£ ......