If you happen to’re trying to share your desktop over LAN or the Web on Linux, the most effective methods is to host a VNC server. There are a lot of totally different VNC options for desktop sharing on Linux. On this article, we’ll be going over TigerVNC. It gives up a dependable VNC server answer, is simple to put in, and supported on a number of variations of Linux.
SPOILER ALERT: Scroll down and watch the video tutorial on the finish of this text.
Ubuntu
sudo apt set up tigervnc-standalone-server tigervnc-viewer
Debian
sudo apt-get set up tigervnc-standalone-server tigervnc-viewer
Arch Linux
sudo pacman -S tigervnc
Fedora
sudo dnf set up tigervnc-server
OpenSUSE
Grab the TigerVNC package from the OpenSUSE build service page. All fashionable variations of SUSE are supported. To set up, click on the 1-click set up button.
Different Linuxes
TigerVNC is among the most used VNC platforms on the market on Linux. This implies that there’s a good likelihood your distribution is supported, and that there’s an installable bundle out there. Search your Linux distribution’s bundle supervisor for “tiger vnc”, and “tiger vnc server”. Set up them, and proceed with this information.
Can’t discover a bundle? Head over to the official website to discover ways to get a binary, or the supply code as an alternative.
Setup
TigerVNC will routinely configure issues and get them prepared to make use of. To begin the server configuration course of, open up a terminal window. Contained in the terminal window, use the next command:
vncserver
As this command runs within the terminal, the immediate will ask for a password to entry your desktops over VNC. In an online browser, go to strongpasswordgenerator, and generate a safe password. That is important, particularly if you happen to plan to pipe your VNC connections out to the web.
Enter the password into the immediate, and the configuration file will generate itself, and save to ~/.vnc.
Operating The Server
By default, the VNC server you’ve simply arrange will solely run while you open a terminal and run the vncserver command. Since issues are configured already, the software will begin the whole lot up, and print out the deal with to hook up with over the LAN.
vncserver
Observe: to run VNC over the web, discuss with your router’s handbook and port-forward port 111.
Autorun With Systemd
Operating the server with a command is sweet if all you want is fast entry right here and there. Nonetheless, if you happen to’re in want of a relentless connection, one of the simplest ways to go is to allow VNC to continually run through your init system. As most fashionable Linux working methods use systemd, that’s what the instance will cowl.
In case your Linux working system doesn’t use the systemd init system, you’ll want so as to add the “vncserver” command to startup through xinitrc, or one thing related.
Allow the server to run at startup with the next systemd command.
systemctl --user allow vncserver@:1
Don’t run this command exterior of consumer mode, because it might be a safety challenge. Moreover, don’t allow the VNC server to continually run if you don’t belief others in your community.
Killing The VNC Server
Generally TigerVNC might glitch and mess up. If at any time you want to kill the server at any time, use this command.
vncserver -kill :1
Take into accout, this command will solely kill one operating occasion at a time. If you happen to’re operating a number of variations of the server without delay, you’ll have to specify it within the command. To do that, exchange the :1 with the quantity the server gave you while you began it with the command.
Beginning Your Desktop Atmosphere
Simply because you possibly can connect with your VNC server, doesn’t imply something will occur. For one thing to occur while you log in, you’ll have to specify it within an autostart file. Make one by going to a terminal, and getting into:
echo '#!/bin/sh' > ~/.vnc/xstartup chmod u+x ~/.vncxstartup
Subsequent, discover the code to begin the desktop atmosphere. To discover this code, open one other terminal tab, and use the cd command to go to the xsessions listing.
cd /usr/share/xsessions/
Inside this folder, use LS to disclose the whole lot in there. That is the place all of the session information for desktop environments stay. On this instance, we’ll use the LXDE Desktop, however the idea is identical for each desktop atmosphere.
Utilizing cat and grep, reveal the command within the xsession Desktop file.
cat LXDE.desktop | grep "Exec="
Operating the cat command on this session file reveals the beginning command for LXDE:
Exec=/usr/bin/startlxde
Overlook about “Exec=”, and simply concentrate on “/usr/bin/lxde“. Utilizing the Nano textual content editor, paste this newly found code into the startup file, and press Ctrl + O to reserve it.
nano ~/.vnc/xstartup exec /usr/bin/startlxde &
This course of will work with any desktop atmosphere session within /usr/share/xsessions/.
Connecting To A Operating Server
Connecting to a operating VNC server on the community may be very straightforward. To begin off, take into account that every time you run an occasion of the VNC server, it creates a 1. The primary occasion of the server (aka solely operating the command one time) will create:
example-linux-pc:1
Operating it 4 instances, in 4 separate terminals will create:
example-linux-pc:1 example-linux-pc:2 example-linux-pc:3 example-linux-pc:4
So long as the pc wanting to hook up with the session, in addition to the pc internet hosting the session are on the identical community, a connection could be made with simply the hostname. To join, open a terminal and enter the next command.
vncviewer example-linux-pc:1
After getting into the command into the immediate, the TigerVNC GUI software will open, and ask for a password. Enter the password you wrote in in the course of the setup course of to get linked.
Join With GUI As an alternative
Don’t need to join over the command line? In that case, open up the Tiger VNC viewer, and fill out the server deal with contained in the immediate. Enter the password you had been requested to fill out when it began.