1

The default user in Ubuntu is "ubuntu" with no password. How can I change the name? I tried editing casper.conf, but it doesn't change anything. I heard someone say you have to recompile initrd.gz, but never explained how.

Thanks in advance for anyone who knows how to do this.

ovine
  • 109

1 Answers1

0

All the information you need is in the following link (customizing login username and password is about a 1/3 of the way down):

https://help.ubuntu.com/community/LiveCDCustomization

This segment talks about it:

Removing the (Casper) Autologin

The autologin feature of the Jaunty/9.04 live CD is a bit of an on-the-fly boot-hack. After extracting the initrd.gz, you need to edit the casper-bottom/25configure_init script and then recreate the initrd.gz file, replacing the original in extract-cd/casper. The process to do so goes like this:


# cd extract-cd/casper
# mkdir tempdir
# cd tempdir
# gunzip -dc ../initrd.gz | cpio -imvd --no-absolute-filenames
# cp scripts/casper-bottom/25configure_init scripts/casper-bottom/25configure_init.orig
# vi scripts/casper-bottom/25configure_init
Now look for line 25 which has the conditional statement to test $USERNAME.

Line 25 performs a conditional evaluation and if it evaluates to true, it will execute the code within the if block. The if block contains code to modify files used in the boot process to create the live cd autologin.

To disable the autologin feature, Remove $USERNAME, but just leave the quotes. The -n modifier tests the $USERNAME string to see if it's length is non-zero. By removing the variable, and leaving two double quotes, this statement evaluates to false because the two double quotes effectively make a zero-byte string. Be sure to leave no whitespace between the quotes because whitespace will make the evaluation true and execution wil fall into the if block.

21:log_begin_msg "$DESCRIPTION"
22:
23:# Arrange for shells on virtual consoles, rather than login prompts
24:
25:if [ -n "$USERNAME" ]; then
After making the change, line 25 will look like this:

25:if [ -n "" ]; then
Save the file and quit the editor. Then, from extract-cd/casper/tempdir run the following command to re-create the initrd.gz file. There are other methods for re-creating the initrd.gz file on this page which may work also.:


# cp ../initrd.gz ../initrd.gz.orig
# find . | cpio -o -H newc | gzip -9 > ../initrd.gz
This will create a new initrd.gz file with no auto login. You can then continue to remaster the CD as described on this page. Be sure to create a user and password to login with before you remaster the cd. If you do not, you will not be able to login after booting!
Terrance
  • 41,612
  • 7
  • 124
  • 183
  • Thanks for the response, Terrance. I'm having some issues figuring out how to add the new user though, as this guide seems to be for removing it. – ovine Aug 24 '16 at 00:02
  • @ovine I am pretty certain it would be the same commands as creating a new user, setting a password and adding them to groups like sudo before you actually perform the creating of the new initrd.gz. – Terrance Aug 24 '16 at 00:06
  • I see. So I'd want to run those last two commands in that excerpt to create the new initrd.gz while chrooted into the live filesystem, right? I hope it wouldn't be too much to ask, but could you give me the commands to create the new user and apply those things before creating the new one? – ovine Aug 24 '16 at 00:11
  • @ovine I am no longer at a computer right now, but I will post it here for you. – Terrance Aug 24 '16 at 00:16
  • @ovine The command to create a user is useradd username then I would add that user to the sudo group by useradd username sudo. Then set a password for the user passwd username. – Terrance Aug 24 '16 at 02:41
  • Do you know of a way I could still do this but keep the autologin? As in, just adding a new user like normal and setting it as the default for the live system? Thanks again, man. – ovine Sep 01 '16 at 02:59