我刚才在做一些例行检查并意识到这一点:
Raspberry Pi OS(以前称为 Raspbian)
来源:树莓派操作系统
我在他们的博客和维基百科页面上都没有发现提到这一点。为什么要把“Raspbian”这样的好名字改成繁琐且有问题的“Raspberry Pi OS”?现在我必须重命名一堆已建立的代码和东西......
使用 Raspbian 和 Ubunntu 16.04 LTS 所以需要一个通用的 Linux 解决方案。
要求很简单:
我需要一种从命令行发送单行电子邮件的方法。
我已经为这个特定的 Rpi3 设置了一个 gmail 帐户,地址为 rpi3abc@gmail.com - 没有 2FA
所以现在我需要能够在没有用户干预的情况下从任何地方(包括 cron)发送单行邮件消息。
我也希望它能够发送文本文件;基本上,任何来自stdin.
我想知道网络上所有设备的名称。我已经尝试过很多在网上找到的命令,但没有取得很大成功,但没有像我想要的那样工作。
基本上,当我输入我的路由器设置时,我可以获得连接到我的网络的设备的名称。我也可以在某些应用程序上获得它,所以我想它可以通过某种方式完成。
我想要通过命令行连接到我的 Wi-Fi 网络的所有设备的名称列表。
谢谢
pi@raspberrypi ~ $ nmap -sP 192.168.4.0/24
Starting Nmap 6.00 ( http://nmap.org ) at 2015-03-05 13:55 UTC
Nmap scan report for 192.168.4.1
Host is up (0.0055s latency).
Nmap scan report for 192.168.4.2
Host is up (0.42s latency).
Nmap scan report for 192.168.4.4
Host is up (0.045s latency).
Nmap scan report for 192.168.4.5
Host is up (0.47s latency).
Nmap scan report for 192.168.4.6
Host is up (0.0032s latency).
Nmap scan report for 192.168.4.7
Host is up …Run Code Online (Sandbox Code Playgroud) 似乎我的 Raspberry Pi 服务器在随机时间后失去了 wifi 连接,并且不知何故无法自动恢复。
通常手动重新启动可以解决问题。
如果大约 30 分钟后没有 wifi,我想让它自动重启。我怎样才能做到这一点?
我在 RaspberryPi 上运行 Raspian。
当我插入 GSM 调制解调器时,我看到两个接口 - wwan0和ppp0。
wwan0 即使插入 GSM 调制解调器但未连接,也存在ppp0 仅当连接 GSM 调制解调器时存在wwan0和ppp0,以及为什么我看ppp0除了wwan0?ppp0而不是wwan0在建立连接后?在当前版本的 Raspian 中,我知道可以从命令行更改当前登录用户的密码,如下所示:
sudo passwd
Run Code Online (Sandbox Code Playgroud)
然后会提示用户输入新密码两次。这将产生如下输出:
Changing password for pi.
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Run Code Online (Sandbox Code Playgroud)
我想知道是否有可能以编程方式更改密码,例如从 shell 脚本更改密码。
我正在尝试制作一个配置脚本以部署在我的 Raspberry Pi 上,我不想手动为它们输入新密码。
我试图通过编辑在启动时自动挂载网络驱动器,/etc/fstab但不起作用。
如果我执行这条线,
sudo mount.cifs //192.168.0.67/test /home/pi/test -o username=myname,password=123
Run Code Online (Sandbox Code Playgroud)
它很好用。但我不知道如何在/etc/fstab.
I changed the init system from sysvinit to systemd on a raspbian installation. The install boots fine, but now starts lightdm on boot. I don't want it to do that.
I noticed lightdm.service is started on boot. Stopping the service with
systemctl stop lightdm.service
works fine.
systemctl disable lightdm.service should disable it, but gives me
Failed to issue method call: No such file or directory
systemctl status lightdm.service gives me
lightdm.service - LSB: Light Display Manager
Loaded: loaded (/etc/init.d/lightdm)
Active: …Run Code Online (Sandbox Code Playgroud) 我很好奇这些程序之间的区别是什么;通过 systemctl 启用时使用 systemd 启动,而/etc/rc.local通过 CLI 或通过 CLI启动的启动。
例如,我最近在树莓派上使用 shairport-sync。最初,我通过启用 sudo systemctl 的 shairport-sync 将 shairport-sync 设置为启动。
后来我使用其中的一个功能在shairport-sync连接设备之前运行脚本并发布。
令我惊讶的是,执行时的脚本shairport-sync没有kill arecord或aplay
然而,当我将通过终端执行,杀死了脚本运行脚本arecord和aplay。
为了进一步混淆自己,我shairport-sync通过终端杀死并启动它以查看正在发生的事情的输出。当我这样做时,当设备连接并杀死arecord和aplay. 所以,作为一个修复我禁用shairport-sync的sysmtectl,并设置它在运行/etc/rc.local作为一个快速修复。之后reboot它按我的预期运行。
这让我相信作为一部分运行systemd的程序与通过/etc/rc.local或 CLI启动时运行的程序之间存在一些差异。
为什么会发生这种情况?这是因为运行级别不同吗?什么黑魔法?
设备连接时运行的脚本shairport-sync如下:shairportstart.sh
#!/bin/sh
/usr/bin/sudo /bin/pkill arecord
if [ $(date +%H) -ge "18" -o $(date +%H) -le "7" ]; then
/usr/bin/amixer set …Run Code Online (Sandbox Code Playgroud) 以用户身份运行任何 systemd 命令时出现此错误:
admin@Xroklaus:~ $ systemctl --user list-units
Failed to get D-Bus connection: Connection refused
Run Code Online (Sandbox Code Playgroud)
如果没有用户参数,该命令运行良好。
admin@Xroklaus:~ $ systemctl list-units
UNIT LOAD ACTIVE SUB DESCRIPTION
proc-sys-fs-binfmt_misc.automount loaded active waiting Arbitrary Executable File Formats File System Automount Point
sys-devices-platform-soc-3f201000.serial-tty-ttyAMA0-hci0-rfkill1.device loaded active plugged /sys/devices/platform/soc/3f201000.serial/tty/ttyAMA0/hci0/rfkil
sys-devices-platform-soc-3f201000.serial-tty-ttyAMA0-hci0.device loaded active plugged /sys/devices/platform/soc/3f201000.serial/tty/ttyAMA0/hci0
...
To show all installed unit files use 'systemctl list-unit-files'.
lines 102-129/129 (END)
Run Code Online (Sandbox Code Playgroud)
并且 Dbus 正在运行。
admin@Xroklaus:~ $ ps -ef | grep dbus
message+ 443 1 0 Jan06 ? 00:00:00 /usr/bin/dbus-daemon --system --address=systemd: …Run Code Online (Sandbox Code Playgroud)