|
| 1 | +# Useful Unix Commands |
| 2 | + |
| 3 | +## Networking |
| 4 | + |
| 5 | +### SSH |
| 6 | + |
| 7 | +[SSH (Secure Shell)](https://www.mankier.com/1/ssh) is used to securely connect from a local to a remote system (ex. from a laptop to a coprocessor). Unlike other commands on this page, ssh is not Unix specific and can be done on Windows and MacOS from their respective terminals. |
| 8 | + |
| 9 | +:::{note} |
| 10 | +You may see a warning similar to `The authenticity of host 'xxx' can't be established...` or `WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!`, in most cases this can be safely ignored if you have confirmed that you are connecting to the correct host over a secure connection, and the fingerprint will change when your operating system is reinstalled or PhotonVision's coprocessor image is re-flashed. This can also occur if you have multiple coprocessors with the same hostname on your network. You can read more about it [here](https://superuser.com/questions/421997/what-is-a-ssh-key-fingerprint-and-how-is-it-generated) |
| 11 | +::: |
| 12 | + |
| 13 | +Example: |
| 14 | + |
| 15 | +``` |
| 16 | +ssh pi@hostname |
| 17 | +``` |
| 18 | + |
| 19 | +For PhotonVision, the username will be `pi` and the password will be `raspberry`. |
| 20 | + |
| 21 | +### ip |
| 22 | + |
| 23 | +Run [ip address](https://www.mankier.com/8/ip) with your coprocessor connected to a monitor in order to see its IP address and other network configuration information. |
| 24 | + |
| 25 | +Your output might look something like this: |
| 26 | + |
| 27 | +``` |
| 28 | +2: end1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 |
| 29 | + link/ether de:9a:8f:7d:31:aa brd ff:ff:ff:ff:ff:ff |
| 30 | + inet 10.88.47.12/24 brd 10.88.47.255 scope global dynamic noprefixroute end1 |
| 31 | + valid_lft 27367sec preferred_lft 27367sec |
| 32 | +``` |
| 33 | + |
| 34 | +In this example, the numbers following `inet` (10.88.47.12) are your IP address. |
| 35 | + |
| 36 | +### ping |
| 37 | + |
| 38 | +[ping](https://www.mankier.com/8/ping) is a command-line utility used to test the reachability of a host on an IP network. It also measures the round-trip time for messages sent from the originating host to a destination computer. It can be used to determine if a network interface is available, which can be helpful when debugging. |
| 39 | + |
| 40 | +## File Transfer |
| 41 | + |
| 42 | +All files under `/opt/photonvision` are owned by the root user. This means that if you want to modify them, the commands to do so must be ran as sudo. |
| 43 | + |
| 44 | +### SCP |
| 45 | + |
| 46 | +[SCP (Secure Copy)](https://www.mankier.com/1/scp) is used to securely transfer files between local and remote systems. |
| 47 | + |
| 48 | +Example: |
| 49 | + |
| 50 | +``` |
| 51 | +scp [file] pi@hostname:/path/to/destination |
| 52 | +``` |
| 53 | + |
| 54 | +### SFTP |
| 55 | + |
| 56 | +[SFTP (SSH File Transfer Protocol)](https://www.mankier.com/1/sftp#) is another option for transferring files between local and remote systems. |
| 57 | + |
| 58 | +### Filezilla |
| 59 | + |
| 60 | +[Filezilla](https://filezilla-project.org/) is a GUI alternative to SCP and SFTP. It is available for Windows, MacOS, and Linux. |
| 61 | + |
| 62 | +## Miscellaneous |
| 63 | + |
| 64 | +### v4l2-ctl |
| 65 | + |
| 66 | +[v4l2-ctl](https://www.mankier.com/1/v4l2-ctl) is a command-line tool for controlling video devices. |
| 67 | + |
| 68 | +List available video devices (used to verify the device recognized a connected camera): |
| 69 | + |
| 70 | +``` |
| 71 | +v4l2-ctl --list-devices |
| 72 | +``` |
| 73 | + |
| 74 | +List supported formats and resolutions for a specific video device: |
| 75 | + |
| 76 | +``` |
| 77 | +v4l2-ctl --list-formats-ext --device /path/to/video_device |
| 78 | +``` |
| 79 | + |
| 80 | +List all video device's controls and their values: |
| 81 | + |
| 82 | +``` |
| 83 | +v4l2-ctl --list-ctrls --device path/to/video_device |
| 84 | +``` |
| 85 | + |
| 86 | +:::{note} |
| 87 | +This command is especially useful in helping to debug when certain camera controls, like exposure, aren't behaving as expected. If you see an error in the logs similar to `WARNING 30: failed to set property [property name] (UsbCameraImpl.cpp:646)`, that means that PhotonVision is trying to use a control that doesn't exist or has a different name on your hardware. If you encounter this issue, please [file an issue](https://github.com/PhotonVision/photonvision/issues) with the necessary logs and output of the `v4l2-ctl --list-ctrls` command. |
| 88 | +::: |
| 89 | + |
| 90 | +### systemctl |
| 91 | + |
| 92 | +[systemctl](https://www.mankier.com/1/systemctl) is a command that controls the `systemd` system and service manager. |
| 93 | + |
| 94 | +Start PhotonVision: |
| 95 | + |
| 96 | +``` |
| 97 | +systemctl start photonvision |
| 98 | +``` |
| 99 | + |
| 100 | +Stop PhotonVision: |
| 101 | + |
| 102 | +``` |
| 103 | +systemctl stop photonvision |
| 104 | +``` |
| 105 | + |
| 106 | +Restart PhotonVision: |
| 107 | + |
| 108 | +``` |
| 109 | +systemctl restart photonvision |
| 110 | +``` |
| 111 | + |
| 112 | +Check the status of PhotonVision: |
| 113 | + |
| 114 | +``` |
| 115 | +systemctl status photonvision |
| 116 | +``` |
| 117 | + |
| 118 | +### journalctl |
| 119 | + |
| 120 | +[journalctl](https://www.mankier.com/1/journalctl) is a command that queries the systemd journal, which is a logging system used by many Linux distributions. |
| 121 | + |
| 122 | +View the PhotonVision logs: |
| 123 | + |
| 124 | +``` |
| 125 | +journalctl -u photonvision |
| 126 | +``` |
| 127 | + |
| 128 | +View the PhotonVision logs in real-time: |
| 129 | + |
| 130 | +``` |
| 131 | +journalctl -u photonvision -f |
| 132 | +``` |
0 commit comments