請問 Ubuntu Server 22.04 啟動程序 [論壇 - 新手村]


正在瀏覽:   1 名遊客


 到底部   前一個主題   下一個主題  [無發表權] 請登錄或者註冊

« 1 2 (3)


回覆: 請問 Ubuntu Server 22.04 啟動程序
會員一級
註冊日期:
2022/7/27 14:06
所屬群組:
已註冊使用者
等級: 2
HP : 0 / 31
MP : 4 / 80
EXP: 25
離線
感謝您的回覆跟幫助

不過也有可能看了我的說明,反而被我誤導
==> 倒是不會, 因會很多東西只要串不起來, 邏輯不通, 那麼就表示中間的理解還有很多地方自己還弄不清楚; 況且工作都超過 20年以上, 所以很多東西還是有系統性經驗的

愛因斯坦曾經說過 If tou can't explain it simply, you don't understand it well enough....

所以我會盡量讓自己弄懂, 畢竟學習誤區還是很多的; 像我前幾天回覆, 也發現自己有地方理解又錯了, 慢慢修正, 跟管理一樣

samwhelp 寫到:


呵! 不用急著回覆我,反正我貼上來,就是要讓您參考,只是作個簡單指引

這需要您實際去操作,花時間去做實驗,去探索,去理解...

記得要照我上面「#17」貼的步驟,一步一步地去操作。

也許您慢慢地就會有感覺,有一天突然豁然開朗,找到您想要的答案。

不過也有可能看了我的說明,反而被我誤導,

哈,所以還是會建議您再多去對照參考其他的文章,自己實際動手去探索,找到能讓自己信服的結論。

2022/8/2 9:54
應用擴展 工具箱
回覆: 請問 Ubuntu Server 22.04 啟動程序
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 37
HP : 0 / 901
MP : 671 / 29339
EXP: 6
離線
# systemctl mask

================================================================================

## 前提

剛剛為了測試「systemctl mask」和「systemctl unmask」的功能。

我把「#17」的內容,做了修改。

關於「demo-service-start.service」這個檔案放置路徑

原本是放在「/etc/systemd/system/demo-service-start.service」,

修改成放在「/usr/lib/systemd/system/demo-service-start.service」。

這樣就能使用「systemctl mask」的機制。

================================================================================

## mask

執行


sudo systemctl mask demo-service-start



顯示


Created symlink /etc/systemd/system/demo-service-start.service → /dev/null.



執行


file /etc/systemd/system/demo-service-start.service



顯示


/etc/systemd/system/demo-service-start.service: symbolic link to /dev/null



執行


systemctl status demo-service-start



顯示


○ demo-service-start.service
     Loaded: masked (Reason: Unit demo-service-start.service is masked.)
     Active: inactive (dead)

Aug 04 11:59:23 sam-anywhere systemd[1]: Started Demo Service Start.
Aug 04 11:59:23 sam-anywhere demo-service-start.sh[12228]: This is demo sevice start message!
Aug 04 11:59:23 sam-anywhere systemd[1]: demo-service-start.service: Deactivated successfully.



執行


systemctl list-unit-files demo-*



顯示


UNIT FILE                  STATE  VENDOR PRESET
demo-service-start.service masked enabled      

1 unit files listed.




執行


sudo systemctl start demo-service-start



顯示


Failed to start demo-service-start.service: Unit demo-service-start.service is masked.



================================================================================

## mask

執行


sudo systemctl unmask demo-service-start



顯示


Removed /etc/systemd/system/demo-service-start.service.



執行


file /etc/systemd/system/demo-service-start.service



顯示


/etc/systemd/system/demo-service-start.service: cannot open `/etc/systemd/system/demo-service-start.service' (No such file or directory)



執行


systemctl status demo-service-start



顯示


○ demo-service-start.service - Demo Service Start
     Loaded: loaded (/lib/systemd/system/demo-service-start.service; enabled; vendor preset: enabled)
     Active: inactive (dead)

Aug 04 11:59:23 sam-anywhere systemd[1]: Started Demo Service Start.
Aug 04 11:59:23 sam-anywhere demo-service-start.sh[12228]: This is demo sevice start message!
Aug 04 11:59:23 sam-anywhere systemd[1]: demo-service-start.service: Deactivated successfully.



執行


systemctl list-unit-files demo-*



顯示


UNIT FILE                  STATE   VENDOR PRESET
demo-service-start.service enabled enabled      

1 unit files listed.



執行


sudo systemctl start demo-service-start



執行


systemctl status demo-service-start



顯示


○ demo-service-start.service - Demo Service Start
     Loaded: loaded (/lib/systemd/system/demo-service-start.service; enabled; vendor preset: enabled)
     Active: inactive (dead) since Thu 2022-08-04 13:08:52 CST; 4s ago
    Process: 17094 ExecStart=/usr/local/bin/demo-service-start.sh (code=exited, status=0/SUCCESS)
   Main PID: 17094 (code=exited, status=0/SUCCESS)
        CPU: 13ms

Aug 04 13:08:52 sam-anywhere systemd[1]: Started Demo Service Start.
Aug 04 13:08:52 sam-anywhere demo-service-start.sh[17094]: This is demo sevice start message!
Aug 04 13:08:52 sam-anywhere systemd[1]: demo-service-start.service: Deactivated successfully.



================================================================================

可以對照參考「Linux systemd 系統服務管理基礎教學與範例」,閱讀「遮蔽特定服務」哪個章節。

或是執行「man systemctl

可找到如下的內容

$ man systemctl 寫到:

mask UNIT...
	Mask one or more units, as specified on the command line. This will link these unit
	files to /dev/null, making it impossible to start them. This is a stronger version of
	disable, since it prohibits all kinds of activation of the unit, including enablement
	and manual activation. Use this option with care. This honors the --runtime option to
	only mask temporarily until the next reboot of the system. The --now option may be
	used to ensure that the units are also stopped. This command expects valid unit names
	only, it does not accept unit file paths.

unmask UNIT...
	Unmask one or more unit files, as specified on the command line. This will undo the
	effect of mask. This command expects valid unit names only, it does not accept unit
	file paths.



================================================================================

## 相關案例

想起了以前參與的討論

* #6, #9 - 回覆: 關於設定Debian Jessie /etc/default/tmpfs遇到的狀況

================================================================================

還有剛剛看了在

* #4 - 回覆: Ubuntu 22.04 Server 安裝 hostapd 重新開機 pppoe無法啟動

在下面這個連結,有提到「sudo systemctl unmask hostapd」

* https://mrjimmy.ddns.net/dhcp-server-安裝/

================================================================================

以上修正

報告完畢


2022/8/4 13:45
應用擴展 工具箱
回覆: 請問 Ubuntu Server 22.04 啟動程序
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 37
HP : 0 / 901
MP : 671 / 29339
EXP: 6
離線
在另一個討論「SUSE Product Documentation」,

我有提到一份文件「SUSE Linux Enterprise Server 15 SP3 / 管理指南」,

可以找到其中一個章節「15 systemd 精靈」,

英文版是「15 The systemd daemon」,

剛好跟這個議題相關,紀錄連結,提供您探索時的參考。


2022/8/8 0:04
應用擴展 工具箱

« 1 2 (3)

 [無發表權] 請登錄或者註冊


可以查看帖子.
不可發帖.
不可回覆.
不可編輯自己的帖子.
不可刪除自己的帖子.
不可發起投票調查.
不可在投票調查中投票.
不可上傳附件.
不可不經審核直接發帖.