Tuesday, 25 September 2012

Monday, 12 March 2012

check if a year is a leap year.

read this codes from Linux Device Driver, think it is good :)
record it here.

/*
 * return 1 if year is leap year, 0 otherwise.
 */
static int inline
leap_year(int year)
{
    return !(year % 400) || ( !(year % 4) && (year % 100)) ;
}

/* Number of days in each month (not leap year). */
static const char no_of_days[] =
{ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

Monday, 27 February 2012

usermod command

usermod command

the default path of the command is /usr/sbin

add one user to one group:
here use the option '-a'

from the manul
  -a, --append                  append the user to the supplemental GROUPS
                                mentioned by the -G option without removing
                                him/her from other groups

/usr/sbin/usermod -a -G group1 user_name

remove one user from one group, you have to move that user to another group:
/usr/sbin/usermod -G group2 user_name