GNU/Linux >> Linux Esercitazione >  >> Ubuntu

Come avviare il server Vnc all'avvio?

Come faccio a creare un file di avvio automatico a livello di sistema? Questo sarebbe su un server cloud che esegue la versione desktop di Maverick.

Ho effettuato l'accesso come root e ho creato un file di avvio automatico utilizzando System/Preferences/StartupApplications ma è finito in /root/.config/autostart e non è stato eseguito (per quanto ne so) al riavvio. Il file di avvio automatico serve per invocare uno script bash che richiama il server VNC.

Ho copiato il file di avvio automatico .desktop da /root/.config/autostart su /etc/xdg/autostart e riavviato. Questo non sembrava fare la differenza.

Modifica Come accennato in un commento, l'obiettivo è eseguire il mio script bash che avvia il server VNC all'avvio; non su un accesso.

Migliore risposta

  1. Innanzitutto, installa il server TightVNC sudo apt-get install tightvncserver .

  2. Configura il server VNC per l'utente con cui desideri accedere. Quando esegui "vncserver" per la prima volta, ti verrà chiesto di impostare una password. consentire solo connessioni tramite tunnel SSH o VPN. Per avviare programmi o una sessione all'avvio della sessione VNC, modificare ~/.vnc/xstartup . Ecco un esempio.

    #!/bin/sh
    
    xrdb $HOME/.Xresources
    xsetroot -solid black
    /opt/azureus/azureus &
    k3b &
    icewm-session &
    
  3. Copia quanto segue in /etc/init.d/vncserver . Il modo più semplice per farlo è copiarlo negli appunti, eseguire sudo -i && cat > /etc/init.d/vncserver && exit in un terminale, incollalo e digita CTRL-D. Assicurati di modificare la variabile USER in qualsiasi utente con cui desideri eseguire il server 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. Rendi lo script eseguibile con sudo chmod +x /etc/init.d/vncserver .

  5. Infine, connettiti al tuo server con un client VNC sulla porta 590X, dove X è il valore di "DISPLAY" nello script vncserver. Su OS X, mi piace usare Chicken of the VNC. Su Windows e Linux, il client TightVNC funziona bene.
Correlati:modificare l'indirizzo Mac in modo permanente all'interno di /etc/network/interfaces?

Fonte


Ubuntu
  1. Come installare il server vnc su RHEL 8 / CentOS 8

  2. Come avviare il servizio all'avvio su Ubuntu 22.04

  3. Come installare e configurare VNC su Ubuntu 20.04

  4. Come configurare il server X11VNC su Ubuntu e LinuxMint

  5. Il server Vino Vnc non riesce ad avviarsi all'avvio?

Come installare il server VNC su CentOS 6

Come installare il server VNC su CentOS 8

Come installare il server VNC su Ubuntu 14.04

Come installare il server VNC su Ubuntu 18.04 LTS

Come installare il server VNC su Ubuntu 20.04 LTS

Come installare il server VNC su Linux Mint 20