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

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!
主站蜘蛛池模板: 汉川市| 明星| 康平县| 临沧市| 景宁| 鹿泉市| 沁水县| 大港区| 达日县| 民勤县| 清水县| 宜黄县| 木兰县| 三门县| 彰武县| 开封市| 兴隆县| 衡水市| 雅安市| 白城市| 灌南县| 财经| 浦北县| 容城县| 景泰县| 四会市| 长宁区| 鸡泽县| 江达县| 湖口县| 师宗县| 通海县| 叶城县| 衡东县| 西乌| 竹溪县| 壤塘县| 鞍山市| 晋江市| 南岸区| 简阳市|