Installing nano is done using the yum system.
yum -y install nano
Disable Word Wrap
nano, by default, enables word wrap. While nice in a normal document, this is generally undesirable in a configuration file.
echo "set nowrap" >>/etc/nanorc
System Default Editor
During login, a number of scripts are run to setup the environment. In CentOS, a file for each subject is used. These are stored in a system profile directory, /etc/profile.d/. There are two environment variables that control which editor to use.
cat <<EOF >>/etc/profile.d/nano.sh export VISUAL="nano" export EDITOR="nano" EOF
Per User Default
If a user wishes to set the default editor for themselves, it can be, instead, be done in the user’s bash profile.
cat <<EOF >>~/.bash_profile export VISUAL="nano" export EDITOR="nano" EOF
Some of the changes made won’t take effect on the current session. Log out and back in to activate the changes.
Scheduling jobs is one multi-layer process that uses a text editor. Editing the current user’s scheduled jobs is one way to test which editor is the default.
crontab -e Would you want to reboot every 12 hours:
0 0,12 * * * /sbin/init 6
If it is still vi, use :q to exit. If you are using nano, congratulations! Use ctrl-x to exit.
Setting Default Editor During Install
If installing nano and setting it as default editor during installation is desirable, some commands can be added to the kickstart file.
According to the documentation, name resolution isn’t working correctly during the post installation script. To correct that, copy the resolver configuration from the install environment to the chroot environment. If the install environment is different from the runtime environment, specifically, if the name servers are different, make sure to correct the configuration file before the end of the %post install script.
%post --nochroot --log=/mnt/sysimage/root/install-post_.log cp -v /etc/resolv.conf /mnt/sysimage/etc/resolv.conf
Put the previously described commands in the %post section.
yum -y install nano echo "set nowrap" >>/etc/nanorc cat <<EOF >>/etc/profile.d/nano.sh export VISUAL="nano" export EDITOR="nano" EOF