-
Linux命令之tzselect
tzselect命令用於選擇時區。要註意的是tzselect只是幫我們把選擇的時區顯示出來,並不會實際生效,也就是說它僅僅告訴我們怎麽樣去設置環境變量TZ。(TZ = Time Zone)(The tzselect program asks the user for information about the current location, and outputs the resulting time zone description to standard output. The output is suitable as a value for the TZ environment variable. All interaction with the user is done via standard input and standard error.)如果妳要永久更改時區,按照tzselect命令提示的信息,在.profile或者/etc/profile中設置正確的TZ環境變量並導出。還有另外壹種更改時區的方法就是直接更改系統配置文件/etc/sysconfig/clock,然後修改符號鏈接/etc/locatime對應的文件,詳見示例三。 常用參數 無。 使用示例 示例壹 將時區更改為北京…
-
linux學習-linux配置文件出去註釋行
1、使用grep -v “^#” 來去掉註釋行,其中:-v 就是取相反的 ^# 表示註解行 eg. grep -v “^#” /etc/vsftpd/vsftpd.conf (也可以使用“>”來重寫配置文件) 2、有時也會連同空行壹起去掉,使用管道符來完成(^$表示空行 ) eg. grep -v “^#” httpd.conf | grep -v “^$” >> vsftpd.conf 上面用了 2次 grep 過濾命令 ,也就是把空行和註解行過濾掉,再把剩下的內容追加保存為原 來的配置文件 vsftpd.conf 這個時候就文件裏的內容就沒有註解行和空行了,,,, 提示: 對配置文件不熟悉的建議不要用這種方法,配置文件中的註解行還是有壹定的幫助的。 另外,在更改配置文件時,建議先對配置文件做壹下備份: cp -a httpd.conf httpd.conf.bak
-
Linux中如何創建靜態庫和動態庫
靜態庫在程序編譯時會被連接到目標代碼中,程序運行時將不再需要該靜態庫。 動態庫在程序編譯時並不會被連接到目標代碼中,而是在程序運行是才被載入,因此在程序運行時還需要動態庫存在。 程序1: hello.h #ifndef HELLO_H #define HELLO_H void hello(const char *name); #endif //HELLO_H 程序2: hello.c #include <stdio.h> void hello(const char *name) { printf(“Hello %s!\n”, name); } 程序3: main.c #include “hello.h” int main() { hello(“everyone”); return 0; } 無論動態庫還是靜態庫都需要用到.o文件來生成,先編譯生成.o文件。 # gcc -c hello.c 1:創建靜態庫 靜態庫文件名的命名規範是以lib為前綴,緊接著跟靜態庫名,擴展名為.a。例如:我們將創建的靜態庫名為myhello,則靜態庫文件名就是libmyhello.a。 # ar cr libmyhello.a hello.o 使用靜態庫:只需要在妳的源程序中加入包含妳所需要使用到的函數的聲明(即包含頭文件),然後在gcc生成目標文件時候指明靜態庫就OK了(除非妳包含的頭文件在/usr/include,庫文件在標準庫/usr/lib,/lib下,否則妳得顯示指明他們的路徑) # gcc -o hello…