When I go to terminal and try to enter a sudo commands it say's "Username not in the sudoers file." So how can I be able to use sudo commands.
You need some user account with root priviledges to assign root priviledges to your own account.
To check if you have any such account on your computer you can either check:
a) Switchboard > User accounts
b) checking the content of sudoers file in /etc/sudoers. However I see no way of checking it without sudo other than booting from liveCD and opening it from there.
This is not exactly an answer and should have been a comment. However I don't have enough reputation points to comment your question so I've been forced to polute it with fake answer. Thanks for understanding.
I ran into a similar issue as the only administator of my machine. If you have another administative user, jena's answer is an easier way.
I was really helped by an anwser on askubuntu about resting a lost administrative password. https://askubuntu.com/questions/24006/how-do-i-reset-a-lost-administrative-password
Full steps :
You need to boot into recovery mode.
Boot up the machine, and after the BIOS screen, hold down the left Shift key. You will then be prompted by a menu that looks something like this:
I've noticed on some systems that timing when to hit the left Shift key can be tricky, sometimes I miss it and need to try it again.
If you have full disk encryption, you have to hold down the key before being asked for the disk password. (You will be asked for the password in a command line interface during boot).
Hit the down arrow until you select the 2nd entry from the top (the one with the recovery mode in the description) and then hit Enter.
Now you should see this menu:
Using the arrow keys scroll down to root and then hit Enter.
You should now see a root prompt, something like this:
At this stage you should have a read-only filesystem. You have to remount it with write permissions:
mount -o rw,remount /
Now we can set the user back into the sudoers group with the
adduser command. (In this example I will use jorge as the example, you need to substitute whatever the user's username is):
root@elementary:~# adduser jorge sudo
Now you can reboot, and you should be able to use sudo commands. You should make sure that you are part of following groups :
- jorge (your username)
You can add your user back in these groups with sudo
jorge@elementary:~$ sudo adduser jorge adm