nav-left cat-right
cat-right

Bash script to generate cPanel user files...

Don’t have your domains listed in WHM/cPanel. The cPanel takes information from cPanel user files under /var/cpanel/users/. The accounts won’t be listed in WHM if corresponding files are missing. This script will help you to generate cPanel user files. This script may fail if you have cPanel user files existing under /var/cpanel/users/. So I would request you to backup users directory and then remove all user...

Linux Time and Clocks...

There are two clocks in your computer. The hardware (CMOS) clock runs even when the computer is turned off, and is used when the system starts up and by DOS (if you use DOS). The ordinary system time, shown and set by date, is maintained by the kernel while Linux is running. You can display the CMOS clock time, or set either clock from the other, with /sbin/clock (or hwclock). There are various other programs that can...

Linux: How to change time zone information?...

The date command can be used to reset system time, but it can’t be used used to change timezone. However, timezone reconfiguration is pretty easier. # date Sun Feb  7 21:45:53 PST 2010 # rm -f /etc/localtime # cp /usr/share/zoneinfo/EST /etc/localtime # date Mon Feb  8 00:46:34 EST 2010 The ‘timeconfig’ command can also be used to reset time/timezone information on RedHat based machines. ~mohammed

Bash puzzle: Unset last element of an array...

Here is a puzzle for bash lovers. This is taken from shell scripting community at Orkut. Question: How to reset last element of an array even if it’s a discontinuous array. Answer: $ array=([0]=a [9]=d [2]=i [6]=k); echo "${array[@]}" a i k d $ : ${!array[@]} $ unset array[_] $ echo "${array[@]}" a i k If you are not familiar with bash, you might...

C Programming: sizeof variable types...

As you know C programming language has different variable types and each of them use different byte size. Do you wonder how to find size of each variable type in C? Look at the program below. Program: int main() {   printf("sizeof(char) == %d\n", sizeof(char));   printf("sizeof(short) == %d\n", sizeof(short));   printf("sizeof(int)...

apropos: search the whatis database for strings or...

Did you ever sweat as you couldn’t find which commands deal with particular keywords? All linux users know they can get complete details about a command/system call from man pages. But, what if you don’t know the command? Yes, you can use apropos in such a situation . apropos searches a set of database files containing short descriptions of system commands for keywords and displays the result on the standard...

Linux: fork() system call with an example...

fork() creates a child process that differs from the parent process only in its PID and PPID, and in the fact that resource utilizations are set to 0. File locks and pending signals are not inherited. Under Linux, fork() is implemented using copy-on-write pages, so the only penalty that it incurs is the time and memory required to duplicate the parent’s page tables, and to create a unique task structure for the child. RETURN...

Awk FS (Input Field Separator), OFS (Output Field ...

I would like to explain a simple behavior by awk that I noticed while writing a script. #!/bin/awk -f BEGIN { FS=":"; OFS="-"; } { $2=""; print } Give this script the password file, it will delete the password field, but leave everything else the same after changing output field separating to hyphen(-). This works fine, but OFS won’t be effective if you remove the...

Linux Time Fields: Access (atime), Modify (mtime),...

Linux saves 3 different time fields per file in inode. They are access, modify and change time and you can use stat command to get them. As far I know, Linux never stores file creation time (for good or bad, I doubt ). Some guys are not sure about the difference between modify and change time. As I study mostly from man pages, I’m pasting relevant sections from the man page for stat system call. man -s 2 stat time_t...

ptmx and pts – pseudo-terminal master and sl...

NAME ptmx and pts – pseudo-terminal master and slave DESCRIPTION The file /dev/ptmx is a character file with major number 5 and minor number 2, usually of mode 0666 and owner.group of root.root. It is used to create a pseudo-terminal master and slave pair. When a process opens /dev/ptmx, it gets a file descriptor for a pseudo-terminal master (PTM), and a pseudo-terminal slave (PTS) device is created in the /dev/pts...

« Previous Entries