The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Default editor in SSH (why different for different accounts)

Discussion in 'General Discussion' started by cookiesunshinex, Jun 12, 2006.

  1. cookiesunshinex

    cookiesunshinex Well-Known Member

    Joined:
    Jun 10, 2005
    Messages:
    77
    Likes Received:
    0
    Trophy Points:
    6
    I've been running a server with cPanel on it for about a year.

    On my older accounts, the default editor through SSH is VI editor.

    On newer accounts, the default editor is Nano. I have no idea why it's different for the newer accounts, but I wish that it wasn't.

    I first discovered this when trying to create crontab entries on the new accounts using crontab -l.

    The problem is that when I go to save my new crontab entries, I hit Control X and then it asks me if I want to save the file, I say Yes, and it tries to save the file with a tmp file name in the /tmp directory.

    Do anyone have any suggestions on how I can change the default editor for the new accounts permanently to VI.

    Secondly, is there any explanation on why this has changed only for the newer accounts? Is it safe to assume that it has something to do with the skeleton directory that was probably updated by a cpanel update?

    Thanks.
     
  2. rumor

    rumor Member

    Joined:
    Aug 26, 2005
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Check the files /etc/bashrc, /etc/profile, and the .bash* files in /etc/skel. The environment variable EDITOR usually gets set in /etc/bashrc (which is read from .bashrc) which defines the default editor. I would guess that the older accounts have that environment variable set in the user-specific .bashrc instead of reading from the system-wide one in /etc/bashrc.

    I think the normal behavior of crontab -e is to load a tmp file, and then once the changes are saved that gets picked up and loaded in the right place for cron to do what it's supposed to do.
     
  3. cookiesunshinex

    cookiesunshinex Well-Known Member

    Joined:
    Jun 10, 2005
    Messages:
    77
    Likes Received:
    0
    Trophy Points:
    6
    I figured out that the older accounts do not have a .bashrc in their home directories. The newer accounts do have a .bashrc in their home directory. It matches what is in the following files from /etc/skel/.bashrc file:

    Code:
    # .bashrc
    
    # User specific aliases and functions
    
    # Source global definitions
    if [ -f /etc/bashrc ]; then
            . /etc/bashrc
    fi
    
    I did notice that the /etc/bashrc lists Pico environment variables.

    What should change and where if I want to use the VI editor server wide?
     
    #3 cookiesunshinex, Jun 27, 2006
    Last edited: Jun 27, 2006
  4. cookiesunshinex

    cookiesunshinex Well-Known Member

    Joined:
    Jun 10, 2005
    Messages:
    77
    Likes Received:
    0
    Trophy Points:
    6
    Sorry to bump this up, but what do I need to do so that by default all accounts (new accounts) use VI editor?

    Thanks.
     
  5. websupport

    websupport Well-Known Member

    Joined:
    Jun 24, 2006
    Messages:
    92
    Likes Received:
    0
    Trophy Points:
    6
    Check rc.conf

    Change /etc/rc.conf to set default editor

    Setting vi as the default editor

    (Set EDITOR to your preferred editor.)
    #EDITOR="/bin/nano"
    EDITOR="/usr/bin/vim"
    #EDITOR="/usr/bin/emacs"

    :)
     
  6. cookiesunshinex

    cookiesunshinex Well-Known Member

    Joined:
    Jun 10, 2005
    Messages:
    77
    Likes Received:
    0
    Trophy Points:
    6
    This file did not exist in /etc/ or in home/user1/etc

    I created the file /etc/rc.conf and added the line you suggested.

    Logged out, and then logged back in and see no difference.

    Is there any process I need to stop/start?

    Should this be created in the user's home/user1/etc directory?


    Thanks.
     
  7. cookiesunshinex

    cookiesunshinex Well-Known Member

    Joined:
    Jun 10, 2005
    Messages:
    77
    Likes Received:
    0
    Trophy Points:
    6
    I think I've figured out my problem.

    1. When user's login and type crontab -e, the editor that is used is Pico.

    Unfortunately, when they try to save the file, it can't be written properly to the /tmp directory. Maybe it's a permissions issue on /tmp directory.

    For some reason, the accounts that use VI editor when typing crontab -e, are able to save the file and it be added to the crontab properly.

    2. I found that some accounts had /home/username/.bashrc and /home/username/.bash_profile and some did not.

    The one that had the files used pico editor when typing crontab -e

    3. I also noticed that rm -R worked for the accounts, but not for the root account. I posted a message in another post regarding this problem, and I figured out that the /root/.bash_profile had some aliases set, but the user's accounts ./bash_profile did not have this alias set.

    So I started to compare the .bash_profiles.

    in the /root/.bash_profile I found this line:
    export VISUAL=/bin/vi

    I believe that I had added that to the /root/.bash_profile a while back while reading a message in this discussion forum regarding setting the default editor.

    I added this line to one of the /home/username/.bash_profile and I was able to execute crontab -e and the system loaded the VI editor to edit the crontab...which was the desired result.

    Thanks for the help. I think I understand the importance and effect of the .bashrc and .bash_profile files now.

    I hope this post helps other people as well.
     
Loading...

Share This Page