開機後自動執行script - Linux

Ingrid avatar
By Ingrid
at 2016-03-11T22:24

Table of Contents

大家好 我想請問一下

我在/home底下寫了一隻script然後a.sh

我希望每次開機以後都會執行這支script

假設內容只有

echo "hello word"

我希望每次打完密碼進來以後他就先執行然後show出hello word

我參考網路上作法

想自動執行一些 shell script或指令可以直接編輯 /etc/rc.local 檔案

所以我就在裡面寫了 bash /home/a.sh

但沒有成功,想請問一下該怎麼做呢?

謝謝大家

--
Tags: Linux

All Comments

Tristan Cohan avatar
By Tristan Cohan
at 2016-03-14T06:30
打完密碼進來->這個應該是進bash的時候吧
那這種的你應該要寫在.bashrc或.bash_profile裏面
Bethany avatar
By Bethany
at 2016-03-14T19:23
.bash_profile只會在bash登入時執行,子程序的bash下不會,
所以如果你只是要在登入時跑這個,那你應該寫在.bash_profi
le。
Agnes avatar
By Agnes
at 2016-03-17T21:59
如果你原先沒有在用.bash_profile,那建議.bash_profile的
開頭加一行這個:
[[ -r ~/.bashrc ]] && . ~/.bashrc
這樣登入時才會跟著讀入.bashrc
Sandy avatar
By Sandy
at 2016-03-22T13:42
感謝大大
Edwina avatar
By Edwina
at 2016-03-23T01:07
[ -r xxxx ] && .... 就好,[[ -r xxxx ]] 多一組了
Skylar DavisLinda avatar
By Skylar DavisLinda
at 2016-03-23T09:07
原來@@
Frederic avatar
By Frederic
at 2016-03-23T15:27
新規格建議用兩個[框起來的說...
Isla avatar
By Isla
at 2016-03-24T23:05
我是記得群組方式一同判斷用 [[ ]] 比較直覺與簡單
Freda avatar
By Freda
at 2016-03-25T05:39
若單純只是 [ -r xxxx ] 判斷單一項目應該就還好

筆電 雙系統Windows 10+Ubuntu 14.04成功

Iris avatar
By Iris
at 2016-03-11T16:37
新買的Acer筆電剛灌好Ubuntu 照著youtube影片加上網友文章跟著做 一開始Windows不理會grub直接啟動 可以在Windows 10輸入指令解決問題 現在情況是觸控板沒反應 Google部分同步整合相當好 還沒遇到異常 現在就是用Google應用程式PttChrome發文的 ...

tw.archive.ubuntu.com 在英國?

Elizabeth avatar
By Elizabeth
at 2016-03-11T11:51
※ 引述《fourdollars (四元)》之銘言: : ※ 引述《fourdollars (四元)》之銘言: : : 所有 *.archive.ubuntu.com 都會在發生問題的時候轉指向 http://archive.ubuntu.com : : 避免服務中斷,不過我看 http://debian.l ...

登入後開terminal以root執行指令

Isabella avatar
By Isabella
at 2016-03-11T11:21
各位溫拿好 小魯我現在有個腳本(假設叫aaa好了)因為有些互動指令 所以他需要開著terminal來持續運作 而且跑他需要sudo或root權限 我現在是用expect寫個自動登入root然後執行aaa的script 再用.config/autostart進桌面後打開terminal跑expect ...

請問欲變更檔案內容,卻出現沒有權限

Callum avatar
By Callum
at 2016-03-09T08:54
小弟想要請問一下 想要變更檔案的內容 卻跳出 Could not save the file You do not have the permission necessary to save the file. Please chech that you typed the location correctl ...

Ubuntu 14.04安裝時偵測不到OS

Hazel avatar
By Hazel
at 2016-03-08T23:42
如題 小弟剛剛想在這台筆電灌雙系統(win7+ubuntu14.04) 目前我的磁碟分割是這樣的 http://i.imgur.com/cHBcqoh.png 我只有一顆1TB的硬碟 win7是灌在C槽 E跟F都剛剛割的 裡面都沒有東西 可以隨意使用 原本想把Ubuntu灌在E槽 但在安裝的時 ...