Managing Users and Hostname on Ubuntu Server
创始人
2024-11-14 13:35:00
0

Tutorial: Managing Users and Hostname on Ubuntu

1. Change Hostname

To change the hostname of your system:

  1. Edit the hostname file:

    sudo nano /etc/hostname 

    Replace the existing name with your new hostname.

  2. Edit the hosts file:

    sudo nano /etc/hosts 

    Update the line that starts with 127.0.1.1 to reflect the new hostname.

  3. Apply the changes:

    sudo systemctl restart systemd-logind.service 
2. Rename a User

To rename a user:

  1. Rename the user:

    sudo usermod -l new_username old_username 
  2. Rename the home directory (if needed):

    sudo usermod -d /homes/new_username -m new_username 
3. Give Sudo Privileges to a User

To add a user to the sudo group:

sudo usermod -aG sudo username 
4. Add a New User

To add a new user with a home directory in /homes:

  1. Create the directory (if it doesn’t exist):

    sudo mkdir -p /homes 
  2. Add the user:

    sudo useradd -m -d /homes/new_user -s /bin/bash new_user 
  3. Set a password:

    sudo passwd new_user 
5. Set Permissions for Home Directories

Ensure home directories are secure:

  1. Set permissions:

    sudo chmod 700 /homes/new_user 
  2. Set ownership:

    sudo chown new_user:new_user /homes/new_user 

Summary

  • Change hostname by editing /etc/hostname and /etc/hosts.
  • Rename users with usermod.
  • Grant sudo access by adding the user to the sudo group.
  • Add new users with custom home directories in /homes.
  • Set appropriate permissions for security.

If you have any more questions or need further assistance, feel free to ask!

相关内容

热门资讯

黑科技攻略(WePoKe)微扑... 黑科技攻略(WePoKe)微扑克全自动机器人(软件透明挂)一直真的有挂(2021已更新)(哔哩哔哩)...
终于知道!!微扑克辅助软件(透... 终于知道!!微扑克辅助软件(透明黑科技)AA德州教程(2026已更新)(哔哩哔哩)1、不需要AI权限...
黑科技规律(微扑克wpk真的有... 黑科技规律(微扑克wpk真的有辅助吗)外挂透明挂辅助插件(透视)一直是真的有挂(有挂教学)-哔哩哔哩...
黑科技美元局(wpk德州专用辅... 黑科技美元局(wpk德州专用辅助器)外挂透明挂辅助软件(透视)原来真的有挂(有挂分享)-哔哩哔哩1、...
一分钟揭秘!!微扑克wpk辅助... 一分钟揭秘!!微扑克wpk辅助(辅助挂)攻略方法(2023已更新)(哔哩哔哩)是一款可以让一直输的玩...
辅助黑科技(WePoKe)we... 辅助黑科技(WePoKe)wepoke德扑之星(软件透明挂)切实真的是有挂(2024已更新)(哔哩哔...
黑科技真的(WePoKe)we... 黑科技真的(WePoKe)wepoke黑科技设备(透视)都是是真的有挂(2022已更新)(哔哩哔哩)...
最新研发!微扑克wpk有挂吗(... 最新研发!微扑克wpk有挂吗(透明黑科技)揭秘教程(2023已更新)(哔哩哔哩);是一款可以让一直输...
黑科技安装(德州ai软件使用)... 黑科技安装(德州ai软件使用)外挂透明挂辅助黑科技(透视)一直真的有挂(有挂实锤)-哔哩哔哩;一、德...
分享认知!wopoker真的有... 分享认知!wopoker真的有挂吗(ai代打)技巧教程(2022已更新)(哔哩哔哩)1、用户打开应用...