Exit/save edit to sudoers file? Putty SSH
Asked Answered
O

5

48

Been following instructions for editing sudoers file, made changes but the instructions say to exit using ctrl+x - this just gives me a capital X and a caret. Have tried ctrl:x ctrl+Q Esc.

Not using nano or any other gui (just putty terminal), the change I am trying to save is to set nano as default editor.

I just need to know which keys do I press and in which order?

Also as a side question are there any 'good' linux tutorial sites, I seem to trawl for hours trying to find the simplest answers? 'Good' as in explained well and without omitting vital info (like which gui you are using).

Outfitter answered 4/10, 2012 at 21:33 Comment(0)
O
109

To make changes to sudo from putty/bash:

  • Type visudo and press enter.
  • Navigate to the place you wish to edit using the up and down arrow keys.
  • Press insert to go into editing mode.
  • Make your changes - for example: user ALL=(ALL) ALL.
  • Note - it matters whether you use tabs or spaces when making changes.
  • Once your changes are done press esc to exit editing mode.
  • Now type :wq to save and press enter.
  • You should now be back at bash.
  • Now you can press ctrl + D to exit the session if you wish.
Outfitter answered 31/12, 2012 at 12:11 Comment(4)
I am still searching for any 'good' linux sites. It seems most linux admins are unable to explain things with any degree of clarity at all. I guess the ones that can don't give it away for free.Outfitter
to insert in terminal, set terminal keyboard settings F12 to \033[2~Interjection
This is one of the best and simplest introductions to visudo I've been able to find. In most cases, the command will be sudo visudo. You can also save and quit vi/vim with <esc> then :xDarbydarce
By insert you mean i? Pressing Insert on the keyboard does nothing for me. Maybe because visudo is not tied to one editor only and our editors may be different. In my case it is vim. Please be VERY specific - entering insert mode and pressing insert are two different things. Apart from that, thanks for a clear overview.Radcliff
S
17

Just open file by nano /file_name

Once done, press CTRL+O and then Enter to save. Then press CTRL+X to return.

Here CTRL+O : is CTRL and O for Orange Not 0 Zero

Seltzer answered 5/11, 2014 at 10:11 Comment(0)
W
3

#UBUNTU20

if you are opening this file as root, then type

root# visudo

the file will be opened, go to the line where you want to add/modifiy anything simply without any insert or i button pressed.

press ctrl + O
press ctrl + x
press enter

Winslow answered 25/1, 2021 at 13:59 Comment(1)
sudo EDITOR=nano visudo in case if Nano is preferred.Selfrenunciation
B
2

The tutorial you saw was telling you how to exit nano editor. By typing Ctrl+X nano exits and if your file needs change you will be prompted to save the changes in which case to save you should press Y and then enter to save changes in the same file you open.

If you are not using any gui and you just want to leave the shell the command is Ctrl+D.

Regarding tutorial, The Linux Documentation Project would be a good place to start. If you like books I would recommend by far any book you want from O'Reilly. They have nice cd bookshelfs with good compilation for any linux sysadmin, and without much effort you can find many places where those html bookshelfs are available to read online.

Baldachin answered 4/10, 2012 at 22:57 Comment(2)
Sorry but Ctrl+D does not exit visudo, it exits the shell. I need to exit and save visudo before exiting the shell. Yes I could read the entire linux documentation or all the books from O'Reilly but that isn't why I asked a question here.Outfitter
Ctrl+X -> N for don't save changes -> Y for save changesAntimonic
R
0

Be careful to type exactly :wq as Wouter Verleur said at step 7. After type enter, you will save the changes and exit the visudo editor to bash.

Rounder answered 3/8, 2015 at 2:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.