由ssh引发的对/etc/init.d/目录的思考

本文部分参考:http://blog.csdn.net/acs713/article/details/7322082

/etc/init.d/目录

init.d目录包含许多系统各种服务的启动和停止脚本。我们看一下该目录:

wu@wu-VirtualBox:~$ ls /etc/init.d/
acpid           brltty            dns-clean          icegridregistry  networking     rcS         sendsigs           umountnfs.sh
anacron         console-setup     friendly-recovery  irqbalance       ondemand       README      single             umountroot
apache2         cron              glacier2router     kerneloops       openbsd-inetd  reboot      skeleton           unattended-upgrades
apparmor        cryptdisks        gmetad.init        killprocs        pppd-dns       resolvconf  speech-dispatcher  urandom
apport          cryptdisks-early  gmond              kmod             procps         rsync       ssh                vboxadd
avahi-daemon    cups              grub-common        lightdm          pulseaudio     rsyslog     sudo               vboxadd-service
binfmt-support  cups-browsed      halt               mongodb          rc             saned       udev               vboxadd-x11
bluetooth       dbus              icegridnode        mysql            rc.local       sendmail    umountfs           x11-common
wu@wu-VirtualBox:~$ 

为了能够使用init.d目录下的脚本,你需要有root权限或sudo权限。每个脚本都将被作为一个命令运行,该命令的结构大致如下所示:
/etc/init.d/command    选项
comand是实际运行的命令,以下几个是常用的选项:

  • start
  • stop
  • restart

1)ssh

这两天遇到了一个ssh的问题,当我

wu@wu-VirtualBox:~$ ssh zxl@192.168.1.114
zxl@192.168.1.114's password: 
Permission denied, please try again.

密码肯定是没有输错的,但是在zxl那台机子上看到ssh是一直启动着的。这时候不知道怎么回事,网上搜索的方法千篇一律,根本解决不了。于是在[email protected]这台机子上运行

zxl@zxl-VirtualBox:~$ sudo service ssh restart

这下子在回到自己的机子上运行,你看到没?这样竟然行了。。。所以大家也遇到这种问题的时候不妨也这么试试。

wu@wu-VirtualBox:~$ ssh zxl@192.168.1.114
zxl@192.168.1.114's password: 
Welcome to Ubuntu 14.04 LTS (GNU/Linux 3.13.0-29-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

691 packages can be updated.
374 updates are security updates.

Last login: Wed Apr 20 20:12:53 2016 from 192.168.1.100
zxl@zxl-VirtualBox:~$

看到有些博客说是服务端是sshd脚本,我觉得也是,但是从/etc/init.d目录下可以看到,sshd这个文件是不存在的,这个我觉得应该是版本的问题吧,我的ssh远程服务端机子是ubuntu14.04。

2)nomachine

  1. 先说putty
    一般情况下,我们用putty在自己的windows上远程登录到另一台linux机子上,但是图形界面不够友好,只有终端命令行界面,要想在开一个终端,必须再用putty登录一次,比较麻烦

  2. 命令行用ssh
    这个问题和上面的一模一样

  3. nomachine
    这个远程登录就相当于qq的远程协助,和直接用远程的电脑是一样的,所以有时候需要图形界面的时候nomachine就能用上,在远程电脑打开多个终端也比较方便。

说这个东西是因为也遇到过类似上面ssh的问题,服务端的nomachine我之前都是通过打开nomachine图形界面启动的,图形界面如下:
由ssh引发的对/etc/init.d/目录的思考_第1张图片

之前服务器nomachine通过这种方式遇到过死活起不了,也不知道怎么回事,那个时候比较笨,直接关机重启,没有想那么多。现在想想我们不是可以用上面 的方法吗?

ubuntu@ubuntu:~$ sudo service nxserver restart

这样不就搞定了吗,以后再也不用开机重启那么暴力了。

你可能感兴趣的:(由ssh引发的对/etc/init.d/目录的思考)