登入後開terminal以root執行指令 - Linux

Isabella avatar
By Isabella
at 2016-03-11T11:21

Table of Contents


各位溫拿好

小魯我現在有個腳本(假設叫aaa好了)因為有些互動指令

所以他需要開著terminal來持續運作

而且跑他需要sudo或root權限


我現在是用expect寫個自動登入root然後執行aaa的script

再用.config/autostart進桌面後打開terminal跑expect那個script

能夠讓他開機登入桌面之後完成接下來的動作

但是這樣我必須把密碼寫在expect那個script裡面


想請問有沒有甚麼方法能夠讓我登入桌面之後以root權限執行我的aaa呢

有試過rc.d rc.local .bashrc或systemctl這些之類的

雖然是以root權限 但那些都是在開機階段就執行了

aaa必須要登入桌面後再打開terminal用sudo執行


想請問有沒有除了expect這種要把密碼寫在裡面之外更好的辦法?

先謝謝各位啦





--
董卓宴請呂布李儒等心腹,貂蟬作陪。卓欲試諸人忠誠,命蟬塗黑雙乳。

席間燭忽滅,燭複明後,人手皆黑,獨布手淨。卓遂賞布,布笑,露黑齒。


--
Tags: Linux

All Comments

Linda avatar
By Linda
at 2016-03-11T16:59
先說你想駭別人電腦很難嘛?
Kumar avatar
By Kumar
at 2016-03-14T22:38
可以研究一下 /etc/sudoer ; 記得可以指定跑些程式
不需輸入 root 密碼;但這是大洞,要想清楚
Noah avatar
By Noah
at 2016-03-18T01:31
用 +s 的 binary 跑呢?這樣就只能執行特定指令了
Valerie avatar
By Valerie
at 2016-03-18T12:27
該設備有連網路的話 ssh 遠端登入下指令呼叫不就好了
Robert avatar
By Robert
at 2016-03-20T12:02
然後利用sshkey登入 或是一般user+sudo權限(要調好
Callum avatar
By Callum
at 2016-03-20T23:21
用su可以轉成root帳號
Hazel avatar
By Hazel
at 2016-03-22T17:36
要輸入你的密碼才能轉換

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

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槽 但在安裝的時 ...

請問 git remote rebase 問題

Queena avatar
By Queena
at 2016-03-08T18:37
標題殺人! remote 是無法 rebase 的 問題是這樣的 專案在開發可能會因為開發某 feature 從 master 切 branch 出來 如果需要 master 上面的 update 如果是自己的話就還好 可以自己在 local git rebase 但是如果多人開發同一個 feature ...

關於centos raid 問題

Madame avatar
By Madame
at 2016-03-08T16:14
各位大大: 想請問我有一台 hp server 灌 centos , 已經有硬體 raid ,軟體是一般分割區, 萬一硬碟毀壞了,centos沒設定 raid , 硬體的 hp server 換硬碟應該會自己 raid rebuild 吧 - ...

gpm 無法使用

Liam avatar
By Liam
at 2016-03-08T13:07
大家好: 我用VMPlayer 7.1.3 Host OS 是Win7 Guest OS 是14.04.4 LTS Server板 安裝了gpm 但是游標無法顯示 以下是設定檔/etc/gpm.conf device=/dev/input/mice repeat_type=none type=imps2 ...