大网数据广告活动
服务器运维问答

Add a Home directory for already created user when no direct root login available

· 52CE 我爱测

I have a user account provided by client with unrestricted sudo access, but this user has no home directory. I want to create one, but I'm not sure how to go about it. I tried logging in as my normal user and sudo su ing into roo…

问题原文

原帖链接 · kuldeep.kamboj · CC BY-SA 3.0

I have a user account provided by client with unrestricted sudo access, but this user has no home directory. I want to create one, but I'm not sure how to go about it.

I tried logging in as my normal user and sudo suing into root, then running

 usermod -d /home/user  -m user

But it gaves the message usermod: no changes. I assume because my user is already logged in?

Other solutions seem to involve removing and re-creating my user account with a home directory, but again as user would be already logged in I think there may be problems with that approach.

Is there a way to create my user's home directory with the access I have, or do I need to inform my client/provider to recreate my account?

已采纳解答

原帖链接 · Peter · CC BY-SA 3.0

Just create a home directory for them and grant them permissions.
mkdir /home/$user and then chown $user:$user /home/$user.

Take note to replace the group in the chown command with something else if required.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2014-02-18)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。