Bosse_B
Posts: 836
Joined: Thu Jan 30, 2014 9:53 am

How to enable VNC on RPi3/Raspbian Stretch from command line?

Tue Nov 07, 2017 5:28 pm

I have an RPi3 with Raspbian Stretch that I have worked on via the command line (SSH using PuTTY).
Now I want to use PiClone to make a backup of the system before I leave it in place, but I have no HDMI enabled monitor and PiClone is a GUI utility as far as I understand it...
So I thought of using VNC instead, but I don't know if one can enable it using the command line only?
Since it is Linux my guess is that it is possible, but how?

I believe that in Raspbian Pixel VNC was enabled by default but I don't know on this Stretch version. In any case my VNC viewer cannot connect to it so I guess it is non-active.
If it is not possible to enable using PuTTY there is a hen-and-egg problem here,,,
Bo Berglund
Sweden

klricks
Posts: 6624
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: How to enable VNC on RPi3/Raspbian Stretch from command line?

Tue Nov 07, 2017 5:53 pm

Find VNC in interface menu:

Code: Select all

sudo raspi-config
Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 5201
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.
Contact: Website

Re: How to enable VNC on RPi3/Raspbian Stretch from command line?

Tue Nov 07, 2017 6:02 pm

Although I've not used/tried it, IIRC, there is a "command-line" version of "Pi-clone" (rpi-clone or similar?). Also, in principle, when connected via SSH (PuTTY) with x-forwarding enabled (and an X-windows compatible desktop on the remote machine) any "X-gui program" should display and be usable on the remote machine. (I've used such an approach for many years with other Unix/Linux boxes long before the Pi, and have continued to do so with my "headless" Pi's).
Trev.
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, B2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B+, P3B, B+, A+ and a B2) but Buster on the P4B's. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

Bosse_B
Posts: 836
Joined: Thu Jan 30, 2014 9:53 am

Re: How to enable VNC on RPi3/Raspbian Stretch from command line?

Tue Nov 07, 2017 6:07 pm

klricks wrote:
Tue Nov 07, 2017 5:53 pm
Find VNC in interface menu:

Code: Select all

sudo raspi-config
Thanks, raspi-config did the trick, but now I have a very small screen to work inside...
If I measure correctly it is only 655x380 pixels...
Can the screen size on VNC be adjusted?
Bo Berglund
Sweden

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 5201
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.
Contact: Website

Re: How to enable VNC on RPi3/Raspbian Stretch from command line?

Tue Nov 07, 2017 6:15 pm

Bosse_B wrote:
klricks wrote:
Tue Nov 07, 2017 5:53 pm
Find VNC in interface menu:

Code: Select all

sudo raspi-config
Thanks, raspi-config did the trick, but now I have a very small screen to work inside...
If I measure correctly it is only 655x380 pixels...
Can the screen size on VNC be adjusted?
It's likely that the VNC server (by default) is using a "physical" display size/resolution defined in config.txt or a "composite video" default due to there being no HDMI connection. What does tvservice -s report? It's possible to launch a VNC mode that does not "clone" the "connected" (or presumed connected) display settings, IIRC, that's one of the VNC options (but don't recall the full details, sorry**).
Trev.
** Edit: Some more info. here: https://www.realvnc.com/en/connect/docs ... y-pi-setup (Virtual Mode)
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, B2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B+, P3B, B+, A+ and a B2) but Buster on the P4B's. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

klricks
Posts: 6624
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: How to enable VNC on RPi3/Raspbian Stretch from command line?

Tue Nov 07, 2017 6:42 pm

Bosse_B wrote:
Tue Nov 07, 2017 6:07 pm
klricks wrote:
Tue Nov 07, 2017 5:53 pm
Find VNC in interface menu:

Code: Select all

sudo raspi-config
Thanks, raspi-config did the trick, but now I have a very small screen to work inside...
If I measure correctly it is only 655x380 pixels...
Can the screen size on VNC be adjusted?
Also use sudo raspi-config to set a forced screen resolution of your choice.
Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

Bosse_B
Posts: 836
Joined: Thu Jan 30, 2014 9:53 am

Re: How to enable VNC on RPi3/Raspbian Stretch from command line?

Tue Nov 07, 2017 6:50 pm

klricks wrote:
Tue Nov 07, 2017 6:42 pm
Also use sudo raspi-config to set a forced screen resolution of your choice.
Right, I googled for some advice and found this solution so I could set it to a comfortable size!
Only "problem" was that I had to reboot afterwards. So before that I had to adjust the persistent iptables rules I had changed after the last boot so that the faulty firewall would not hit back in again....
Now working though.
Thanks for your help!
Bo Berglund
Sweden

Bosse_B
Posts: 836
Joined: Thu Jan 30, 2014 9:53 am

Re: How to enable VNC on RPi3/Raspbian Stretch from command line?

Tue Nov 07, 2017 8:31 pm

Sorry to get back to this thread, but the reason I wanted to access the Pi desktop was that I read somewhere that Stretch includes a disk cloning utility that runs off the GUI screen. I think it is called PiClone, but now I cannot find this on any of he GUI menus and when I google Pi Clone I get to all kinds of unrelated old postings, not dealing with this new utility.

Can someone here please help me finding it?
Or should I open a new thread for this?
Bo Berglund
Sweden

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 5201
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.
Contact: Website

Re: How to enable VNC on RPi3/Raspbian Stretch from command line?

Tue Nov 07, 2017 8:37 pm

Bosse_B wrote: Sorry to get back to this thread, but the reason I wanted to access the Pi desktop was that I read somewhere that Stretch includes a disk cloning utility that runs off the GUI screen. I think it is called PiClone, but now I cannot find this on any of he GUI menus and when I google Pi Clone I get to all kinds of unrelated old postings, not dealing with this new utility.

Can someone here please help me finding it?
Or should I open a new thread for this?
The "GUI version" is (still) referred to as "SD Card Copier" in the menu system IIRC**.
Trev.
** I only have an old Jessie screenshot in my webpages: http://www.cpmspectrepi.uk/raspberry_pi ... Screenshot
and it might (now) be in a different menu area.
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, B2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B+, P3B, B+, A+ and a B2) but Buster on the P4B's. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

Bosse_B
Posts: 836
Joined: Thu Jan 30, 2014 9:53 am

Re: How to enable VNC on RPi3/Raspbian Stretch from command line?

Tue Nov 07, 2017 9:03 pm

Indeed it is!
And I found a blog outlining the usage too:
Latest updates to Raspbian
SD Card Copier is the 3rd item down from the top.
Bo Berglund
Sweden

ItayGal
Posts: 5
Joined: Mon Nov 07, 2016 8:48 am

Re: How to enable VNC on RPi3/Raspbian Stretch from command line?

Mon May 06, 2019 1:16 pm

The pure cli version would be:

Code: Select all

sudo ln /usr/lib/systemd/system/vncserver-x11-serviced.service /etc/systemd/system/multi-user.target.wants/vncserver-x11-serviced.service
sudo systemctl start vncserver-x11-serviced

c3pop
Posts: 1
Joined: Thu Jul 11, 2019 4:51 pm

Re: How to enable VNC on RPi3/Raspbian Stretch from command line?

Thu Jul 11, 2019 5:00 pm

I suppose the following code using a symbolic link, with 'ln -s', is easier to understand.

Code: Select all

sudo ln -s /usr/lib/systemd/system/vncserver-x11-serviced.service /etc/systemd/system/multi-user.target.wants/vncserver-x11-serviced.service
sudo systemctl start vncserver-x11-serviced

Bosse_B
Posts: 836
Joined: Thu Jan 30, 2014 9:53 am

Re: How to enable VNC on RPi3/Raspbian Stretch from command line?

Thu Jul 11, 2019 7:31 pm

I think this is a very old conversation.
I started it in Nov 2017 and since then RPi4 and Raspbian Buster are out....
Bo Berglund
Sweden

Return to “Raspbian”