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

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!
主站蜘蛛池模板: 昌平区| 常宁市| 台山市| 潮州市| 鄄城县| 霍城县| 锡林浩特市| 綦江县| 仙居县| 金川县| 东乡族自治县| 双鸭山市| 丹巴县| 宜兰市| 安乡县| 北海市| 平安县| 景宁| 托克托县| 宝清县| 台安县| 台安县| 泸西县| 古交市| 洛阳市| 罗田县| 勃利县| 通化县| 北宁市| 甘洛县| 新宁县| 乌拉特后旗| 达日县| 绥江县| 禄丰县| 聂拉木县| 兴隆县| 增城市| 肥西县| 江油市| 通河县|