acbd46
# What has changed
acbd46
The previous Tigervnc versions had a wrapper script called `vncserver` which 
acbd46
could be run as a user manually to start *Xvnc* process. The usage was quite 
acbd46
simple as you just run
acbd46
```
acbd46
$ vncserver :x [vncserver options] [Xvnc options]
acbd46
```
acbd46
and that was it. While this was working just fine, there were issues when users
acbd46
wanted to start a Tigervnc server using *systemd*. For these reasons things were 
acbd46
completely changed and there is now a new way how this all is supposed to work.
acbd46
acbd46
 # How to start Tigervnc server
acbd46
 
acbd46
## Add a user mapping
acbd46
With this you can map a user to a particular port. The mapping should be done in 
acbd46
`/etc/tigervnc/vncserver.users` configuration file. It should be pretty 
acbd46
straightforward once you open the file as there are some examples, but basically
acbd46
the mapping is in form
acbd46
```
acbd46
:x=user
acbd46
```
acbd46
For example you can have
acbd46
```
acbd46
:1=test
acbd46
:2=vncuser
acbd46
```
acbd46
acbd46
## Configure Xvnc options
acbd46
To configure Xvnc parameters, you need to go to the same directory where you did
acbd46
the user mapping and open `vncserver-config-defaults` configuration file. This 
acbd46
file is for the default Xvnc configuration and will be applied to every user 
acbd46
unless any of the following applies:
acbd46
* The user has its own configuration in `$HOME/.vnc/config`
acbd46
* The same option with different value is configured in 
acbd46
  `vncserver-config-mandatory` configuration file, which replaces the default 
acbd46
  configuration and has even a higher priority than the per-user configuration.
acbd46
  This option is for system administrators when they want to force particular 
acbd46
  *Xvnc* options.
acbd46
acbd46
Format of the configuration file is also quite simple as the configuration is
acbd46
in form of
acbd46
```
acbd46
option=value
acbd46
option
acbd46
```
acbd46
for example
acbd46
```
acbd46
session=gnome
acbd46
securitytypes=vncauth,tlsvnc
acbd46
desktop=sandbox
acbd46
geometry=2000x1200
acbd46
localhost
acbd46
alwaysshared
acbd46
```
acbd46
### Note:
acbd46
There is one important option you need to set and that option is the session you
acbd46
want to start. E.g when you want to start GNOME desktop, then you have to use
acbd46
```
acbd46
session=gnome
acbd46
```
acbd46
which should match the name of a session desktop file from `/usr/share/xsessions`
acbd46
directory.
acbd46
acbd46
## Set VNC password
acbd46
You need to set a password for each user in order to be able to start the 
acbd46
Tigervnc server. In order to create a password, you just run
acbd46
```
acbd46
$ vncpasswd
acbd46
```
acbd46
as the user you will be starting the server for. 
acbd46
### Note:
acbd46
If you were using Tigervnc before for your user and you already created a 
acbd46
password, then you will have to make sure the `$HOME/.vnc` folder created by 
acbd46
`vncpasswd` will have the correct *SELinux* context. You either can delete this 
acbd46
folder and recreate it again by creating the password one more time, or 
acbd46
alternatively you can run
acbd46
```
acbd46
$ restorecon -RFv /home/<USER>/.vnc
acbd46
```
acbd46
acbd46
## Start the Tigervnc server
acbd46
Finally you can start the server using systemd service. To do so just run
acbd46
```
acbd46
$ systemctl start vncserver@:x
acbd46
```
acbd46
as root or
acbd46
```
acbd46
$ sudo systemctl start vncserver@:x
acbd46
```
acbd46
as a regular user in case it has permissions to run `sudo`. Don't forget to 
acbd46
replace the `:x` by the actual number you configured in the user mapping file. 
acbd46
Following our example by running
acbd46
```
acbd46
$ systemctl start vncserver@:1
acbd46
```
acbd46
you will start a Tigervnc server for user `test` with a GNOME session.
acbd46
acbd46
### Note:
acbd46
If you were previously using Tigervnc and you were used to start it using 
acbd46
*systemd* then you will need to remove previous *systemd* configuration files,
acbd46
those you most likely copied to `/etc/systemd/system/vncserver@.service`, 
acbd46
otherwise this service file will be preferred over the new one installed with
acbd46
latest Tigervnc.
acbd46
acbd46
# Limitations
acbd46
You will not be able to start a Tigervnc server for a user who is already
acbd46
logged into a graphical session. Avoid running the server as the `root` user as
acbd46
it's not a safe thing to do. While running the server as the `root` should work 
acbd46
in general, it's not recommended to do so and there might be some things which
acbd46
are not working properly.