3. $ man hello HELLO(1) User Commands HELLO(1) NAME hello - friendly greeting program SYNOPSIS hello [OPTION]... DESCRIPTION Print a friendly, customizable greeting. -h, --help display this help and exit -v, --version display version information and exit -t, --traditional use traditional greeting format -n, --next-generation use next-generation greeting format -g, --greeting=TEXT use TEXT as the greeting message
10. $ gcc -o hello hello.c main.c -Wall main.c: In function ‘main’: main.c:1:1: warning: implicit declaration of function ‘print_hello’ main.c:1:1: warning: control reaches end of non-void function $ nm hello.o 00000000 T print_hello U puts $ ldd hello linux-vdso.so.1 => (0x00110000) libc.so.6 => /lib/libc.so.6 (0x00a57000) /lib/ld-linux.so.2 (0x00a38000)
14. void openlog(char *ident, int option, int facility); void syslog(int priority, char *format, …); void closelog();
15. #include <syslog.h> int main() { int i; openlog("test", LOG_PID, LOG_USER); syslog(LOG_DEBUG,"try to sending 5 messages"); for (i = 0; i < 5; ++i) syslog(LOG_INFO,"info message [i = %i]",i); closelog(); };
16. $ tail /var/log/debug Dec 20 11:25:04 linux test[6222]: try to sending 5 messages $ tail /var/log/messages Dec 20 11:25:04 linux test[6222]: info message [i = 0] Dec 20 11:25:04 linux test[6222]: info message [i = 1] Dec 20 11:25:04 linux test[6222]: info message [i = 2] Dec 20 11:25:04 linux test[6222]: info message [i = 3] Dec 20 11:25:04 linux test[6222]: info message [i = 4]
26. USER - имя текущего пользователя HOME - путь к домашнему каталогу текущего пользователя PATH - список каталогов, разделенных двоеточиями, в которых производится "поиск" программ PWD - текущий каталог OLDPWD - предыдущий текущий каталог SHELL - текущая командная оболочка HOSTNAME - имя машины QTDIR - расположение библиотеки QT LD_LIBRARY_PATH - место "поиска" дополнительных библиотек LANG - язык и кодировка пользователя DISPLAY - текущий дисплей в X11
27. extern char ** environ; //declared in unistd.h char *getenv(char const *name); int setenv(char const *name, char const *value, int overwrite); int unsetenv(char const *name);