Ubuntu: 15 items found.

Delete lines with sed command

Sed Command to Delete Lines: Sed command can be used to delete or remove specific lines which matches a given pattern or in a particular position in a file. Here we will see how to delete lines using sed command with various examples.

More ~

ubuntu: Read-only file system

文件系统挂了,变成只读模式。supervisor无法启动,就连ping 域名时无法解析dns,想要修改/etc/resolve.conf,只读也写不进去。
试下往临时目录写也是这:

touch /tmp/aaa.txt
touch: cannot touch '/tmp/aaa.txt': Read-only file system
More ~

给树莓派的ubuntu20.04系统装mongodb 4.4

Debian64位系统暂时还没有mongodb4.4的deb,编译安装也没试成功。
Ubuntu20.04 64位可以用这些命令装上。

wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
 
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
 
sudo apt-get update
 
sudo apt-get install mongodb-org

装完可以启动mongod服务

systemctl start mongod
systemctl enable mongod

服务启动可能会异常,可以看下 systemctl status mongod

如报出/var/run ... 可以修改对应的服务声明 如 /lib/systemd/system/mongod.service
去掉/var

More ~

Ubuntu 防火墙 UFW 操作指北

Ubuntu上默认安装了一个防火墙服务 ufw, 全称为 Uncomplicated Firewall。默认是禁用的。

想用GUI可以看下Gufw。

基本用法

启用ufw: sudo ufw enable

To check the status of UFW:

查看 ufw状态: sudo ufw status verbose
也可以用 sudo ufw show raw 查看详情
也可以在 ** /etc/ufw**目录下查看 .rules的规则文件

More ~

禁用ubuntu ssh连接后的欢迎信息

本文的目的是在Ubuntu 20.04 Focal Fossa Linux上禁用动态motd和新闻。
20200723004336.png

  • 在本教程中,您将学习:
  • 如何修改登录新闻
  • 如何修改动态消息
  • 如何在系统范围内使motd动态消息屏蔽
  • 如何使每个用户的motd动态消息屏蔽
More ~

树莓派ubuntu20.04 国内源

用的阿里的:

deb https://mirrors.aliyun.com/ubuntu-ports/ focal main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu-ports/ focal main main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu-ports/ focal-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu-ports/ focal-updates main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu-ports/ focal-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu-ports/ focal-backports main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu-ports/ focal-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu-ports/ focal-security main restricted universe multiverse
# deb https://mirrors.aliyun.com/ubuntu-ports/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu-ports/ focal-proposed main restricted universe multiverse
More ~

pam_unix(sudo:auth): Couldn't open /etc/securetty: No such file or directory

问题来源于raspberry pi4 安装了打印服务,但是cups服务有点异常报,/etc/securetty找不到。
查了下应该是ubuntu 20.04的bug.

root@ubuntu:~# systemctl status cups
● cups.service - CUPS Scheduler
     Loaded: loaded (/lib/systemd/system/cups.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2020-07-01 00:58:26 CST; 12min ago
TriggeredBy: ● cups.path
             ● cups.socket
       Docs: man:cupsd(8)
   Main PID: 8324 (cupsd)
      Tasks: 2 (limit: 4434)
     CGroup: /system.slice/cups.service
             ├─8324 /usr/sbin/cupsd -l
             └─9318 /usr/lib/cups/notifier/dbus dbus://

Jul 01 01:08:15 ubuntu cupsd[8324]: pam_unix(cups:auth): Couldn't open /etc/securetty: No such file or directory
Jul 01 01:08:15 ubuntu cupsd[8324]: pam_unix(cups:auth): Couldn't open /etc/securetty: No such file or directory
Jul 01 01:08:22 ubuntu cupsd[8324]: pam_unix(cups:auth): Couldn't open /etc/securetty: No such file or directory
Jul 01 01:08:22 ubuntu cupsd[8324]: pam_unix(cups:auth): Couldn't open /etc/securetty: No such file or directory
Jul 01 01:08:27 ubuntu cupsd[8324]: pam_unix(cups:auth): Couldn't open /etc/securetty: No such file or directory
Jul 01 01:08:27 ubuntu cupsd[8324]: pam_unix(cups:auth): Couldn't open /etc/securetty: No such file or directory
Jul 01 01:08:29 ubuntu cupsd[8324]: pam_unix(cups:auth): Couldn't open /etc/securetty: No such file or directory
Jul 01 01:08:29 ubuntu cupsd[8324]: pam_unix(cups:auth): Couldn't open /etc/securetty: No such file or directory
Jul 01 01:08:39 ubuntu cupsd[8324]: pam_unix(cups:auth): Couldn't open /etc/securetty: No such file or directory
Jul 01 01:08:39 ubuntu cupsd[8324]: pam_unix(cups:auth): Couldn't open /etc/securetty: No such file or directory

解决的办法就是新建这个文件/etc/securetty,内容为

More ~

Ubuntu 用chrony同步时间

开始

这个软件包含两个命令集: chronyc 客户端 和 chronyd 守护进程. 安装chrony方法:

sudo apt install chrony

验证 chrony是否安装成功,并查看有多少个服务端及结点已连接:

$ chronyc activity
200 OK
8 sources online
0 sources offline
0 sources doing burst (return to online)
0 sources doing burst (return to offline)
0 sources with unknown address

配置 /etc/chrony/chrony.conf, 参考 https://chrony.tuxfamily.org/doc/3.5/chrony.conf.html

More ~