vnc 启动运行

整理

.bashrc .bash_profile

/etc/rc.local

 /etc/init.d/rc.local


自启动ngix,其中ngix是一个脚本,在脚本中再启动真实的程序

/etc/init.d/nginx
update-rc.d nginx defaults

sudo /etc/init.d/nginx  start



参考http://www.gagahappy.com/ubuntu-mysql-add-to-service/设置开机启动

root@vieri-desktop:/home/vieri# cp usr/share/mysql/mysql.server /etc/init.d/mysql
root@vieri-desktop:/home/vieri# chmod +x /etc/init.d/mysql
chkconfig -add mysql命令报错
用ubantu带的update-rc.d命令添加自启动
root@vieri-desktop:/home/vieri# cd /etc/init.d
root@vieri-desktop:/etc/init.d# update-rc.d mysql defauts
update-rc.d: warning: mysql start runlevel arguments (none) do not match LSB Default-Start values (2 3 4 5)
update-rc.d: warning: mysql stop runlevel arguments (none) do not match LSB Default-Stop values (0 1 6)
usage: update-rc.d [-n] [-f] <basename> remove
       update-rc.d [-n] <basename> defaults [NN | SS KK]
       update-rc.d [-n] <basename> start|stop NN runlvl [runlvl] [...] .
       update-rc.d [-n] <basename> disable|enable [S|2|3|4|5]
        -n: not really
        -f: force
添加
root@vieri-desktop:/etc/init.d# update-rc.d mysql defaults
 Adding system startup for /etc/init.d/mysql ...
   /etc/rc0.d/K20mysql -> ../init.d/mysql
   /etc/rc1.d/K20mysql -> ../init.d/mysql
   /etc/rc6.d/K20mysql -> ../init.d/mysql
   /etc/rc2.d/S20mysql -> ../init.d/mysql
   /etc/rc3.d/S20mysql -> ../init.d/mysql
   /etc/rc4.d/S20mysql -> ../init.d/mysql
   /etc/rc5.d/S20mysql -> ../init.d/mysql

查看启动

root@vieri-desktop:/etc/init.d# chkconfig --list mysql
mysql                     0:off  1:off  2:on   3:on   4:on   5:on   6:off


删除
The disable|enable API is not stable and might change in the future.
root@vieri-desktop:/etc/init.d# update-rc.d -f mysql remove
 Removing any system startup links for /etc/init.d/mysql ...
   /etc/rc0.d/K20mysql
   /etc/rc1.d/K20mysql
   /etc/rc2.d/S20mysql
   /etc/rc3.d/S20mysql
   /etc/rc4.d/S20mysql
   /etc/rc5.d/S20mysql
   /etc/rc6.d/K20mysql



Start a VNC Server on Ubuntu on Boot

Ubuntu makes many things easy. For example, with Gnome, it's very simple to set up remote access to your desktop with the included Vino application. The only problem is that to get the VNC server running, you have to be logged in! Luckily, it's not too difficult to create a script which starts up the server as soon as your system boots. This is especially handy if you are running a headless server, or are using the primary display for other purposes. In this case, my server runsMythTV on the normal X server connected to my TV, but starts up Azureus and K3B in a VNC session so I can access them without bothering those watching TV.

To set it up, follow these steps:

  1. First, install the TightVNC server. This VNC server has excellent compatibility with clients, and provides reasonable compression for slow networks. It can be installed with Synaptic, or withsudo aptitude install tightvncserver.
  2. Set up the VNC server for the user you wish to log in as. When you run "vncserver" for the first time, it will ask you to set a password. VNC authentication is not the strongest encryption available, so be sure to firewall your server from all but trusted machines. Better yet, deny direct access to VNC and only allow SSH tunnelled or VPN connections. To launch programs or a session when your VNC session starts, modify~/.vnc/xstartup. Here is my copy of xstartup: it runs an icewm session, Azureus, and K3B. For Gnome, try running "gnome-session", and for KDE, try "startkde".
    #!/bin/sh

    xrdb $HOME/.Xresources
    xsetroot -solid black
    /opt/azureus/azureus &
    k3b &
    icewm-session &

  3. Copy the following into /etc/init.d/vncserver. The easiest way to do it is to copy it to your clipboard, runsudo -i && cat > /etc/init.d/vncserve && exit in a terminal, paste it in, and typeCTRL-D. Be sure to change the USER variable to whatever user you want the VNC server to run under.
    #!/bin/sh -e
    ### BEGIN INIT INFO
    # Provides:          vncserver
    # Required-Start:    networking
    # Default-Start:     3 4 5
    # Default-Stop:      0 6
    ### END INIT INFO

    PATH="$PATH:/usr/X11R6/bin/"

    # The Username:Group that will run VNC
    export USER="mythtv"
    #${RUNAS}

    # The display that VNC will use
    DISPLAY="1"

    # Color depth (between 8 and 32)
    DEPTH="16"

    # The Desktop geometry to use.
    #GEOMETRY="<WIDTH>x<HEIGHT>"
    #GEOMETRY="800x600"
    GEOMETRY="1024x768"
    #GEOMETRY="1280x1024"

    # The name that the VNC Desktop will have.
    NAME="my-vnc-server"

    OPTIONS="-name ${NAME} -depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}"

    . /lib/lsb/init-functions

    case "$1" in
    start)
    log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISPLAY}"
    su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"
    ;;

    stop)
    log_action_begin_msg "Stoping vncserver for user '${USER}' on localhost:${DISPLAY}"
    su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"
    ;;

    restart)
    $0 stop
    $0 start
    ;;
    esac

    exit 0

  4. Make the script executable with sudo chmod +x /etc/init.d/vncserver.
  5. Then, run sudo update-rc.d vncserver defaults. This adds the appropriate symlinks to the vncserver script so that it is sent the start and stop commands at the appropriate time.Update: jpb writes that you may need to use sudo update-rc.d vncserver 99 instead if the job is running too early in the boot process.
  6. To start the server without rebooting, run sudo /etc/init.d/vncserver start
  7. Finally, connect to your server with a VNC client on port 590X, where X is the value of "DISPLAY" in the vncserver script. On OS X, I like to useChicken of the VNC. On Windows and Linux, the TightVNC client works nicely.

Of course, this script should work as expected on any Debian-based distribution. If you have problems with performance, try lowering the screen resolution. 800x600 ismuch faster than 1024x768 over slow connections.



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值