

更换Linux UID的脚本
source link: https://www.lujun9972.win/blog/2019/08/08/%E6%9B%B4%E6%8D%A2linux-uid%E7%9A%84%E8%84%9A%E6%9C%AC/index.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

更换Linux UID的脚本
Linux 上更改 UID 的操作步骤有点麻烦,有时会忘了重新设置用户文件的属主,所以写个脚本来简化负担。
更改文件属主需要 root 权限
if [[ "$(id -u)" -ne "0" ]];then echo "This script should be execute by root" >&2 exit 1 fi
脚本接受两个参数,一个是用户名,一个是新的UID
user="$1" newUid="$2"
记录下用户对应的旧UDI
oldUid="$(id -u "${user}")"
更改用户UID
usermod -u "${newUid}" "${user}"
重新设置用户文件的属主
find / -user "${oldUid}" -exec chown -h "${user}" {} \;
这里一定要记得使用
chown
的-h
选项把符号链接的属主改掉,否则改的是符号链接所指向的文件属主。
Recommend
-
24
UID Generator为什么要使用由于 Event Soucing 是记录事件的,那么 Object Id 肯定就不能是用数据库生成的了,基本上所有的 Event Soucing 相关...
-
14
Android 安全机制来源于Linux,并且以Linux权限管理为基础,要了解Android的安全机制,需要从linux中的安全机制了解开始,而用户的权限管理又是linux安全机制的最基本的一个组成 2、linux中的用户(UID)、组(GID)、进程(PID) ...
-
41
Unable to use sudo on OSX, get sudo: unknown uid 501: who are you? advertisements When I type sudo <command> in terminal I...
-
7
修改 GPG UID 名称 February 25, 2021 • 开发 之前 GPG UID 名称都是用的 Scvoet,也就是我的用户名。前段时间将各个平台的昵称都改成了我的英文名 Percy,今天...
-
5
Introducing Unique Identity (UID), the First NFT for Identity.View the whole animation on OpenSea: https://opensea.io/assets/0xba0439088dc1e75f5...
-
8
Linux namespace in Go - Part 2, UID and MountIn the previous article, I did two experiments on what isolation it brings with PID and UTS, this articl...
-
4
Linux 软件源一键更换脚本 Moexin 2020-06-10 in
-
8
usermod Linux usermod 命令修改用户UID UID是User Identifier的缩写,UID是Linux系统分配给每个用户的唯一标识号 ...
-
6
如何使用 IdGen 生成 UID 2022-12-10 2022-12-11 5在分布式系统中,雪花 ID 是一种常用的唯一 ID 生成算法。它通过结合时间戳、机器码和自增序列来生成 64 位整数 ID,可以保证 I...
-
8
如何使用 IdGen 生成 UID 在分布式系统中,雪花 ID...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK