Cka query while editing in vi

Hi while practicing on killersh mock exam I was trying to edit my file using vi but it doesn’t not allow me to save the file.
It only to quit the file.
Kindly help. I have my exam in a day.

Hi @suraj001

To save a file on Vim, you can pass :w and to save and exit the vim editor:wq or :wq! force override and save and quit. In Vim you can remember the keys as w is for write and q for quit.
If you just want to quit without saving the file - :q or q! for force override and quit.

You can refer to our Vim-101, that should help you.

PS: Remember the modes in Vim - Normal and Insert among others. Above commands are to be run from Normal mode. You can enter Normal mode by pressing Esc key.

i’m getting the message posted after the esc :wq itself.
Kindly help

Alos if try to redirect by using imperative command and dry run into a file. I’m getting permission denied error as below.

By the screenshot, it appears you are in the root directory:
/$
check with pwd
if you intend to run it from the root, try sudo vi 2.yaml .

Else, you can cd back to user’s $HOME and try there without sudo.

So all kubectl commands in cka exam should be by going to home directory?

IIRC, you do not need to change to some directory unless required by the task.
Kubectl and vi should work without sudo.

Kubectl will be available from the node you will work from. You can get a feel of the exam env by practicing from killer.sh, which closely resembles the real Exam env.
And, you can escalate privileges by using sudo -i whenever required.

Please refer to this important technical doc by LF.