Setting an Alias as root

Posted on 2005-05-12
Last Modified: 2013-12-27
I wanted to know how to set an alias as root
I can set an alias while logged in as root
alias psm "/usr/ucb/ps auxgw | more"
but this is removed once I log out.
how would I set a permanant alias?

Question by:Troder
    LVL 34

    Accepted Solution

    When you login as root, execute your fave shell (bash, tcsh, zsh, whatever). Have the appropriate configuration (.profile, .cshrc, whatever) file in root's home directory and put the configuration statements you want in there (for example, command aliases).

    DO NOT change root's shell!!

    Leave it as sh. Instead, run whatever shell you prefer, after logging in as root.
    LVL 5

    Expert Comment


    Create a file calle /.profile and put the 'alias ...' line in the file.

    When a user logs in his .profile is run.  This can also be used to add directories to the PATH, MANPATH etc.

    Hope this helps,

    Regards, Nisus
    LVL 34

    Expert Comment

    Optimally, you should never log directly in as root. Instead, log in as yourself, and either use sudo to escalate privledge for specific tasks, or use su to gain root privs. Allowing root login from anywhere but the console, especially if you're not using SSH, is a Bad Idea (tm).
    LVL 5

    Expert Comment

    PsiCop is perfectly correct.  In fact I would prefer to use ssh rather than telnet.  You can setup trusting so it is a trivial matter to wander around all your servers, and everything is encrypted.

    LVL 38

    Expert Comment

    If you did not setup the box, have a look at the /etc/passwd to find out where's the root's
    home dir, default is /, but some sys adm (including me) put the root's home dir in a place
    other then /. then modify (or create) the .profile file under root's home dir and put your
    alias in the file, you can add other ENV settings eg:
    PATH,  MANPATH, LD_LIBRARY_PATH .... etc in the same file.

    For security reason, turn off telnet and ftp in your system (plain text password), use ssh
    instead. at least don't allow root telnet/ftp from outside to the box.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
    Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
    This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
    This tutorial goes over how to archive and restore FreeBSD jails that are managed by ezjail.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now