It seems you are using the
vi editor instead of nano.
In nano you can save using Ctrl+x, but this shortcut does something else in vi.
To save a file in vi, first press the
Escape button to leave insert mode.
Then type the following to, respectively, enter Command-line mode and save and exit the file:
If the file has read-only permissions, you will have to add an exclamation mark to force the file to be saved and exit:
Vi might come off as a bit of a strange editor, and takes some time to get used to, but once you start to get the hang of it, it's really nice.
You can find a lot of beginner tutorials on the internet.
PS. If it's a system file you are trying to edit, you will probably also require superuser permissions to edit it.