How to Change the VNC Password in Linux

What is a VNC Password and How do you Change the VNC Password in Linux?

VNC stands for Virtual Network Computing. In Linux, VNC is a system that allows a computer user to control another computer remotely using a graphical interface. That is to say, VNC enables the user to interact with the Linux desktop using a keyboard and mouse of a different computer over a network. 

We require a VNC password to authenticate a user to the VNC server, i.e., the application running on the remote computer. That is to say, an anonymous person will not be allowed access to the VNC server without verification.

Nowadays, recent Linux releases come with VNC in their installations. If you do not have VNC installed, follow these steps on How to Install VNC on Ubuntu. Now, let’s continue and look at how to change the VNC password in Linux.

So, let’s dive right in!

What is a VNC Password?

A VNC password is used to authenticate a user to the VNC server. As a result, once a user is authenticated, they can remotely interact and control the desktop, keyboard, and mouse of another computer.

Your VNC password and the password you use to log in to your Linux computer are distinct entities. Therefore it is advisable to set your VNC password to be different from your Linux login password.

Further, let’s note that a user usually sets and can change the VNC password themselves. This password is generally encrypted. Similarly, a user can decrypt or delete it and replace it with another one. Deleting and replacing it is the option that is mainly recommended. 

How to Change the VNC Password.

We use the VNC password command to set or change the VNC password in Linux. The VNC password is stored in an encrypted version. Also, ensure that you set a strong password so that the system is not accessed by unauthorized persons.

Here is the command:


The vncpasswd command requests for a VNC password to access VNC desktops. It allows us to change a VNC password for security reasons. It is also advisable to change your password after every few months to lower the risk of someone obtaining it and gaining access to your system. 

The vncpasswd command also lets us set the VNC password for the first time. It requests the password twice. The first password is the primary password.

Here is how to change the VNC password in Linux:

  1. Start by opening your Command Terminal by pressing Ctrl + Alt + T.
  1. Now, type the command vncpasswd
  1. Then, you will be prompted to enter your VNC password. If the password is below 6 characters, the output too short is seen as shown below:
vnc password in linux

If the password is more than 8 characters, the additional characters will be truncated. In other words, the extra characters will be ignored. 

vnc password in linux
  1. From there, enter an appropriate VNC password and verify it. That is the primary password.
primary password

The second password is the read-only password. If it is too short, it will not be saved. It authenticates for view-only desktops.

  1. After that, you can choose to enter a view-only password by typing ‘y‘ for yes or ‘n‘ for no. When you select y, continue and enter a view-only password and then verify it. 

Where is the VNC Password stored?

The VNC password is stored in the passwd file, which is usually in the .vnc folder by default. In other words, this is the location of the password when the VNC server runs for the first time. 

If we run the command vncpasswd and get the alert VNC directory does not exist, it means that the .vnc folder and passwd file do not exist.

In the same vein, the vncpasswd command goes ahead and creates the hidden .vnc folder. You will be prompted to enter the password and verify it to create the folder and file successfully.

.vnc folder

When you are done with that, you may want to view it. 

Here is how you can check where the VNC password is stored using the graphical user interface.

  1. Begin by going to home
  2. Then click View from the menu. 
  3. After that, move your mouse and select Show Hidden Files. All hidden folders, which begin with a dot (.) are displayed. 
  4. Finally, you will see the folder .vnc and when you open it, you will find the file passwd inside.

Here is how to view this same folder on Command Terminal.

  1. First, go to home by typing ‘cd /home‘.
  2. Then, type the command ls -a to view the hidden files. You will see the .vnc folder, among other hidden files and folders.
  3. With that out of the way, access the folder by typing ‘cd .vnc/‘ 
  4. Lastly, type the command ls to view the files inside the folder. In this case, it’s the passwd file where the VNC password is stored.
vnc password in linux

For clarity, here is the default path where the VNC password is stored.


How to Remove the VNC Password.

We usually remove the VNC password to allow another one to be created or changed and then stored. To remove the passwd file which contains the VNC password, use the command below in your Command Terminal.

sudo rm ~/.vnc/passwd 

You can also remove the file using the graphical interface. 

Here is how:

  1. Start by opening the home folder.
  2. Now, click View from the menu.
  3. Then, click Show Hidden Files.
  4. Then, click on .vnc folder to open.
  5. Finally, right-click on the file passwd and select Move to Trash.

You can confirm by checking in the .vnc folder that the file doesn’t exist anymore.  

We’ve come to the end of our article. Certainly, remember that you should not share your VNC password with anyone because it gives them full control of your system. That means they can change important settings or even delete critical files.

In conclusion, we hope you have learned How to Change the VNC password in Linux. We also hope we helped you learn more about where the VNC password is stored. If you have any questions or suggestions, let us know in the comment section below.

If this guide helped you, please share it. 🙂


Leave a Reply

Your email address will not be published. Required fields are marked *