關於「~/bin」 [論壇 - Ubuntu基本設定]
正在瀏覽:
1 名遊客
關於「~/bin」 |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員五級
![]() ![]() 註冊日期:
2012/4/22 10:50 所屬群組:
已註冊使用者 等級: 37
HP : 0 / 905
![]() |
剛在下面這篇,看到一個回覆有提問,有提到關於「~/bin」的議題,
因為在那沒帳號,所以貼在這回覆。 https://kaif.io/z/compiling/debates/V5JY1Ykjtt ================================================================================ 我的環境是「Ubuntu 18.04」,我使用的是「bash」。 ================================================================================ 關於「~/bin」,可以在「~/.profile」找到。請參考下面的藍色字。 關於「PATH」的概念,請參考「鳥哥的 Linux 私房菜 / 6.1.3 關於執行檔路徑的變數: $PATH」。 而「PATH」相關的檔案,請參考「/etc/environment」。 關於「~/bin」這個資料夾,預設是沒有的,請執行「mkdir -p ~/bin」。 ================================================================================ 執行
顯示 # ~/.profile: executed by the command interpreter for login shells. # This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login # exists. # see /usr/share/doc/bash/examples/startup-files for examples. # the files are located in the bash-doc package. # the default umask is set in /etc/profile; for setting the umask # for ssh logins, install and configure the libpam-umask package. #umask 022 # if running bash if [ -n "$BASH_VERSION" ]; then # include .bashrc if it exists if [ -f "$HOME/.bashrc" ]; then . "$HOME/.bashrc" fi fi # set PATH so it includes user's private bin if it exists if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH" fi # set PATH so it includes user's private bin if it exists if [ -d "$HOME/.local/bin" ] ; then PATH="$HOME/.local/bin:$PATH" fi ================================================================================ 若是把「~/.profile」改爛了,可以到「/etc/skel/.profile」找到備份,來復原。
================================================================================ 關於「~/.profile」,要注意上面「紅色字」提到的情境。 ================================================================================ 關於「~/.bashrc」,請參考上面綠色字。 建議不要在「~/.profile」修改,而是在「~/.bashrc」修改。 或是有一種模式,在「~/.bashrc」加入「source "$HOME/.my_profile"」, 然後只要在「~/.my_profile」修改,就可以預防把「~/.bashrc」改爛。 不過有一些自動安裝的「Script」,安裝的過程可能就會修改到「~/.bashrc」。 註:關於上面提到的「~/.my_profile」可以自行命名。 懂了這個原理後,也可以從中自成自己的一套系統,自己定義檔案要擺在那, 這個就需要自行發揮了。 ================================================================================ 若是把「~/.bashrc」改爛了,可以到「/etc/skel/.bashrc」找到備份,來復原。
================================================================================ 回到「~/bin」, 舉例,我通常習慣會把「composer」和「youtube-dl」安裝在「~/bin」。 雖然我的系統有一個「Package: youtube-dl」, 但是「youtube-dl」有時候需要更新, 我就直接執行「youtube-dl --update」,就會更新「~/bin/youtube-dl」。 然後您會好奇,執行「youtube-dl」會先執行「~/bin/youtube-dl」還是「/usr/bin/youtube-dl」, 關鍵在於上面藍色字的設定「PATH="$HOME/bin:$PATH"」, 可以看到「$HOME/bin」是設在「$PATH」前, 您可以執行「echo $PATH」,來看到您的「PATH」。 執行
顯示
也就是會先找到「~/bin/youtube-dl」。 執行
顯示
================================================================================ 而「mpv」會用到「youtube-dl」,請參考「mpv-0.27.2/player/lua/ytdl_hook.lua」。 執行下面指令,可以下載「mpv」的原始碼。
## mpv相關的討論 * #4 回覆: mpv播放影片控制時間問題請教 * #6 回覆: 關於「m3u」和「mpv」和「smplayer」的操作使用 ================================================================================ 然後我在「Ubuntu 18.04」發現到,有新加入「.local/bin」這個路徑,請參考上面的紫色字。 ================================================================================ 關於「/etc/skel/」 執行
顯示 bash, base-files: /etc/skel 執行
顯示
執行
顯示
## Package * base-files * bash ================================================================================ 之前有對一些檔案路徑做探索,有紀錄在下面的連結 * http://samwhelp.github.io/book-ubuntu-qna/read/howto/explore/ * http://samwhelp.github.io/book-ubuntu-qna/read/howto/configure-font/fontconfig/ ================================================================================ 以上是我個人的操作習慣, 提供參考 ![]()
2019/11/27 0:17
|
||||||||||
![]() |
您可以查看帖子.
您不可發帖.
您不可回覆.
您不可編輯自己的帖子.
您不可刪除自己的帖子.
您不可發起投票調查.
您不可在投票調查中投票.
您不可上傳附件.
您不可不經審核直接發帖.