Sunday, June 3, 2007

Linux User Guide (1)

File links:

Hard link: $ln source dest

By using hard link, all links and original file have the same inode.

Using ls command to list link information:

$ls –i test

$ls –l test : second column shows the number of links

Symbolic links: $ln –s source dest

For symbolic link, all links have different inode, user can create a symbolic link to a file that doesn’t exist.

Job Control:

Commands: ps, ps –aux, fg, bg, CTRL-Z(suspend job), jobs, kill %i (after % is job number)

Using /dev/null to redirect useless output data.

Stop and restart jobs:

CTRL-Z: suspend job;

$fg: restart job in the foreground;

$bg: restart job in the background;

$&: start job as background process.

Booting the system:

1. Make boot device manually

$rdev kernel-name root-device à to make boot partition

$rdev /vmlinuz /dev/hda2

$cp /vmlinuz /dev/fd0

2. Using LILO

Win95 installer will overwrite LILO MBR, before install win95, create boot disk for linux, install win95, then reboot with linux floppy, run /sbin/lilo, reconfigure the system.

Using $sys a: c: /mbr to overwrite LILO.

Shutting down:

$shutdown hh:mm:ss(time) warning-message

$shutdown now

$shutdown –r 20:00 we are shutting down -r means reboot the system after shut down.

$halt

The /etc/inittab file:

System boot, kernel mount the root file system, executes init that takes /etc/inittab as the parameter file, spawns a lot of children processes.

Managing the file system:

1. mounting the file system
$ mount –av

2. /etc/fstab file
File systems support by linux: ext2, ext, minix, xia, umsdos, msdos, proc, iso9660, xenix, sysV, coherent, hpfs
Linux uses ext2 as natural file system, swap partition has a mount point of none.
$ swapon –a
$ mount –t ext2 /dev/hda3 /usr

3. Device Diver name:
hdx: IDE driver sdx: SCSI driver
fdx: floppy driver stx: SCSI tape driver
scdx: SCSI CD-ROM driver

/dev/hda: the whole first IDE driver
/dev/hda1: the first partition in the driver
/dev/hda2: the second partition in the driver

/dev/hda: IDE, master, primary
/dev/hdb: IDE, slave, primary
/dev/hdc: IDE, master, secondary
/dev/hdd: IDE, slave, secondary

Checking the file sytem:
$e2fsck –av /dev/hda2

$efsck $xfsck $fsck
If e2fsck reports it performed repairs on a mounted file system, you must reboot the system immediately.

Using a swap file:

Create a swap file: $dd if=/dev/zero of=/swap bs=1024 count=8208 : create one 8M swap file

$mkswap /swap 8208

$sync

$swapon /swap

Drawback using a swap file:

1. Performance will not be as good as swap partition whose blocks are contiguous, I/O requests are made directly to the device;

2. System has more chance to corrupt for large swap file.

Good point:

1. User can use swap file for the actions that need more swap space, and after that delete it.


Latest Posts