centos 7.0 ln命令 和chkconfig 命令介绍 开机自动启 服务

有时候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 服务 启动

 

[root@localhost ~]# 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 links
can hold arbitrary text; if later resolved, a relative link is
interpreted 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 through
the 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 controls
behavior 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'
[root@localhost ~]#

使用chkconfig命令  

 

输出 所有服务列表

chkconfig --list

chkconfig --list denyhosts 列表中的denyhosts服务

[root@localhost ~]# 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

转载于:https://www.cnblogs.com/xxx91hx/p/4378037.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值