Linux System Admin


Network transfer the image directory
------------------------------------

server-end: cd {src_dir} ; nc -l -p 2000 {remote_client} |tar -xvhf -

client-end: cd {dst_dir} ;  tar chf - {transfer_dir} | nc {remote_server} 2000

or use rsync

rsync -az -e ssh {user}@{server}:{src_dir} {local_dst_dir}

==============

Clone HD under Linux/Network
----------------------------

if you can pull out the HD from other machines and plug into the one you have already installed Linux, you only need to boot from CD, then run command (assuming the new HD is hdb, and hda and hdb are the same geometry)

dd if=/dev/hda of=/dev/hdb

if you cannot pull out the HD, you can boot both machines from CD, setup correct network addresses for them, then you need a small utility `netcat' to duplicate the HD. You can compile the binary of netcat and save it on CD (not sure if Knoopix has already included it).  On the machine you have NOT setup linux (hostA), execute command:

nc -v -w 120 -l -p 1234 | gzip -dc | dd of=/dev/hda

on the machine you have setup linux (hostB), execute command:

dd if=/dev/hda bs=512 | gzip -c | nc -v -w 60 hostA.ip 1234

also..

I need to clone one of my machines to about 10 other ones.  And because of the level of customization, it would take forever to do by hand.  So, I downloaded Tom's root boot floppy from http://www.toms.net.  The machine I needed to clone was booted in read-only mode, it had an ip of 10.10.220.53. I then booted the other machine with Tom's root boot disk and gave it the ip 
10.10.220.21.  On the one I wanted to clone to, I did:

nc -l -n -v -p 6666 > /dev/sda

On the machine I wanted to clone from, I did:

cat /dev/sda | nc -n -v 10.10.220.21 6666

After a couple of hours, the command finished.  I unplugged the network cable from the new machine (since it was a clone with the same ip as the other one), and rebooted.  It cloned the MBR, the partition table, and all of the data.  The machine seems to work perfectly.  I changed the ip on it, and stuck it into production and it's been performing flawlessly all morning.

==============

to check sed version: rpm -q --qf "%{NAME} %{ARCH}\n" sed

rpm will check for dependency, include both dependent packages if necessary

i.e. rpm -Fvh i686/glibc* i386/glibc*

i.e. -ivh for installation, -qa to list all

===============

In /etc/raidtab

===============

raiddev /dev/md0

raid-level      0

nr-raid-disks   2

persistent-superblock 1

chunk-size            4

device          /dev/sdb0

raid-disk       0

device          /dev/sdb1

raid-disk       1

device          /dev/sdb2

raid-disk       2

device          /dev/sdb3

raid-disk       3

device          /dev/sdb4

raid-disk       4

Then

=>mkraid [--really-force] /dev/md0

=>cat /proc/mdstat

=> /dev/md0 is now ready to be formatted, mounted, used and abused.

*>Disk Druid or fdisk,

*>In fdisk to create RAID partition, must create partition type fd (Linux RAID)

*>best performance when partitions within a given RAID array span identical cylinders on different drives.

Start/Stop RAID

===============

raidstop /dev/md0

or

raidstart /dev/md0

Good supplement tools

=====================

http://www.cse.unsw.edu.au/~neilb/source/mdadm/.

Utilities

=========

-ntsysv ; need to restart individual services/server

-service httpd/sshd start/stop/restart/status

-service httpd reload

-service xinetd restart ; /etc/xinetd.conf ; /etc/xinetd.d/

-diskcheck ; /etc/diskcheck.conf

Create ext3 FS

==============

/sbin/fdisk /dev/hda

/sbin/mkfs -t ext3 /dev/hda1

pico -w /etc/fstab

-> /dev/hda1  ext3   default  1  2

/sbin/tune2fs -l /dev/hda1 {check the volume}

User Management

===============

shell: useradd/mod/del ; groupadd ; gpasswd -a  

X-Win: redhat-config-users

*> prevent new created file assigned as users' default private group

*> -chmod 2775  & set default umask 002

-> Install Shadow & MD5 password ; /etc/login.defs

-> shadow-utils package provides pwconv,pwunconv,pwck,grpck

*> pico .bash_profile ; source .bash_profile

Important Directory

===================

/var/lib/rpm/

/etc/sysconfig/

Filesystem Hierarchy Standard (FHS) - http://www.pathname.com/fhs

-/etc reserved for configuration files that are local to machine

-/sbin essential for booting otherwise will put in -/usr/sbin/ or -/usr/local/sbin/

-/bin essential for booting otherwise will put in -/usr/bin/

-/lib only libraries that need to execute the binaries in /bin and /sbin

-/usr shared across whole site, on its own partition mountable read-only

-/usr/local/ use installing software locally, safe from system updated

-/var/ use for variable data files include spool/log/transient/temporary

-/opt an area for large, static application packages to store

TIPS

====

Mount Win98 : mount -t vfat /dev/hda1 /mnt

: in fstab - /dev/hda1 /mnt/windows vfat noauto,owner,users 0 0

RedHat Linux 7.3 with a custom 2.4 kernel offers:

-Kernel source is /usr/src/linux-2.4

-Support for the ext3 filesystem.

-Multi-processor (SMP) support.

-USB support.

-Preliminary support for IEEE 1394

Labels: cheatsheet, linux.