GNU/Linux >> Tutoriales Linux >  >> Ubuntu

¿Cómo iniciar el servidor Vnc en el arranque?

¿Cómo creo un archivo de inicio automático para todo el sistema? Esto sería en un servidor en la nube que ejecuta la versión de escritorio de Maverick.

Inicié sesión como root y creé un archivo de inicio automático usando System/Preferences/StartupApplications pero terminó en /root/.config/autostart y no se ejecutó (por lo que puedo decir) al reiniciar. El archivo de inicio automático es para invocar un script bash que invoca el servidor VNC.

Copié el archivo de inicio automático .desktop de /root/.config/autostart a /etc/xdg/autostart y reiniciado. Esto no pareció marcar la diferencia.

Editar Como se mencionó en un comentario, el objetivo es ejecutar mi script bash que inicia el servidor VNC al arrancar; no al iniciar sesión.

Mejor respuesta

  1. Primero, instale el servidor TightVNC sudo apt-get install tightvncserver .

  2. Configure el servidor VNC para el usuario con el que desea iniciar sesión. Cuando ejecute "vncserver" por primera vez, le pedirá que establezca una contraseña. solo permita conexiones SSH tuneladas o VPN. Para iniciar programas o una sesión cuando se inicie su sesión de VNC, modifique ~/.vnc/xstartup . Aquí hay un ejemplo.

    #!/bin/sh
    
    xrdb $HOME/.Xresources
    xsetroot -solid black
    /opt/azureus/azureus &
    k3b &
    icewm-session &
    
  3. Copie lo siguiente en /etc/init.d/vncserver . La forma más sencilla de hacerlo es copiarlo en el portapapeles, ejecutar sudo -i && cat > /etc/init.d/vncserver && exit en una terminal, péguelo y escriba CTRL-D. Asegúrese de cambiar la variable USER a cualquier usuario con el que desee que se ejecute el servidor VNC.

    #!/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. Haga que el script sea ejecutable con sudo chmod +x /etc/init.d/vncserver .

  5. Finalmente, conéctese a su servidor con un cliente VNC en el puerto 590X, donde X es el valor de "DISPLAY" en la secuencia de comandos vncserver. En OS X, me gusta usar Chicken of the VNC. En Windows y Linux, el cliente TightVNC funciona bien.
Relacionado:¿Cambiar la dirección Mac permanentemente dentro de /etc/network/interfaces?

Fuente


Ubuntu
  1. Cómo instalar el servidor vnc en RHEL 8 / CentOS 8

  2. Cómo iniciar el servicio al arrancar en Ubuntu 22.04

  3. Cómo instalar y configurar VNC en Ubuntu 20.04

  4. Cómo configurar el servidor X11VNC en Ubuntu y LinuxMint

  5. ¿El servidor Vino Vnc no puede iniciarse al iniciar?

Cómo instalar el servidor VNC en CentOS 6

Cómo instalar el servidor VNC en CentOS 8

Cómo instalar el servidor VNC en Ubuntu 14.04

Cómo instalar el servidor VNC en Ubuntu 18.04 LTS

Cómo instalar el servidor VNC en Ubuntu 20.04 LTS

Cómo instalar el servidor VNC en Linux Mint 20