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

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!
主站蜘蛛池模板: 五家渠市| 水富县| 南郑县| 东阳市| 交口县| 青州市| 阜康市| 中山市| 山西省| 富川| 平潭县| 新昌县| 耿马| 会东县| 临洮县| 呈贡县| 都昌县| 马鞍山市| 崇左市| 黄梅县| 石嘴山市| 金湖县| 宜春市| 深泽县| 象山县| 华蓥市| 固安县| 德兴市| 临桂县| 永胜县| 钟山县| 襄樊市| 德兴市| 玛多县| 泾源县| 清丰县| 丽水市| 措美县| 阿拉尔市| 东丽区| 永年县|