1. Open sudoers file using command : sudo nano /etc/sudoers
2. Then add
"YourUsername ALL=(ALL) ALL"
below the root user
su -
usermod -aG sudo <username>
exit
# Then restart your machine
Remember to reboot the virtual machine after giving yourself sudo righs