linux下怎么新建一个用户,并使这个用户只能对某一个限定的文件夹内的文件进行修改等所有权限

哎呀,我得谈谈这个问题。
你提到的设置主目录的-d/home/var命令实际上是在Linux系统上创建用户时使用的。
For example, if you use the useradd command to create a new user, the -d option of this command can specify the user's home directory.这个主目录是存储用户个人数据的地方,所有权当然属于用户。
然后-p后面可以设置用户的密码,-m选项在创建用户时创建主目录。

但是,您在问题中提到的内容似乎与此命令无关。
您提到的“userad --help”可能是一个拼写错误。
正确的是“useradd --help”。
该命令用于查看useradd命令的帮助信息,其中包含该命令的各种选项和使用方法。

Let's talk about controlling file permissions. File permission control under Linux is defined by three eight-bit variables, such as xxxyyyzzz. Permission settings here, rwx read, write and execute. The first three digits are permissions granted to the owner of the file, the middle three digits are permissions granted to the group, and the last three digits are permissions granted to other users.
If you want the user of a file to have full control permissions, there are two methods.或者将文件组设置为与用户同组,使用户拥有组用户权限。
或者直接将文件的所有者设置为该用户,使该用户拥有所有者权限。

Of course, if these two methods are not enough, then you may have to consider using ACL (Access Control Lists). This can determine exactly what permissions each user has, which is pretty accurate. But to be honest, the more you use it, the more of a pain it will be to set up.
As for directory execution permission, it refers to whether the user can access the directory. Without execute permission, the user cannot access this directory, just as they cannot access a locked room.希望这能解释得更清楚。

linux useradd命令详解

useradd 是用于创建用户的 Linux 命令。
说白了,就是新建一个账户。

上周我刚刚处理了一个需要添加管理员的系统。
直接使用:useradd -m -g admin sam
/etc/passwd 保存账户信息。
具体参数我记不清了,不过大概是这样的:
-D 改变默认设置。
-c 添加注释。
-d 设置主目录。
-e 设置过期时间。

-m 表示主目录尚未准备好创建。
-M 不创建主目录。
-g 指定主要组。

-G 添加多个组。
使用 -R 创建系统帐户。
-u 设置 UID。

首先,具体细节你可以自己看。

如何免密码登录另一台linux设备、提权到root,以及允许本机root可登陆

无需密码登录另一台Linux设备: 1 . 生成SSH密钥对:在主机上执行ssh-keygen -t rsa命令,生成本地密钥和公钥。
2 、复制公钥到目标机器:执行ssh-copy-id -p$(ssh端口号,如果是2 2 ,可以默认)${用户名}@${目标机器IP}命令将公钥复制到目标机器。

无需密码即可将权限提升至root: 1 . 编辑 sudoers 文件:使用 sudo visudo 命令编辑 /etc/sudoers 文件,添加 sshuser ALL=(ALL) NOPASSWD:ALL 行,允许 sshuser 用户无需密码即可执行 sudo 命令。
2 、解决主机名解析问题:如果遇到sudo:无法解析主机错误,则需要在/etc/hosts文件中添加主机名与IP地址的映射关系。

允许外部用户以 root 用户身份通过 SSH 登录此 Linux 设备: 1 、修改SSH配置:在root用户下打开/etc/ssh/sshd_config文件,将PermitRootLogin参数由no修改为yes。
2 . 设置root的SSH密钥:在root的主目录中生成本地密钥和公钥,并将公钥添加到authorized_keys文件中。
3 、重启SSH服务:执行service sshd restart命令重启SSH服务。

以上免密码方式会降低系统安全性,仅建议在非重要环境或有安全防火墙保护的环境下使用。