標籤:
有時候centos需要 程式開機啟動的時候 自啟動
首先在 /etc/init.d/
cd /etc/init.d
檔案夾下建立開機啟動項
使用ln命令
使用方式 : ln [options] source dist,其中 option 的格式為 :
[-bdfinsvF] [-S backup-suffix] [-V {numbered,existing,simple}]
[--help] [--version] [--]
說明 : Linux/Unix 檔案系統中,有所謂的連結(link),我們可以將其視為檔案的別名,而連結又可分為兩種 : 硬連結(hard link)與軟連結(symbolic link),硬連結的意思是一個檔案可以有多個名稱,而軟連結的方式則是產生一個特殊的檔案,該檔案的內容是指向另一個檔案的位置。硬連結是存在同一個檔案系統中,而軟連結卻可以跨越不同的檔案系統。
ln source dist 是產生一個連結(dist)到 source,至於使用硬連結或軟鏈結則由參數決定。
不論是硬連結或軟鏈結都不會將原本的檔案複製一份,只會佔用非常少量的磁碟空間。
參數 :
-f : 鏈結時先將與 dist 同檔名的檔案刪除
-d : 允許系統管理者硬鏈結自己的目錄
-i : 在刪除與 dist 同檔名的檔案時先進行詢問
-n : 在進行軟連結時,將 dist 視為一般的檔案
-s : 進行軟鏈結(symbolic link)-v : 在連結之前顯示其檔名
-b : 將在鏈結時會被覆寫或刪除的檔案進行備份
-S SUFFIX : 將備份的檔案都加上 SUFFIX 的字尾
-V METHOD : 指定備份的方式
--help : 顯示輔助說明
--version : 顯示版本
軟連結 (捷徑?)
ln -s /usr/share/denyhosts/demantion denyhosts
都放在/etc/init.d下
做自啟動的時候 軟串連ln -s 到/etc/init.d下 然後再chkconfig 服務 啟動
[[email protected] ~]# ln --help用法:ln [選項]... [-T] 目標 連結名 (第一種格式) 或:ln [選項]... 目標 (第二種格式) 或:ln [選項]... 目標... 目錄 (第三種格式) 或:ln [選項]... -t 目錄 目標... (第四種格式)In the 1st form, create a link to TARGET with the name LINK_NAME.In the 2nd form, create a link to TARGET in the current directory.In the 3rd and 4th forms, create links to each TARGET in DIRECTORY.Create hard links by default, symbolic links with --symbolic.By default, each destination (name of new link) should not already exist.When creating hard links, each TARGET must exist. Symbolic linkscan hold arbitrary text; if later resolved, a relative link isinterpreted in relation to its parent directory.Mandatory arguments to long options are mandatory for short options too. --backup[=CONTROL] 為每個已存在的目標檔案建立備份檔案 -b 類似--backup,但不接受任何參數 -d, -F, --directory 建立指向目錄的永久連結(只適用於超級使用者) -f, --force 強行刪除任何已存在的目標檔案 -i, --interactive prompt whether to remove destinations -L, --logical dereference TARGETs that are symbolic links -n, --no-dereference treat LINK_NAME as a normal file if it is a symbolic link to a directory -P, --physical make hard links directly to symbolic links -r, --relative create symbolic links relative to link location -s, --symbolic make symbolic links instead of hard links -S, --suffix=SUFFIX override the usual backup suffix -t, --target-directory=DIRECTORY specify the DIRECTORY in which to create the links -T, --no-target-directory treat LINK_NAME as a normal file always -v, --verbose print name of each linked file --help 顯示此協助資訊並退出 --version 顯示版本資訊並退出The backup suffix is ‘~‘, unless set with --suffix or SIMPLE_BACKUP_SUFFIX.The version control method may be selected via the --backup option or throughthe VERSION_CONTROL environment variable. Here are the values: none, off 不進行備份(即使使用了--backup 選項) numbered, t 備份檔案加上數字進行排序 existing, nil 若有數位備份檔案已經存在則使用數字,否則使用普通方式備份 simple, never 永遠使用普通方式備份Using -s ignores -L and -P. Otherwise, the last option specified controlsbehavior when a TARGET is a symbolic link, defaulting to -P.GNU coreutils online help: <http://www.gnu.org/software/coreutils/>請向<http://translationproject.org/team/zh_CN.html> 報告ln 的翻譯錯誤要擷取完整文檔,請運行:info coreutils ‘ln invocation‘[[email protected] ~]#
使用chkconfig命令
輸出 所有服務列表
chkconfig --list
chkconfig --list denyhosts 列表中的denyhosts服務
[[email protected] ~]# chkconfig --list denyhosts注意:該輸出結果只顯示 SysV 服務,並不包含原生 systemd 服務。SysV 配置資料可能被原生 systemd 配置覆蓋。 如果您想列出 systemd 服務,請執行 ‘systemctl list-unit-files‘。 欲查看對特定 target 啟用的服務請執行 ‘systemctl list-dependencies [target]‘。denyhosts 0:關 1:關 2:開 3:開 4:開 5:開 6:關
0表示:表示關機
1表示:單一使用者模式
2表示:無網路連接的多使用者命令列模式
3表示:有網路連接的多使用者命令列模式
4表示:不可用
5表示:帶圖形介面的多使用者模式
6表示:重新啟動
添加服務
chkconfig --add 服務名
chkconfig --add denyhosts
刪除服務
chkconfig --del denyhosts
開機啟動
chkconfig 服務名 on
chkconfig denyhosts on
關閉開機啟動
chkconfig denyhosts off
centos 7.0 ln命令 和chkconfig 命令介紹 開機自動啟 服務