Showing posts with label nano. Show all posts
Showing posts with label nano. Show all posts

Friday, December 3, 2010

Change default text editor to nano

The default text editor in Arch most probably is vim.
If you want to change that to nano, you will probably do that because the default actions are shown at the bottom of the nano page, so it is easier to use when you don't know the vim shortcuts.
The ^ sign stand for the CTRL key, btw; the M(eta) stands for the Alt key.

To change the default text editor you go to your .bashrc file in /home/user.
Make it visible with ctrl+h.
Then setting something like
export EDITOR=nano

in your .bashrc, or the file for the shell your using, might solve your problem.

/////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\
sorurce of concise nano howto :
http://www.gentoo.org/doc/en/nano-basics-guide.xml

Opening and creating files

Opening and creating files is simple in nano, simply type:

Code Listing 1.1: Creating or opening a file

# nano filename

Nano is a modeless editor so you can start typing immediately to insert text. If you are editing a configuration file like /etc/fstab use the -w switch, for example:

Code Listing 1.2: Disable the word wrapping

# nano -w /etc/fstab

Warning: It is very, very important that you use the -w switch when opening a config file. Failure to do so may keep your system from booting or cause other bad things.

Saving and exiting

If you want to save the changes you've made, press Ctrl+O. To exit nano, type Ctrl+X. If you ask nano to exit from a modified file, it will ask you if you want to save it. Just press N in case you don't, or Y in case you do. It will then ask you for a filename. Just type it in and press Enter.

If you accidentally confirmed that you want to save the file but you actually don't, you can always cancel by pressing Ctrl+C when you're prompted for a filename.

Cutting and pasting

To cut a single line, you use Ctrl+K (hold down Ctrl and then press K). The line disappears. To paste it, you simply move the cursor to where you want to paste it and punch Ctrl+U. The line reappears. To move multiple lines, simply cut them with several Ctrl+Ks in a row, then paste them with a single Ctrl+U. The whole paragraph appears wherever you want it.

If you need a little more fine-grained control, then you have to mark the text. Move the cursor to the beginning of the text you want to cut. Hit Ctrl+6 (or Alt+A). Now move your cursor to the end of the text you want to cut: the marked text gets highlighted. If you need to cancel your text marking, simply hit Ctrl+6 again. Press Ctrl+K to cut the marked text. Use Ctrl+U to paste it.

Searching for text

Searching for a string is easy as long as you think "WhereIs" instead of "Search". Simply hit Ctrl+W, type in your search string, and press Enter. To search for the same string again, hit Alt+W.

Note: In nano's help texts the Ctrl-key is represented by a caret (^), so Ctrl+W is shown as ^W, and so on. The Alt-key is represented by an M (from "Meta"), so Alt+W is shown as M-W.

Wednesday, November 10, 2010

Grant user shutdown permission in suoders file

Yes, you will have to edit your sudoers file in /etc

You will have to edit it so it looks like this:
# %users localhost=/sbin/shutdown -h now
paul ALL=(ALL) ALL
paul ALL=NOPASSWD: /usr/bin/thunar
paul ALL=NOPASSWD: /sbin/reboot
paul ALL=NOPASSWD: /sbin/shutdown
paul ALL=NOPASSWD: /usr/bin/pacman -Sy


In Arch you can define your default editor in /home/user/.bashrc

export EDITOR=nano


Of course replacing paul with your username.
What you do is that as superuser you grant user paul the permission to do certain superuser things like shutting done without password.
You will have to edit the sudoers file not with an ordinary texteditor but with "sudo visudo" in the terminal.

"visudo" is the command used to edit the /etc/sudoers configuration file. It is not recommended that you use any other editor to modify your sudo parameters. "visudo" uses the same commands as the "vi" text editor.

Always make a backup of your old original sudoers file;nevertheless visudo is often configured to work with nano.
To be sure it uses nano you can change the editor visudo uses, by typing

#EDITOR=nano visudo

to edit the file

Ctrl+o, Enter to save
Ctrl+x to exit.

Blog Archive