init vs. telinit

hellothere52hellothere52 Member Posts: 1 ■□□□□□□□□□
I've been looking through tons of websites and books, and can't find a single explanation as to the difference between the init and telinit commands.

In fact, one book said that the telinit command was an alias shortcut to the init command. How is typing 3 more letters a "shortcut"????

Can anyone help?

Thanks!

Comments

  • Daniel333Daniel333 Member Posts: 2,077 ■■■■■■□□□□
    I believe they are the same thing my friend. Some authors and distros just prefer one over the other.

    Seemed interesting enough...
    http://www.ncsa.uiuc.edu/UserInfo/Resources/Hardware/IBMp690/IBM/usr/share/man/info/en_US/a_doc_lib/cmds/aixcmds5/telinit.htm
    -Daniel
  • livenliven Member Posts: 918
    Well the only thing I can see is that

    in SUSE

    telinit is a symlink to init


    So they do the same thing.

    AND,

    if you do a man on telinit you get the init man page....


    So don't really know why telinit exists but init will do the same thing on some distros.
    encrypt the encryption, never mind my brain hurts.
  • tierstentiersten Member Posts: 4,505
    telinit is used to signal init that you want to change to a different runlevel. You're supposed to use telinit.
  • livenliven Member Posts: 918
    tiersten wrote:
    telinit is used to signal init that you want to change to a different runlevel. You're supposed to use telinit.


    Really?


    I didn't know that, usually I just do something like this:



    init 3

    or what ever level I want to change to.

    And when you reboot suse (enterprise) it issues:


    init 6

    since the commands are symlinked together I don't really think it mattes.


    Is telinit an older command to be depriciated?
    encrypt the encryption, never mind my brain hurts.
  • tierstentiersten Member Posts: 4,505
    liven wrote:
    Is telinit an older command to be depriciated?
    Just doing init <new runlevel> works because at some point, somebody added code to support that. For compatibility with other UNIX systems which may not use the same init, you're still supposed to use telinit. It isn't depreciated.

    A program can tell what name you're executing it as. Just because its a symlink doesn't mean the two copies will do the same thing. There is a mini utility package called busybox which implements a basic version of several utilities. You only ever get 1 binary called busybox. Everything else is symlinked to that. It knows what you're trying to do because of what the symlink names are.
  • livenliven Member Posts: 918
    tiersten wrote:
    liven wrote:
    Is telinit an older command to be depriciated?
    Just doing init <new runlevel> works because at some point, somebody added code to support that. For compatibility with other UNIX systems which may not use the same init, you're still supposed to use telinit. It isn't depreciated.

    A program can tell what name you're executing it as. Just because its a symlink doesn't mean the two copies will do the same thing. There is a mini utility package called busybox which implements a basic version of several utilities. You only ever get 1 binary called busybox. Everything else is symlinked to that. It knows what you're trying to do because of what the symlink names are.


    I guess my confusion is that I can not find a telinit command any where on any of the linux boxes I own or admin professionally. telinit is always a symlink to init.

    Now I am sure there are some OS's out there that can tell the different between init and telinit. But on the systems I use/maintain/admin/own when/why would I need to use telinit over init?

    I am asking when is it better to use one over the other. Or, to better phrase the question, what does telinit do that init doesn't do (or vice versa).

    THanks!!
    encrypt the encryption, never mind my brain hurts.
  • tierstentiersten Member Posts: 4,505
    liven wrote:
    I guess my confusion is that I can not find a telinit command any where on any of the linux boxes I own or admin professionally. telinit is always a symlink to init.
    On Linux it is nearly always a symlink if you're using a standard init. On other UNIX systems it may not be.
    liven wrote:
    Now I am sure there are some OS's out there that can tell the different between init and telinit.
    Any UNIX system can. Most other modern OSes can as well. I'm just pointing out that because its a symlink doesn't mean that both commands will do the same thing. The program can tell the difference.

    On a Linux system:
    If you run telinit then the init binary will know that you've run it as telinit and therefore run the code to send the new runlevel to the real init.

    If you run init then the init binary will know that it isn't PID 1 and therefore will assume that you actually want to do what telinit does. This isn't guaranteed for all UNIX systems.
    liven wrote:
    But on the systems I use/maintain/admin/own when/why would I need to use telinit over init?
    "init <new runlevel>" will work in your case. There is no guarantee that it will work in every system however. "telinit <new runlevel>" should work in every system.
  • MentholMooseMentholMoose Member Posts: 1,525 ■■■■■■■■□□
    I have a couple Fedora installs and telinit is not symlinked to init... they are separate binaries. They are part of the "upstart" package.
    [mentholmoose@localhost ~]$ which init telinit | xargs ls -l
    -rwxr-xr-x. 1 root root 138312 2009-07-22 05:02 /sbin/init
    -rwxr-xr-x. 1 root root  60504 2009-07-22 05:02 /sbin/telinit
    [mentholmoose@localhost ~]$ cat /etc/redhat-release
    Fedora release 11 (Leonidas)
    [mentholmoose@localhost ~]$ rpm -q upstart
    upstart-0.3.11-1.fc11.x86_64
    
    Also of potential interest:
    [mentholmoose@localhost ~]$ init --help
    Usage: init [OPTION]...
    Process management daemon.
    
    Options:
      -q, --quiet                 reduce output to errors only
      -v, --verbose               increase output to include informational messages
          --help                  display this help and exit
          --version               output version information and exit
    
    This daemon is normally executed by the kernel and given process id 1 to denote
    its special status.  When executed by a user process, it will actually run
    /sbin/telinit.
    
    Report bugs to <fedora-devel-list@redhat.com>
    
    MentholMoose
    MCSA 2003, LFCS, LFCE (expired), VCP6-DCV
Sign In or Register to comment.