Add my own user as an admin (i.e. being in the same groups as the current user).
$ sudo adduser inkarkat $ sudo usermod --append --groups "$(sed -e "/.$USER/"'!d' -e 's/^\([^:]\+\):.*$/\1/' /etc/group | sed -n -e H -e '${ g; s/^\n//; s/\n/,/g; p }')" inkarkat $ su - inkarkat
Rename an existing user to my own username. For example, an AWK EC2 Ubuntu instance has the ubuntu default username.
When you can directly login as superuser (or another user and then switch user), this is as simple as this:
$ usermod -l inkarkat -d /home/inkarkat -m OLD_USER_NAME && groupmod -n inkarkat OLD_GROUP
On an AWS EC2 Ubuntu instance, the passwordless sudo is achieved via a special configuration that has the username hard-coded; this needs to be adapted as well if the user doesn't have a password:
$ sed -i.orig -e 's/OLD_USER_NAME/inkarkat/g' /etc/sudoers.d/90-cloud-init-users
When login is only possible through the original user, this will fail, as even with exec sudo -s, the SSH login process is still owned by the original user.
usermod: user OLD_USER_NAME is currently used by process 745 # ps -eaf | grep OLD_USER_NAME OLD_USER_NAME 745 1 0 12:39 ? 00:00:00 /lib/systemd/systemd --user OLD_USER_NAME 746 745 0 12:39 ? 00:00:00 (sd-pam) root 28832 612 0 13:14 ? 00:00:00 sshd: OLD_USER_NAME [priv] OLD_USER_NAME 28915 28832 0 13:14 ? 00:00:00 sshd: OLD_USER_NAME@pts/0 OLD_USER_NAME 28916 28915 0 13:14 pts/0 00:00:00 -bash
We need to create a temporary local user, give that sudo rights and enable SSH login with my key, and login as them to do the renaming:
$ sudo adduser temp && sudo adduser temp sudo Adding user `temp' ... Adding new group `temp' (1001) ... Adding new user `temp' (1001) with group `temp' ... Creating home directory `/home/temp' ... Copying files from `/etc/skel' ... New password: Retype new password: passwd: password updated successfully Changing the user information for temp Enter the new value, or press ENTER for the default Full Name []: Room Number []: Work Phone []: Home Phone []: Other []: Is the information correct? [Y/n] Adding user `temp' to group `sudo' ... Adding user temp to group sudo Done. $ sudo install -d -o temp -m 700 ~temp/.ssh && sudo install -D -o temp -m 600 -t ~temp/.ssh/ ~/.ssh/authorized_keys $ exit
$ export OLD_USER_NAME=ubuntu; export OLD_GROUP=$OLD_USER_NAME $ sudo usermod -l inkarkat -d /home/inkarkat -m $OLD_USER_NAME && sudo groupmod -n inkarkat $OLD_GROUP $ sudo sed -i.orig -e "s/$OLD_USER_NAME/inkarkat/g" /etc/sudoers.d/90-cloud-init-users $ exit
$ sudo rm -r ~temp && sudo deluser temp Removing user `temp' ... Warning: group `temp' has no more members. Done.
Source: Ask Ubuntu - How do I change my username?
$ sudo add-apt-repository ppa:nextcloud-devs/client $ sudo apt update && sudo apt install nautilus-nextcloud
- Applications > Accessories > Nextcloud desktop sync client Server address: https://cloud.karkat.de/ (Login in browser) (O) Sync everything from server [v] Ask for confirmation for larger than 500 MB [v] Ask before syncing external storage Local Folder: /home/inkarkat/cloud General > General Settings [v] Launch on System Startup Network > Proxy Settings (O) Use system proxy
Ingo Karkat, 20-Dec-2020, updated 14-Apr-2021