I’m a newer for Rocky Linux, I installed Rocky 9.6 on my PC yesterday.
I created a user account, but I forgot to set my new user account to administrator, and the root user also had been banned, so there is no user account has “sudo” permission in the system
if you are able to shutdown this system and access the disk directly from another OS, you can edit the group file to include your user in the wheel group.
“root” is banned or “root” logins are not allowed? Did you create a password for root on install? Assuming you did create a root password then open a terminal and change to the root user thus:
$ su -
<root passwd>
groupmod -a wheel -U <your username>
Then type ctrl d to exit the root user and logout and back in again and you should have sudo permission.
yes, my noe-privileged user account can shutdown system. I did install the system to VM software, but I don’t know how to access the disk directly from another OS, could you give me some tips?
The easiest way for this would be booting the installation image again and then switching to the shell (alt + f2).
Then you basically just need to mount the root disk.
There it depends on your disk configuration, assuming your system is using EFI, disk is sda and you used the default partitioning it’s most likely partition 3 (sda3) with LVM on it and the root partition then it rl-root. (use ls /dev/mapper, lsblk and blkid to find out if your configuration matches the assumptions before and after scanning for LVM disks)
then it’s just a vgscan and vgchange -ay away from being able to mount /dev/mapper/rl-root, best just mount it to /mnt.
And then you can just do a vi /mnt/etc/group and add your username at the end of the wheel line.
This is the very condensed version of it, if you need it more in detail I might need some outputs of your system (the beforementioned ls, lsblk, …)
The installation image should have “Troubleshoot” option, and within it “Rescue”. Than may automate part of the “find and mount”.
Then the “disk” of the VM would be an “image/file” on the host to access and mount, for example by creating a second Rocky VM and attaching the image to that VM (and then find&mount&edit).
Thanks for the answers from friends, I had reinstalled Rocky Linux eventually, because there was no “Troubleshoot“ option when the system booting, I installed Rocky server with GUI the first time, and I don’t know why has no “Troubleshoot“ option when the system booting.