日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux系统配置脚本,Linux系统配置脚本开机自启

發(fā)布時間:2023/12/9 linux 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux系统配置脚本,Linux系统配置脚本开机自启 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

在日常使用過程中,當有時候需要運行開機自啟腳本,同時想看到輸出結果的時候,不免就需要將系統(tǒng)配置為免密登錄模式,本文主要介紹再init3模式(多用戶命令行界面),運行開機自啟腳本及輸出腳本指令運行數(shù)據(jù)結果。本文使用的系統(tǒng)主要為CentOS7以上、Redhat7以上版本。

配置開機免密登錄

-第一種免密登錄方式

#切換到gdm目錄下,找到custom.conf文件

[root@localhost ~]# cd /etc/gdm/

#改目錄下有很多文件,我們只需要找到custom.confg文件并使用vi打開

[root@localhost gdm]# ls

custom.confg Init PostLogin PreSession Xsession

#打印出來看一下該文件內容

[root@localhost gdm]# cat custom.confg

# GDM configuration storage

[daemon]

[security]

[xdmcp]

[chooser]

[debug]

#Uncomment the line below to turn on debugging

#Enable=true

[root@localhost gdm]# vi custom.confg

~

#找到[daemon],并添加如下內容保存

[daemon]

AutomaticLoginEnable=True

AutomaticLogin=root #自動登錄的用戶名

-第二種免密登錄方式,在本案例中不適用,再CentOS6版本中可行

#切換到getty.target.wants目錄,并找到getty@tty1.service

[root@localhost ~]# cd /etc/systemd/system/getty.target.wants

#該目錄下通常就一個文件

[root@localhost getty.target.wants]# ls

getty@tty1.service

[root@localhost getty.target.wants]# vi getty@tty1.service

~

#打開之后,尋找[Service]下的ExecStart行,并添加--autologin root后,保存

[Serxice]

# the VT is cleared by TTYVDisallocate

ExecStart=-/sbin/agetty --autologin root --noclear %I $TERM

.......

開機自啟腳本

-注:若是腳本無法運行可關閉Linux的防火墻

#打開selinux文件,并找到SELINUX行,修改后面內容,使之disabled

[root@localhost~]# vi /etc/config/selinux

# This file controls the state of SELinux on the system.

# SELINUX= can take one of these three values;

# enforcing - SELinux security policy is enforced.

# permissice - SELinux prints warnings instead of enforcing.

# disabled - No SELinux policy is loaded.

SELINUX=disabled

# SELINUXTYPE= can take one of these three values;

# targeted - Targeted processes are protected.

# minimum - Modification of targeted policy.Only selected processes are protected.

# mls - Multi Level Security protection.

SELINUXTYPE=targeted

-第一種方法

#再root目錄下,找到用戶配置文件.bash_profile

[root@localhost ~]# ls -a

. .bash_logout .......

.. .bash_profile ........

........

#打開該文件,并將光標移至文件末尾,添加自啟腳本路徑及名稱,并保存

[root@localhost ~]# vi .bash_profile

# .bash_profile

# Get the aliases and functions

if [ -f ~/.bashrc ]; then

.~/.bashrc

fi

# User specific environment and startup programs

PATH=#PATH:$HOME/bin

export PATH

sh /root/filenane.sh

-第二種方法

#切換至 /etc/init.d 目錄下,并將腳本拷貝到該目錄

[root@localhost ~]# cd /etc/init.d/

[root@localhost init.d]# cp /root/filename.sh ../init.d/

[root@localhost init.d]# ls

functions netconsole network README rhnsd filename.sh

[root@localhost init.d]# vi filename.sh

~

#在腳本開頭,添加如下內容

> #chkconfig: 2345 80 90

> #description:filename.sh #filename.sh為當前腳本自身名稱

#在chkconfig工具服務列表中增加此服務

[root@localhost init.d]# chkconfig --add filename.sh

聲明:本人所寫的只是本人在使用中遇到的問題做個記錄總結,很多內容也是百度,或者查閱官方文檔,若與他人有重復;若需按照本文配置,請認真確認是否適合你的情況,造成一切損失;本人概不負責。

總結

以上是生活随笔為你收集整理的linux系统配置脚本,Linux系统配置脚本开机自启的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。