I edited my /etc/profile in root to attempt to run a script at login, but apparently I did that wrong.

The issue now, after rebooting the VM, the login loops. If I type in my user name and then password, it will successfully login, display the time of my last login, and then return me back to the login screen after a second or so. I've tried logging in as root and my normal login. I read somewhere else that booting into a recovery mode could help, but I can't find that option when booting Arch. I have options for:

  1. Arch Linux pkg-linux-kernel
  2. Arch Linux pkg-linux-kernel (fallback initramfs)
  3. Arch Linux
  4. Advanced options for arch linux

I've tried all of these boot options

  • 1
    It is a bit late now, but the next time you do similar things: do not log out. Switch to a different TTY and test if your login changes work. Only then consider logging out. – Hennes Mar 16 '14 at 12:53

Download any Linux iso image. Preferably something small and simple such as Puppy Linux but anything will do as long as it is bootable. Attach that to your VM and boot from it. Once you're booted into this system, mount the local drive of the VM. This should be as easy as opening a file manager and clicking on the drive.

If not, just open a terminal and run this:

sudo mkdir /media/arch; mount /dev/sda1 /media/arch

That will mount the first partition of the first drive (change that to match your system) on the directory /media/arch. You can now access your profile at /media/arch/etc/profile. Open it in a text editor, undo your changes, save the file and reboot the VM. That's it.

  • Ah that makes sense. I had a feeling I would need something like a live cd. I'll try this out. – Brian Ecker Mar 16 '14 at 4:14
  • @BrianEcker I'm assuming a certain level of linux knowledge because you're using Arch so I haven't given many details. If you have trouble with any of these steps, please post a new question. – terdon Mar 16 '14 at 4:20
  • Ok, I've got a question. I've booted another iso in VirtualBox. When I go to list the drives, the only drive I see is /dev/sda which I believe is all for the currently booted OS in VB. Normally, if I wanted to mount a drive, I would list them all either through command line or something like gparted, and then mount the appropriate one, but I only see one, and I think it has to do with the VM. Any help? – Brian Ecker Mar 18 '14 at 8:13
  • @BrianEcker the /dev/sda is your VM's hard drive, you can check by running lsblk, the ISO will be something like sr0. – terdon Mar 18 '14 at 14:46

Probably not as clean as using a boot CD, but the following may be useful if you don't have something else to boot lying around.

When the linux kernel has been loaded and started, as the last step it normally starts the init program (e.g. /sbin/init). But you can specify as a kernel parameter which program to run instead, so you could just as easily start /bin/bash for example.

This could be used to solve your problem:

  1. in the boot options, add init=/bin/bash rw to the kernel command line and boot with these extra parameters.
  2. when the kernel is done starting, it will start bash, giving you a prompt in which you have root access.
  3. thanks to the rw option (read-write), the device mounted as / can be written to, so you can now edit /etc/profile
  4. then, remount the / device as read-only. This makes sure the changes are written and the device is no longer being modified, which is very desirable in case we need to do a hard reset (probably depends on the distro, but it's possible that the reboot command won't work). To remount, run mount -o remount,ro /
  5. reboot the machine

You should boot in single-mode , however I don't know you access for single mode or not. Then modify /etc/profile. Then restart your OS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.