You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

自定义Linux Mint安装ISO:将创建的用户添加至指定用户组

Automatically Add New User to tty and lp Groups During Linux Mint 18.3 Xfce Installation (JLIVECD)

Great question—yes, you absolutely can automate this. There are two reliable ways to make sure the user created during installation gets added to the tty and lp groups automatically after reboot, using JLIVECD to customize your Mint 18.3 Xfce image. Let’s break down both methods:

Method 1: Modify adduser.conf (Simplest Approach)

Linux Mint uses the adduser utility to create user accounts during installation, and it follows rules set in /etc/adduser.conf. We can update this config to include your desired groups by default:

  • Mount your JLIVECD ISO and extract the filesystem squashfs:

    sudo mkdir -p /mnt/jlivecd
    sudo mount -o loop linuxmint-18.3-xfce-64bit.iso /mnt/jlivecd
    unsquashfs /mnt/jlivecd/casper/filesystem.squashfs
    cd squashfs-root
    
  • Edit the adduser.conf file:
    Open /etc/adduser.conf (inside the extracted squashfs-root directory) in your favorite text editor. Look for these lines:

    EXTRA_GROUPS="dialout cdrom floppy audio video plugdev users"
    ADD_EXTRA_GROUPS=1
    

    Update EXTRA_GROUPS to include tty and lp:

    EXTRA_GROUPS="dialout cdrom floppy audio video plugdev users tty lp"
    ADD_EXTRA_GROUPS=1
    

    Save the file and close it.

Method 2: Add a Post-Install Script (More Flexible)

If you need more control (e.g., only add groups under specific conditions), you can create a custom post-install script that runs after the installer finishes setting up the system:

  • Follow the first step from Method 1 to mount the ISO and extract the filesystem.

  • Create a post-install script:
    Navigate to the ubiquity post-install directory and create a new script:

    cd squashfs-root/usr/lib/ubiquity/post-install.d/
    sudo nano 99-add-user-to-groups
    

    Paste this content into the script:

    #!/bin/sh
    # Automatically add the newly created user to tty and lp groups
    
    # Fetch the first non-system user (created during installation)
    NEW_USER=$(getent passwd | awk -F: '$3 >= 1000 && $3 != 65534 {print $1; exit}')
    
    if [ -n "$NEW_USER" ]; then
        usermod -aG tty,lp "$NEW_USER"
        echo "Successfully added $NEW_USER to tty and lp groups" >> /var/log/ubiquity/post-install.log
    fi
    
  • Make the script executable:

    sudo chmod +x 99-add-user-to-groups
    

Finalize Your Custom ISO

Once you’ve made either change, repackage the filesystem and update the ISO:

  • Recreate the squashfs filesystem:

    cd ../..  # Back to the directory containing squashfs-root
    sudo mksquashfs squashfs-root filesystem.squashfs -comp xz
    
  • Replace the original squashfs in the mounted ISO:

    sudo mv filesystem.squashfs /mnt/jlivecd/casper/
    
  • Update the MD5 checksum file:

    cd /mnt/jlivecd
    sudo md5sum $(find . -type f ! -name "md5sum.txt") > md5sum.txt
    
  • Unmount the ISO and clean up:

    sudo umount /mnt/jlivecd
    sudo rm -rf squashfs-root
    

Now, when you boot your custom JLIVECD ISO and run the installation, the user you create will automatically be part of the tty and lp groups once you reboot into the installed system.

内容的提问来源于stack exchange,提问作者sftpck

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 09:46:48