Category Archives: Linux

RedHat Linux Run-Levels

What is a Run-Level?

“Runlevel” defines the state of the machine after boot. Different runlevels are typically assigned to:

  • single-user mode
  • multi-user mode without network services started
  • multi-user mode with network services started
  • system shutdown
  • system reboot

The exact setup of these configurations will vary from OS to OS, and from one Linux distribution to another.  As a result, the information listed below is for Redhat Linux.  Below are the different Redhat levels:

  • 0 is Halt
    • Immediately shuts down system and powers it off, if it can.
  • 1 is Single user
    • Brings system to a bare essentials mode for maintenance
  • 2 & 4 is User-defined or custom
  • 5 is Multi-user with display and console
    • All services are running including X11 (or GUI)
  • 6 is Reboot

You might be able to tell what runlevels are used with you Linux distribution by entering the following command:

cat /etc/inittab

Then look for the section that has a description similar to “Default runlevel.  The runlevels used by…”

How do you tell what runlevel you’re currently running?  Good question, here’s the command:

who -r

The result lets us know that we are currently at level 3 and previously running level 5.  How do we change the current level?  Wow, I’m overwhelmed by the excellent questions for this post ;).  Here’s the command:

init 3

This command will change the run level to 3.  However, on reboot it will go back to the default level which is usually runlevel 5 for Redhat.  To make it permanent run the following commands:

su -c ‘vi /etc/inittab’

Now scroll down to the line that has “id:5:initdefault:” (image below) and enter “o”  This will open a new line and enter edit mode.  Change the 5 to the runlevel your configuring.  In this case it would be 3.  Hit the “ESC” key on your keyboard to exit edit mode.  Then enter the following CMD “:x”.  This command saves and exits vi.

Note: Run-Level 1 stops all services.  As a result, you may need network connectivity.  Below is the command to start the network services:

service network start; service nfs start

References:

http://en.wikipedia.org/wiki/Runlevel


Assigning a userID sudo rights in Redhat Linux

In Windows you can give a userID full access to the system by making them a member of the Administrator’s group.  However, root access in Redhat Linux WILL NOT grant a user full access to the system.  You will need to assign the userID sudo access as well.  Here’s how:
  • Open a command prompt and type: visudo
  • Scroll down to the section that says “## Allow root to run any commands anywhere” and type “o“.  This will open a new line and go into edit mode.
  • Type the “userID   ALL=(ALL)  (ALL)“you’ll be assigning sudo rights.
  • Hit the ESC key to exit edit mode
  • Type :xto save and exit.
Note: If you need to revert back to the original type: “:e!”  This is useful if you run into issues when editing this file.


How to determine if you’re running a 32 or 64bit Version of Linux

Need to know if your running a 32 or 64bit version of Linux and don’t know how to.  No problem: Open a command prompt and type: getconf LONG_BIT