linux系统配置脚本,Linux系统配置脚本开机自启
在日常使用过程中,当有时候需要运行开机自启脚本,同时想看到输出结果的时候,不免就需要将系统配置为免密登录模式,本文主要介绍再init3模式(多用户命令行界面),运行开机自启脚本及输出脚本指令运行数据结果。本文使用的系统主要为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系统配置脚本开机自启相关推荐
- linux 安装redis以及配置redis开机自启
linux 安装redis 非常简单,官网有介绍. 步骤如下: 一安装redis: 1.先查看redis版本,找到你想下载的版本:http://download.redis.io/releases/ ...
- Linux下redis安装并设置开机自启(超详细)
一 : 下载安装redis (1)下载redis 可以到官网下载 : http://download.redis.io/releases/redis-4.0.8.tar.gz 也可以通过linux命令 ...
- linux下redis权限,Linux(Centos)下Redis开机自启设置
1.设置redis.conf中daemonize为yes,确保守护进程开启. 2.编写开机自启动脚本 vi /etc/init.d/redis 脚本内容如下: # chkconfig: 2345 10 ...
- linux 设置rides(5.0.3)开机自启
原文链接 先把最新版本下载下来,如下所示,然后使用命令解压出来: tar xf redis-5.0.3.tar.gz 解压完成后,文件如第二张图中所示: 这个时候就需要进行编译安装,先切换到这个目录中 ...
- linux httpd 开机启动脚本,httpd服务如何开机启动
在之前的学习中我们已经知道怎样收到启动服务或者停止服务,以httpd服务在Redhat5.centos6为例: 启动服务: service httpd start 停止服务: service http ...
- linux init.d添加启动脚本 ln,linux编写可运行的shell脚本并在其他目录创建ln连接与设置开机启动...
ln :创建连接文件 - 默认创建的是硬连接,好比复制 ,但是两个文件会同步 命令:ln ./java/android/aa.txt aaa - s :创建的是软连接变为指向(类似于windows的 ...
- linux启用shell脚本,linux下开机启动shell脚本
背景 设置比较炫酷的开机启动脚本 首先,新建一个kaiji.sh 后缀名的脚本-->新建的脚本在任何位置创建都可以,只要在使用.sh 文件,时候使用绝对路径即可 [root@hf-01 ~]# ...
- Linux系统【Ubuntu】开机自启脚本及配置
Linux系统[Ubuntu]开机自启脚本及配置 1.使用vim命令在`/etc/init.d`目录下新建一个xx.sh,文件名可自定义,以test.sh为例 2.保存成功以后,设置文本权限,否则不生 ...
- linux开发板开机自启动脚本,linux 添加开机自启动脚本
Linux设置服务开机自动启动的方式有好多种,这里介绍一下通过chkconfig命令添加脚本为开机自动启动的方法. 1. 编写脚本autostart.sh(这里以开机启动redis服务为例),脚本内容 ...
最新文章
- linux rpm 安装包制作
- 了解自定义De / Serializer:JSON绑定概述系列
- spring boot配置ip_Spring Cloud 配置中心高可用搭建
- Win10文件夹空白处右键列表添加命令提示符
- (文中有惊喜)走进云时代的数据库
- nginx发布静态目录备忘
- JAVA文件传输原理及介绍—狂神说
- 人民日报:今天,大学培养的人才合格吗?
- 深信服ACssh登录
- python画人脸代码_[转]7行Python代码的人脸识别
- 数值微分25 - Poisson 泊松方程(一维、二维):已知一些自定义的二阶导数点,得到一条曲线,即原方程平滑地通过它们)
- 模拟器安装app 报错误 INSTALL_FAILED_NO_MATCHING_ABIS
- 测试人员花样甩锅技巧
- 虚幻引擎学习笔记——Month1 Week2
- 金蝶K3采购暂估案例教程3差额调整
- 如何修炼java内功
- 戴尔台式计算机怎么拆卸两块侧板,高效易用 戴尔OptiPlex 7050商用台式机评测
- Linux删除文件夹和文件的命令
- Bloom Filter
- 关于深度学习理论和架构的最新综述(part3)