官术网_书友最值得收藏!

Sharing a screen on your desktop computer

While it is inevitable that you will use the command line a lot when using Linux, a lot of people enjoy Raspbian's GUI. But you still want to keep your Zero in the attic! No problem at all: the Virtual Network Computing (VNC) service makes the GUI available from anywhere you able to connect.

Getting ready

Stay connected to your Raspberry Pi Zero with your SSH terminal. On your home computer, you will need a VNC viewer application. I love the VNC Viewer Chrome extension, and it is available on any platform.

How to do it...

  1. First, you need to install a VNC server on your Raspberry Pi Zero. To install it on Raspbian, type the following:
            sudo apt-get install tightvncserver
    
  2. Once it's installed, starting it is as simple as typing vncserver:
            $ vncserver
            New 'X' desktop is rpz14101:1
            Starting applications specified in /home/pi/.vnc/xstartup
            Log file is /home/pi/.vnc/rpz14101:1.log 
    
  3. The first time you start a server, it will prompt you for a password. This is the password that you will use to connect using the VNC viewer. The VNC session you create will be for the user that started it, so if you initialized it from the pi user as in the previous example, VNC connections in it will also be for the pi user, if you are logged on as root, VNC will connect as root, and so on.
  4. Now your Zero is available on the network over VNC. Any kind of device that can run a VNC viewer application will be able to use X Windows on the Pi. The VNC server returns the device name and a port instead of the IP address. To connect, we will use this format:
            <IP Address>:<Desktop number>
    

    Here's an example:

            192.168.2.119:1
    

    We'll use the same address we found with ifconfig and used to ping and SSH to our Raspberry Pi Zero.

  5. Once you are connected, it works just like being directly connected to the Zero over HDMI. This way, you can use the Raspberry Pi Zero no matter where you or the Zero are located. If you need the command line, SSH is the ideal tool, but if you are using GUI tools such as Scratch, need to look something up with a browser, or write a song with Sonic Pi, the VNC connection will be the choice for you.
    Note

    Because of the Raspberry Pi Zero's size, some sacrifices had to be made. It uses an older CPU, which is quite a bit slower overall than the Raspberry Pi 2 or 3. If you are planning to use the GUI a lot, you might want to use one of the larger, faster models. The Raspberry Pi Zero is perfectly capable, but it won't be nearly as much fun playing Minecraft Pi over VNC as it would be on a Raspberry Pi 3.

  6. Logging on using a VNC viewer is as simple as providing the IP address and desktop number:
  7. You'll be prompted for the password you created when you set up the VNC server, and then you are ready to go!
主站蜘蛛池模板: 昔阳县| 揭阳市| 瑞昌市| 广河县| 丰镇市| 饶阳县| 建湖县| 昌图县| 龙江县| 麻栗坡县| 武平县| 镇远县| 盱眙县| 武夷山市| 三亚市| 陕西省| 伊宁市| 铅山县| 东莞市| 云阳县| 民乐县| 阿拉善右旗| 山阳县| 延寿县| 汕头市| 临江市| 高淳县| 黑山县| 巍山| 南投市| 静乐县| 延庆县| 从江县| 通河县| 阿鲁科尔沁旗| 汽车| 墨脱县| 苍梧县| 唐河县| 盘锦市| 建始县|