Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
hi guys, Is it possible to display a menu when my cent os starts up to prompt me for a GUI or a TUI...i know you can switch run modes ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Dec 2012
    Posts
    56

    Lightbulb GUI TUI menu on centos


    hi guys,

    Is it possible to display a menu when my cent os starts up to prompt me for a GUI or a TUI...i know you can switch run modes to tell the OS to go either into GUI or command line


    just thought it would be neat to do this at boot up...or is it there? would this be done in GRUB???

    any info would help the cause...thanks for reading
    jonin

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    hi,

    yeah, it is in grub. or if it isn't, it is easily added. basically, it is, as you said, a difference between calling run level 3 or 5. if legacy grub, edit /etc/grub.conf and copy and paste the stanza of lines pertaining to your default boot image, and give it a "GUI" title. Add " 5" to the kernel parameters, telling it to go into run level 5 no matter what (as in, no matter what /etc/inittab says to do). Add another stanza the same as before, but this time, add " 3". your end result might look like this:
    Code:
    title Red Hat Enterprise Linux (Default)
            root (hd0,0)
            kernel /vmlinuz-2.6.30 ro root=/dev/hda3
            initrd /initrd-2.6.30.img
    
    title Red Hat Enterprise Linux (GUI)
            root (hd0,0)
            kernel /vmlinuz-2.6.30 ro root=/dev/hda3 5
            initrd /initrd-2.6.30.img
    
    title Red Hat Enterprise Linux (Text)
            root (hd0,0)
            kernel /vmlinuz-2.6.30 ro root=/dev/hda3 3
            initrd /initrd-2.6.30.img
    the first stanza will boot into whatever run level is specified in /etc/inittab. the 2nd one will boot into run level 5/GUI, and the 3rd will boot into text-only/run level 3.

    if you have shiny new grub 2.0, then the instructions are different (more complicated) but it is still doable.

  3. #3
    Just Joined!
    Join Date
    Dec 2012
    Posts
    56
    Hey Atreyu,

    this is whats in my grub.conf ....i went to a terminal typed su and logged into my su account then i typed vim /etc/grub.conf

    and this is what came up...do i just need to add your stanzas in here...or edit them...im a bit confused, sorry im a real noob, trying to do things in Linux

    thanks so much for your help

    Code:
    # grub.conf generated by anaconda
    #
    # Note that you do not have to rerun grub after making changes to this file
    # NOTICE:  You have a /boot partition.  This means that
    #          all kernel and initrd paths are relative to /boot/, eg.
    #          root (hd0,0)
    #          kernel /vmlinuz-version ro root=/dev/mapper/vg_centos1-lv_root
    #          initrd /initrd-[generic-]version.img
    #boot=/dev/sda
    default=0
    timeout=5
    splashimage=(hd0,0)/grub/splash.xpm.gz
    hiddenmenu
    title CentOS (2.6.32-279.22.1.el6.i686)
            root (hd0,0)
            kernel /vmlinuz-2.6.32-279.22.1.el6.i686 ro root=/dev/mapper/vg_centos1-lv_root rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=uk LANG=en_US.UTF-8 rd_LVM_LV=vg_centos1/lv_swap rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=128M rd_LVM_LV=vg_centos1/lv_root rd_NO_DM rhgb quiet
            initrd /initramfs-2.6.32-279.22.1.el6.i686.img
    title CentOS (2.6.32-279.19.1.el6.i686)
            root (hd0,0)
            kernel /vmlinuz-2.6.32-279.19.1.el6.i686 ro root=/dev/mapper/vg_centos1-lv_root rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=uk LANG=en_US.UTF-8 rd_LVM_LV=vg_centos1/lv_swap rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=128M rd_LVM_LV=vg_centos1/lv_root rd_NO_DM rhgb quiet
            initrd /initramfs-2.6.32-279.19.1.el6.i686.img
    title CentOS (2.6.32-279.el6.i686)
            root (hd0,0)
            kernel /vmlinuz-2.6.32-279.el6.i686 ro root=/dev/mapper/vg_centos1-lv_root rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=uk LANG=en_US.UTF-8 rd_LVM_LV=vg_centos1/lv_swap rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=128M rd_LVM_LV=vg_centos1/lv_root rd_NO_DM rhgb quiet
            initrd /initramfs-2.6.32-279.el6.i686.img
    ~
    Last edited by atreyu; 04-05-2013 at 04:10 AM. Reason: added CODE tags to aid readability

  4. #4
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Okay, so you've got three kernels in your grub config file. You can see by the title and the kernel line:

    1. 2.6.32-279.22.1.el6.i686
    2. 2.6.32-279.19.1.el6.i686
    3. 2.6.32-279.el6.i686

    Your default kernel is the first one listed (2.6.32-279.22.1.el6.i686). you can tell by the line default=0 near the top of the file (0 is first, 1 is second and so on).

    So what you'd want to do is make two copies of that entire first stanza, with two changes:
    1. change the title to reflect forced GUI/Text mode
    2. add the 3 or 5 to the kernel parameters

    so you'd want something like this, additions in red:
    Code:
    default=0
    timeout=5
    splashimage=(hd0,0)/grub/splash.xpm.gz
    hiddenmenu
    
    title CentOS (2.6.32-279.22.1.el6.i686)
            root (hd0,0)
            kernel /vmlinuz-2.6.32-279.22.1.el6.i686 ro root=/dev/mapper/vg_centos1-lv_root rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=uk LANG=en_US.UTF-8 rd_LVM_LV=vg_centos1/lv_swap rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=128M rd_LVM_LV=vg_centos1/lv_root rd_NO_DM rhgb quiet
            initrd /initramfs-2.6.32-279.22.1.el6.i686.img
    
    title CentOS (2.6.32-279.22.1.el6.i686) GUI Mode
            root (hd0,0)
            kernel /vmlinuz-2.6.32-279.22.1.el6.i686 ro root=/dev/mapper/vg_centos1-lv_root rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=uk LANG=en_US.UTF-8 rd_LVM_LV=vg_centos1/lv_swap rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=128M rd_LVM_LV=vg_centos1/lv_root rd_NO_DM rhgb quiet 5 
            initrd /initramfs-2.6.32-279.22.1.el6.i686.img
    
    title CentOS (2.6.32-279.22.1.el6.i686) Text Mode
            root (hd0,0)
            kernel /vmlinuz-2.6.32-279.22.1.el6.i686 ro root=/dev/mapper/vg_centos1-lv_root rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=uk LANG=en_US.UTF-8 rd_LVM_LV=vg_centos1/lv_swap rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=128M rd_LVM_LV=vg_centos1/lv_root rd_NO_DM rhgb quiet 3 
            initrd /initramfs-2.6.32-279.22.1.el6.i686.img
    
    title CentOS (2.6.32-279.19.1.el6.i686)
            root (hd0,0)
            kernel /vmlinuz-2.6.32-279.19.1.el6.i686 ro root=/dev/mapper/vg_centos1-lv_root rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=uk LANG=en_US.UTF-8 rd_LVM_LV=vg_centos1/lv_swap rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=128M rd_LVM_LV=vg_centos1/lv_root rd_NO_DM rhgb quiet
            initrd /initramfs-2.6.32-279.19.1.el6.i686.img
    
    title CentOS (2.6.32-279.el6.i686)
            root (hd0,0)
            kernel /vmlinuz-2.6.32-279.el6.i686 ro root=/dev/mapper/vg_centos1-lv_root rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=uk LANG=en_US.UTF-8 rd_LVM_LV=vg_centos1/lv_swap rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=128M rd_LVM_LV=vg_centos1/lv_root rd_NO_DM rhgb quiet
            initrd /initramfs-2.6.32-279.el6.i686.img
    You'll have to scroll all the way to the right to see the 3 and 5.

    Note: I added spaces inb/t stanzas to make it easier to read, and I left out the commented portion to save space.

    Give it a try and let us know how it turns out.

  5. #5
    Just Joined!
    Join Date
    Sep 2005
    Location
    Edmonton, Canada
    Posts
    48
    Excellent posts atreyu. One thing to know though, this edit of grub.conf file will need to done with each kernel update.

  6. #6
    Just Joined!
    Join Date
    Dec 2012
    Posts
    56
    OK thats fantastic...did what you said and it works perfectly...you guys are great i really appreciate your help...
    its amazing how much you can learn from doing simple excercises like this
    i learned about the grub.conf file and what it actually looks like, and edited it with vim (not that easy, will need to watch some YT tutorials on vim, bungled my way through it, had to press cursor keys to get right accross to the end of the line [silly])

    i just have a few questions: if you dont mind:

    why did my system have 3 kernels? is this normal?
    when should you update kernels?

    do you guys work with Linux in the industry, my friend works for a big company in London and said to me not to even bother with the GUI, just learn BASH?

    lastly...are there any other excercises you would recomend to get somebody like me more active in Linux?
    it would be nice if there was a missions page, with things to attempt and learn..is there one?

    anyways i have taken enough of your guys time...thanks again for the help...one day i might return the favor, 10 years from now

  7. #7
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by jselover View Post
    One thing to know though, this edit of grub.conf file will need to done with each kernel update.
    @jselover,
    Absolutely 100% right! I meant to include that disclaimer, but forgot. Thanks for catching.

    @j0n1n,
    To get around this issue, you could try a combination of the yum plugin yum-plugin-post-transaction-actions and the grub command line tool grubby.

    The yum plugin will allow you to tell yum to run a custom command whenever a given package (e.g., kernel) is updated, and the grubby command will allow you to edit grub.conf non-interactively. So the idea would be to write a script that uses grubby to modify grub.conf as you wish, then tell the yum plugin to call it.

    It is not what I would call straight-forward, but it is certainly doable. And is definitely an opportunity to learn something!

  8. #8
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by j0n1n View Post
    why did my system have 3 kernels? is this normal?
    It is normal if automatic updates are running. I believe there is an initscript/program called yum-updatesd.

    when should you update kernels?
    The kernel is the most import part of your Linux distribution. Bug fixes, security patches, and feature enhancements are coming out all the time, so it is a good idea to allow updates to run, especially if the machine is exposed to the internet. If it i a production server, you may *not* want to have automatic updates running on it, though. In that case, it would be better to have an identical machine running in parallel which you would update first, and verify that all is well, before applying the updates to the prod server.

    do you guys work with Linux in the industry, my friend works for a big company in London and said to me not to even bother with the GUI, just learn BASH?
    I work w/Linux every day and I am definitely in favor of doing things the command line way (e.g., Bash shell) versus the GUI way. Sometimes, you need or want a GUI, too, though. For me, I only use a GUI if I fully understand what is happening behind the scenes, and I don't lose any fine-grain control by not using the console method.

    lastly...are there any other excercises you would recomend to get somebody like me more active in Linux?
    it would be nice if there was a missions page, with things to attempt and learn..is there one?
    As for what new Linux user should do to get involved, there are other posts on that topic here at LF, but I'd recommend this in no particular order:

    * start reading technical articles on line, and scour the web for free Linux books - they abound
    * install two or 3 different flavors of Linux (e.g., Fedora/RPM-based, Ubuntu/DEB-based)
    * set up a home network (file sharing, printing, web server, etc.) using your Linux (and other) boxes
    * join a LUG if on is in your area
    * contribute to an open source project, most of them are Linux-based

  9. #9
    Just Joined!
    Join Date
    Dec 2012
    Posts
    56
    thanks for the help...i will do what you said...im busy reading the linux+2012 book to take the cert in a few months, then i want to do red hat technician program, dont know which one yet...but i hear you on reading supplementary material. i guess i should also be looking at perl in the near future...thanks again for the help...much appreciated

    jonin

  10. #10
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by j0n1n View Post
    im busy reading the linux+2012 book to take the cert in a few months, then i want to do red hat technician program, dont know which one yet...
    A good idea, I'd say. I think the RHEL Certified System Administrator is a good one for starters. It basically touches all aspects of Linux administration, but doesn't dwell too heavily on any one thing.

    i guess i should also be looking at perl in the near future...
    Perl is an indispensable tool in assisting with Linux administration, IMO. It is part of many scripts that exist behind the scenes and is an excellent choice for working with text files and CGI programming. Be sure to familiarize yourself with the huge repository of 3rd party perl software modules at CPAN. The website perlmonks.org is also an active and excellent resource for getting tough Perl questions answered.

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •