Tried to change user name, now cannot log in

I have been trying to change my user name and machine name, however now I cannot log in and I am directed as guest. Is there a way to resolve this problem?

I'm afraid you need to call a (the?) sys admin. You are (resp. have been?) the sys admin? Boot into single user mode.

I am the sys admin. I can only log in as guest since my password is not being recognised.

Looking at /etc/passwd I have the entry

hagbard:x:1000:1000::/home/cdi:/bin/bash

Used to be cdi

Originally had

cdi:x:1000:1000::/home/cdi:/bin/bash

then changed it to

cdi:x:1000:1000:hagbard:/home/cdi:/bin/bash

then to

hagbard:x:1000:1000::/home/cdi:/bin/bash

Looks like you can log in as root. How did you do all those changes? Using what tools, or did you edit passwd manually?

Manually. Also changed name from User Accounts. Played around with usermod as well. How can I get as root? User is now hagbard but cannot accept the password I had for cdi.

How about manually resetting it to cdi:x:1000:1000::/home/cdi:/bin/bash and then use system tools ONLY!? Just guessing you have the shadow suite (or equivalent) installed, which needed to be modified simultaneously, which you missed when tinkering manually and which system tools would include automatically.

I have tried, however running

sudo gedit /etc/passwd

is giving

sudo: unable to change to root gid: Operation not permitted

I'm afraid you need to log in as root.

How can I do that?

user name "root" and the respective password. Didn't you say you're the sys admin?

Yes, but I seem to have lost access

---------- Post updated at 10:26 AM ---------- Previous update was at 10:24 AM ----------

guest-mKNnW5@fuckup:~$ root
bash: root: command not found

su -

or, if you can elevate as part of the sudoer list.

sudo -i

Open a new session with your xterm or emulator or on a virtual console. You'll see

.......
... login:

enter "root" as the user name. You'll see

Password: 

enter the correct root password.

If that doesn't work, boot into single user mode.

It is saying login incorrect

---------- Post updated at 11:50 AM ---------- Previous update was at 11:08 AM ----------

How can I get into single user mode?

If you were in X11 and opened a GUI session, you may still have old credentials active e.g. cdi letting you as cdi open a new xterm, and it might save you as cdi should have sudo privilege, as you didnt change them...
That said going to single user mode is architecture and OS dependant... I see nowhere anything in your previous posts on this thread...

What operating system are you using? For Linux kernel based, please, state the version of the distribution.

Am using Trisquel 7, free system derived from Ubuntu

Trisquel does not have the root user account available (it is locked) as it inherits this feature from Ubuntu. The first user created has administrator privileges which it is invoked by placing the command sudo in front of the task that requires elevated privileges.
It will ask you for a password, and that password is your password as a normal user.
sudo -i will give you a session as if you were root (you see the classic # for root). The password asked is your normal user login credentials.

---------- Post updated at 11:28 AM ---------- Previous update was at 11:12 AM ----------

Do you mind to post the output of the following command which will display the groups you are part of?

id guest-mKNnW5

guest-rVMxCC@fuckup:~$ id guest-mKNnW5
id: guest-mKNnW5: no such user

---------- Post updated at 06:55 PM ---------- Previous update was at 06:31 PM ----------

My password did not let me in

Yeah, I thought that username you posted previously was reveling, but this confirms it, anyway. You are login in as a very limited guest user. That's why the name changes every time. You are not login as the normal user, the one you have to make in order to install the OS.

At this point, if you do not remember what that credentials were, you might need to try to recover it. However, I warn you that you might render the system unusable.

Here's a link from the Ubuntu camp. It should be about the same.