linux操作之:可執行檔,庫檔案路徑設定!

來源:互聯網
上載者:User

經常被人家問到這個問題,路徑怎麼設定阿?
我怎麼離開了可執行檔的檔案夾以後就沒有辦法使用可執行檔了阿?
我用export為什麼總是不對阿?

問題很多,這裡介紹一種很直接很簡單的方法,其實操作很簡單,熟悉linux的朋友們因該都知道,算是給不是很熟悉linux的使用的朋友的一點協助吧

作業系統:opensuse 11.1 64位版本

1 設定可執行檔路徑,我們直接修改系統檔案來實現,很簡單:
在終端裡面執行:

  1. BTazuo:/etc # cd /etc
  2. BTazuo:/etc # vim profile

profile檔案有點大,東西很多,找到PATH字樣的地方:


  1. for dir in  /usr/X11/bin /

這行下面添加自己的可執行檔就是了。

2  設定庫檔案路徑,依舊是修改系統檔案如下:

  1. BTazuo:~ # cd /etc
  2. BTazuo:/etc # vim ld.so.conf

裡面

  1. include /etc/ld.so.conf.d/*.conf

之前添加你的庫檔案也就是lib檔案的路徑就ok了。

重啟就ok了,哈哈。

作業系統:Centos 58

可執行檔路徑,依舊是在/etc/profile中:

1 # /etc/profile  2  3 # System wide environment and startup programs, for login setup  4 # Functions and aliases go in /etc/bashrc  5  6 pathmunge () {  7     if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then  8        if [ "$2" = "after" ] ; then  9           PATH=$PATH:$1 10        else 11           PATH=$1:$PATH 12        fi 13     fi 14 } 15 16 # ksh workaround 17 if [ -z "$EUID" -a -x /usr/bin/id ]; then 18     EUID=`id -u` 19     UID=`id -ru` 20 fi 21 22 # Path manipulation 23 if [ "$EUID" = "0" ]; then 24     pathmunge /sbin 25     pathmunge /usr/sbin 26     pathmunge /usr/local/sbin 27 fi

# Path manipulation之後then裡面添加你想要的可執行檔路徑,比如/usr/local/share/xxx/bin即可

系統庫路徑,和上面一致:

[root@localhost etc]# ll ld*-rw-r--r-- 1 root root   9028 Feb 23  2012 ldap.conf-rw-r--r-- 1 root root 115468 Dec  9 15:07 ld.so.cache-rw-r--r-- 1 root root     28 Oct  8  2006 ld.so.confld.so.conf.d:total 32-r--r--r-- 1 root root 324 Dec  5 10:07 kernelcap-2.6.18-308.24.1.el5.conf-r--r--r-- 1 root root 324 Feb 22  2012 kernelcap-2.6.18-308.el5.conf-rw-r--r-- 1 root root  15 Feb 14  2012 mysql-i386.conf-rw-r--r-- 1 root root  17 May 10  2012 openais-athlon.conf-rw-r--r-- 1 root root  20 Feb 24  2012 qt-i386.conf-rw-r--r-- 1 root root 276 Dec  9 03:59 vmware-tools-libraries.conf-rw-r--r-- 1 root root  21 Nov 21 09:41 xulrunner-32.conf[root@localhost etc]#[root@localhost etc]# cd ld.so.conf.d/[root@localhost ld.so.conf.d]# lltotal 32-r--r--r-- 1 root root 324 Dec  5 10:07 kernelcap-2.6.18-308.24.1.el5.conf-r--r--r-- 1 root root 324 Feb 22  2012 kernelcap-2.6.18-308.el5.conf-rw-r--r-- 1 root root  15 Feb 14  2012 mysql-i386.conf-rw-r--r-- 1 root root  17 May 10  2012 openais-athlon.conf-rw-r--r-- 1 root root  20 Feb 24  2012 qt-i386.conf-rw-r--r-- 1 root root 276 Dec  9 03:59 vmware-tools-libraries.conf-rw-r--r-- 1 root root  21 Nov 21 09:41 xulrunner-32.conf[root@localhost ld.so.conf.d]# cat mysql-i386.conf/usr/lib/mysql

要添加庫檔案路徑只需要在ld.so.conf.d:裡面添加一個conf檔案指定路徑,比如上面的mysql-i386.conf,就指明了路徑。之所以可以如此是因為:

在檔案ld.so.conf裡面只有一句:

1 include ld.so.conf.d/*.con

著作權,轉載請註明!

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.