在日常使用过程中,当有时候需要运行开机自启脚本,同时想看到输出结果的时候,不免就需要将系统配置为免密登录模式,本文主要介绍再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系统配置脚本开机自启相关推荐

  1. linux 安装redis以及配置redis开机自启

    linux 安装redis 非常简单,官网有介绍. 步骤如下: 一安装redis: 1.先查看redis版本,找到你想下载的版本:http://download.redis.io/releases/ ...

  2. Linux下redis安装并设置开机自启(超详细)

    一 : 下载安装redis (1)下载redis 可以到官网下载 : http://download.redis.io/releases/redis-4.0.8.tar.gz 也可以通过linux命令 ...

  3. linux下redis权限,Linux(Centos)下Redis开机自启设置

    1.设置redis.conf中daemonize为yes,确保守护进程开启. 2.编写开机自启动脚本 vi /etc/init.d/redis 脚本内容如下: # chkconfig: 2345 10 ...

  4. linux 设置rides(5.0.3)开机自启

    原文链接 先把最新版本下载下来,如下所示,然后使用命令解压出来: tar xf redis-5.0.3.tar.gz 解压完成后,文件如第二张图中所示: 这个时候就需要进行编译安装,先切换到这个目录中 ...

  5. linux httpd 开机启动脚本,httpd服务如何开机启动

    在之前的学习中我们已经知道怎样收到启动服务或者停止服务,以httpd服务在Redhat5.centos6为例: 启动服务: service httpd start 停止服务: service http ...

  6. linux init.d添加启动脚本 ln,linux编写可运行的shell脚本并在其他目录创建ln连接与设置开机启动...

    ln :创建连接文件 - 默认创建的是硬连接,好比复制 ,但是两个文件会同步 命令:ln ./java/android/aa.txt  aaa - s :创建的是软连接变为指向(类似于windows的 ...

  7. linux启用shell脚本,linux下开机启动shell脚本

    背景 设置比较炫酷的开机启动脚本 首先,新建一个kaiji.sh 后缀名的脚本-->新建的脚本在任何位置创建都可以,只要在使用.sh 文件,时候使用绝对路径即可 [root@hf-01 ~]# ...

  8. Linux系统【Ubuntu】开机自启脚本及配置

    Linux系统[Ubuntu]开机自启脚本及配置 1.使用vim命令在`/etc/init.d`目录下新建一个xx.sh,文件名可自定义,以test.sh为例 2.保存成功以后,设置文本权限,否则不生 ...

  9. linux开发板开机自启动脚本,linux 添加开机自启动脚本

    Linux设置服务开机自动启动的方式有好多种,这里介绍一下通过chkconfig命令添加脚本为开机自动启动的方法. 1. 编写脚本autostart.sh(这里以开机启动redis服务为例),脚本内容 ...

最新文章

  1. linux rpm 安装包制作
  2. 了解自定义De / Serializer:JSON绑定概述系列
  3. spring boot配置ip_Spring Cloud 配置中心高可用搭建
  4. Win10文件夹空白处右键列表添加命令提示符
  5. (文中有惊喜)走进云时代的数据库
  6. nginx发布静态目录备忘
  7. JAVA文件传输原理及介绍—狂神说
  8. 人民日报:今天,大学培养的人才合格吗?
  9. 深信服ACssh登录
  10. python画人脸代码_[转]7行Python代码的人脸识别
  11. 数值微分25 - Poisson 泊松方程(一维、二维):已知一些自定义的二阶导数点,得到一条曲线,即原方程平滑地通过它们)
  12. 模拟器安装app 报错误 INSTALL_FAILED_NO_MATCHING_ABIS
  13. 测试人员花样甩锅技巧
  14. 虚幻引擎学习笔记——Month1 Week2
  15. 金蝶K3采购暂估案例教程3差额调整
  16. 如何修炼java内功
  17. 戴尔台式计算机怎么拆卸两块侧板,高效易用 戴尔OptiPlex 7050商用台式机评测
  18. Linux删除文件夹和文件的命令
  19. Bloom Filter
  20. 关于深度学习理论和架构的最新综述(part3)

热门文章

  1. 带标题的图片轮询展示
  2. Centos中不从skel目录里向其中复制任何文件错误的解决方法
  3. [转]打造自己的LINQ Provider(上):Expression Tree揭秘
  4. Jsoup 抓取和数据页 认识HTTP头
  5. CAS去掉HTTPS认证
  6. ASP.NET MVC3数据绑定到VIEW的方式
  7. 废水处理计算书 excel_废水监测数据是匿名的吗?
  8. 数据eda_关于分类和有序数据的EDA
  9. 吹气球问题的C语言编程,C语言怎样给一个数组中的数从大到小排序
  10. 线性回归非线性回归_了解线性回归