自定义Linux Mint安装ISO:将创建的用户添加至指定用户组
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-rootEdit the
adduser.conffile:
Open/etc/adduser.conf(inside the extractedsquashfs-rootdirectory) in your favorite text editor. Look for these lines:EXTRA_GROUPS="dialout cdrom floppy audio video plugdev users" ADD_EXTRA_GROUPS=1Update
EXTRA_GROUPSto includettyandlp:EXTRA_GROUPS="dialout cdrom floppy audio video plugdev users tty lp" ADD_EXTRA_GROUPS=1Save 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-groupsPaste 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 fiMake 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 xzReplace 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.txtUnmount 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

