Lesson 7

Dates: 3/5/2014
Start-up and Run Levels. Scheduled jobs (at, cron)
Linux for Engineering and IT Applications


Practical Exercises with run levels


  • The exercises below should be done on run01 VM.
    virsh run01
    

  • Switching between run levels.

    Create /etc/inittab with the following entries
    id:5:initdefault:
    
    to boot into default Run Level 5; reboot the system using /sbin/init 6 command. When the system boots up, verify the current run level with command
    /sbin/runlevel
    
    Change sequentially to Run Levels 3, 2, and 1 using command
    /sbin/init N 
    
    where N is the next Run Level. Run /sbin/runlevel command in every Run Level.

  • Creating startup scripts.

    Copy the script from the lecture, sample.sh, in /etc/init.d directory; make it executable; try to run it:
       
       /etc/init.d/sample.sh
       /etc/init.d/sample.sh start
       /etc/init.d/sample.sh stop
    
    Create symbolic links of the script to various /etc/rcN.d directories:
       ln -s /etc/init.d/sample.sh /etc/rc1.d/K99sample  
       ln -s /etc/init.d/sample.sh /etc/rc2.d/S01sample  
       ln -s /etc/init.d/sample.sh /etc/rc3.d/K99sample  
    
    Init to Run Levels 1, 2, and 3 and notice if the init runs S01sample and K99sample scripts: check the updated content of file /var/log/sample.log Remove the links. Set the script to "stop" at run level 1, 3, and 5 and "start" at Run Levels 2 and 4:
    update-rc.d sample.sh start 20  2 4 . stop 80  1 3 5 .
    

    Check what kind of links with sample.sh have been created in /etc/rc1.d /etc/rc2.d, /etc/rc3.d, /etc/rc4.d and /etc/rc5.d
    Remove the log file
    rm /var/log/sample.log  
    
    Enter Run Levels 1, 2, 3, 4, and 5. Check the content of file /var/log/sample.log.


  • Take me to the Course Website