https://www.everythingmacintosh.com/tech-notes/repair-your-hard-disk-in-single-user-mode/Start or restart your Mac. As soon as you hear the startup tone, press and hold Command-S on the keyboard. Keep holding down those keys until you see a black screen with white lettering. This is called “booting into Single User Mode.”
This will not work in Screen sharing mode. The Keyboard disconnects as soon as you disconnect the screen sharing session.
I do not think there is a way to do this without a keyboard attached to the G5.
Thanks