Last active
March 10, 2024 20:00
-
-
Save rpavlik/ce24433e0604ef52f334c0de25936535 to your computer and use it in GitHub Desktop.
Linux name change
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from https://askubuntu.com/a/1363020 | |
wsl -l -v | |
wsl --terminate Debian # <distro> from the previous command | |
wsl -u root -d Debian # "-d <distro>" is only needed for non-default instances | |
# Now from in WSL | |
usermod -l rylie ryan | |
# Optionally change the home directory name to match | |
usermod -d /home/rylie -m rylie | |
# Optionally change the group name to match | |
groupmod -n rylie ryan |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# see https://www.golinuxcloud.com/how-to-change-username-on-linux/#Method-2_Change_username_on_Linux_without_usermod_command | |
# as root | |
# rename user and group | |
sed -i 's/^ryan/rylie/' /etc/passwd | |
sed -i 's/^ryan/rylie/' /etc/shadow | |
sed -i 's/ryan/rylie/' /etc/groups | |
# Move home dir | |
mv /home/ryan /home/rylie | |
# compatibility symlink | |
ln -s /home/rylie /home/ryan | |
# Update home dir in user database | |
sed -i 's:/home/ryan:/home/rylie:' /etc/passwd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wsl --shutdown | |
# Fix default user for wsl | |
# https://learn.microsoft.com/en-us/windows/wsl/basic-commands#change-the-default-user-for-a-distribution | |
debian config --default-user rylie |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment