Linux 查询及编辑用户及用户组
查询当前所有用户
compgen -u
查询当前所有用户组
compgen -g
添加一个用户到某个组
sudo usermod -a -G groupName userName
newgrp groupName
删除一个用户从某个组
sudo usermod -G groupName userName
newgrp groupName
用户和组对文件的权限管理参考:chown 和 chmod 管理文件权限
compgen -u
compgen -g
sudo usermod -a -G groupName userName
newgrp groupName
sudo usermod -G groupName userName
newgrp groupName
用户和组对文件的权限管理参考:chown 和 chmod 管理文件权限
安装好 openwrt 后默认有一个 root 用户,需要添加新用户也很简单,只需要在 /etc/passwd 文件最后按照格式增加一个用户即可,然后可以修改这个新用户的密码。
下面使用一条命令快速添加新用户:
grep -qw new_user /etc/passwd || echo "new_user:x:0:23333:::" >> /etc/passwd
命令先检查是否在文件中存在需要添加的用户名,如果不存在则在文件最后一行添加用户。
其中 new_user 是用户名,0 是 uid,23333 是 gid。
如果需要修改这个新用户的密码,执行命令即可:
passwd new_user
以上就是创建新用户简单方法。
执行下面命令即可获取本地网关所有的 ip 段地址:
$ ip address | grep -w inet | awk '{print $2}'
127.0.0.1/8
192.168.122.2/24
172.18.0.1/16
172.17.0.1/16
172.19.0.1/16 目前有很多的云备份服务可以使用,比如 icloud,google photos 等。immich 是一款实现类似功能的本地部署工具,将数据都存储在自己本地服务器上,拥有完善的手机端 app 可以方便的同步备份手机图片。
GitHub 主页:https://github.com/immich-app/immich
官网教程:https://immich.app/docs/overview/introduction/
我服务器目前安装的是 Ubuntu 20.04 系统,很多新的软件包并没有在官方维护的源中提供,所以为了方便需要可以添加第三方的源。
添加需要用到的命令是:add-apt-repository,但是默认系统并没有安装这个环境,需要先手动安装 package software-properties-common:
sudo apt install software-properties-common
然后就可以安装需要的源了,推荐两个:
https://launchpad.net/%7Esavoury1/+archive/ubuntu/backports?field.series_filter=bionic
https://launchpad.net/%7Esavoury1/+archive/ubuntu/utilities?field.series_filter=bionic
安装方法很简单:
sudo add-apt-repository ppa:savoury1/backports
sudo add-apt-repository ppa:savoury1/utilities
sudo apt-get update执行 apt update 后会发现很多可更新的软件了。