20 January 2014

UNIX Timestamps: mtime, ctime, and atime

Unix keeps 3 timestamps for each file: mtime, ctime, and atime.

Most people seem to understand atime (access time), it is when the file was last read.

There does seem to be some confusion between mtime and ctime though. ctime is the inode change time while mtime is the file modification time. "Change" and "modification" are pretty much synonymous. There is no clue to be had by pondering those words.
Instead you need to focus on what is being changed. mtime changes when you write to the file. It is the age of the data in the file. Whenever mtime changes, so does ctime. But ctime changes a few extra times. For example, it will change if you change the owner or the permissions on the file.


Let's look at a concrete example. We run a package called Samba that lets PC's access files. To change the Samba configuration, I just edit a file called smb.conf. (This changes mtime and ctime.) I don't need to take any other action to tell Samba that I changed that file. Every now and then Samba looks at the mtime on the file. If the mtime has changed, Samba rereads the file. Later that night our backup system runs. It uses ctime, which also changed so it backs up the file. But
let's say that a couple of days later I notice that the permissions on smb.conf are 666. That's not good..anyone can edit the file. So I do a "chmod 644 smb.conf". This changes only ctime. Samba will not reread the file. But later that night, our backup program notices that ctime has changes, so it backs up the file. That way, if we lose the system and need to reload our backups, we get the new improved permission setting.

Here is a second example. Let's say that you have a data file called employees.txt which is a list of employees. And you have a program to print it out. The program not only prints the data, but it obtains the mtime and prints that too. Now someone has requested an employee list from the end of the year 2013 and you found a backup tape that has that
file. Many restore programs will restore the mtime as well. When you run that program it will print an mtime from the end of the year 2013.

But the ctime is today. So again, our backup program will see the file as needing to be backed up.

Suppose your restore program did not restore the mtime. You don't want your program to print today's date. Well no problem. mtime is under your control. You can set it to what ever you want. So just do:

$ touch -t 201301231150.30 employees.txt

This will set mtime back to the date you want and it sets ctime to now. You have complete control over mtime, but the system stays in control of ctime. So mtime is a little bit like the date on a letter while ctime is like the postmark on the envelope.

02 December 2011

Exit the VM from OVM Console

Most of us are aware of this command

xm console {vm-name} to connect the VM from dom0

But once you have initiated, you wont be able to go back to dom0.These are the control commands that will help you to get back to dom0

ctrl + ]   "->" If you have initiated the command from the console
ctrl + 5  "->" If you have initiated the command via Putty Session

31 July 2010

Run level - Solaris

The first thing I noticed was /etc/inittab file is different from the Linux version. However, runlevel are quite identical

Default Solaris Run Level

• S : Single user state (useful for recovery)
• 0 : Access Sun Firmware ( ok> prompt)
• 1 : System administrator mode
• 2 : Multi-user w/o NFS
• 3 : Multi-user with NFS
• 4 : Unused
• 5 : Completely shutdown the host (like performing a power-off @ OBP) 
• 6 : Reboot but depend upon initdefault entry in /etc/inittab

Solaris 8/9 Find out runlevel

To find out current runlevel use who command:

$ who -r

Output:

. run-level 3 Mar 3 14:04 3 0 S

Solaris changing runlevels after bootup

You need to use init command, for example change runlevel to 2.

# /sbin/init 2

Solaris changing the default runlevel

An entry with initdefault (in /etc/inittab file) is scanned only when init is initially invoked. init uses this entry to determine which run level to enter initially.

Open /etc/inittab file:

# vi /etc/inittab
Find out this entry:
is:3:initdefault:

Change is:3 to number you want, don't use S, 0, 6 ;). Save file.



* Only init states 0, 1, 5, 6, and S can be reached using shutdown.

Make changes to .bash_profile and need to update the current session?

$ source .bash_profile


With the above command, the user does not have to logout.

How to skip a service while starting in HP-UX

During the HP-UX OS booting,if you want the service/daemon need to be skipped  press crtl + backslash.

Most of us tried pressing ctrl + c, that wont work during the booting

18 January 2010

Symbolic links

namei can be used to trace the endpoint of a cascaded symbolic link

Eg.,

$ namei /dev/cdrw
f: /dev/cdrw
 d /
 d dev
 l cdrw -> scd0
   b scd0
$

SELinux....

Most of the Linux admins especially working on RedHat used to disable this option during installation ofcourse includes me as well....But later i realised the feature it offers.

Today much attention has been paid to network security,data security and computing security using various products available in the market but none of us are realizing the local exploit(Malware/Malicious) is a big one than the rest of the things.

SELinux takes care of control this local exploit....in other words its a kind of access control mechanism.


Is that is the only reason we need this....or do we have a flaw in the existing access control system.

Inherent flaw in the traditional permissions model is DISCRETION.I.e.,Owner of a particular file can change the permissions at his own will which might result in security breach.

By contrast,SELinux implements Mandatory Access Control(MAC) where access control decisions are not at the discretion of individual users or even system administrators.

22 December 2009

HP-UX Boot process


HP-UX OS Boot Process - PA-RISC Machines

19 January 2009

Fault tolerance for NIC

More and more data centers are in the process of setting up unmaned data centers.Admins are trying their best to have a fault tolerance solution for each software and Hardware component.
Here is a fault tolerance soultion for a Network interface via bonding in Linux

1.Create a file ifcfg-bond under /etc/sysconfig/network-scripts where is the binding number.
2.cat ifcfg-bond0

DEVICE=bond0
BOOTPROTO=none
ONBOOT=yes
NETWORK=192.168.41.0

NETMASK=255.255.255.0
IPADDR=192.168.41.250
USERCTL=no


3.Network interfaces to be bound together must be configured by adding MASTER= and SLAVE= directives to their configuration files.

4.Configuration files for the two interface files

DEVICE=eth<0/1>
BOOTPROTO=none

ONBOOT=yes
MASTER=bond0

SLAVE=yes
USERCTL=no

5.Configuring alias in modprobe.conf
alias bond0 bonding

options bond0 milmon=80 mode=1

modprobe to activate the aliases and restart the network service.

6. Now bond0 will be up.Output of ifconfig will show the same ip-address for bond0,eth0 & eth1.

27 August 2008

How to list the contents of the EFI directory on hp-ux IPF systems?

First find the default boot device using the setboot command
# setboot
Primary bootpath : 0/4/1/0.0.0.7.0
HA Alternate bootpath : 0/0/2/0
Alternate bootpath : 0/4/1/0.0.0.6.0
Autoboot is ON (enabled)#


Find the corresponding dirver for the Hardware path using ioscan
# ioscan -funC disk

disk 39 0/4/1/0.0.0.6.0 sdisk CLAIMED DEVICE HP DG146ABAB4
/dev/dsk/c17t6d0 /dev/dsk/c17t6d0s2 /dev/rdsk/c17t6d0 /dev/rdsk/c17t6d0s2
/dev/dsk/c17t6d0s1 /dev/dsk/c17t6d0s3 /dev/rdsk/c17t6d0s1 /dev/rdsk/c17t6d0s3
disk 40 0/4/1/0.0.0.7.0 sdisk CLAIMED DEVICE HP DG146ABAB4
/dev/dsk/c17t7d0 /dev/dsk/c17t7d0s2 /dev/rdsk/c17t7d0 /dev/rdsk/c17t7d0s2
/dev/dsk/c17t7d0s1 /dev/dsk/c17t7d0s3 /dev/rdsk/c17t7d0s1 /dev/rdsk/c17t7d0s3
#


List the contents of EFI shell.This can be useful to compare root and root mirror disks.

# lifls -l /dev/rdsk/c17t7d0s2
volume ISL10 data size 7984 directory size 8 06/10/27 14:23:07
filename type start size implement created
===============================================================
ISL -12800 584 242 0 06/10/27 14:23:07
AUTO -12289 832 1 0 06/10/27 14:23:07
HPUX -12928 840 1024 0 06/10/27 14:23:07
PAD -12290 1864 1468 0 06/10/27 14:23:07
LABEL BIN 3336 8 0 08/07/01 05:19:23#