Showing posts with label Network Administration-Linux. Show all posts
Showing posts with label Network Administration-Linux. Show all posts

Sunday, August 3, 2008

Mounting Devices on Linux

Before accessing a hard disk or any other storage medium in Linux or UNIX they should be mounted. Note that there is no concept of mounting in windows platforms. Mount allows you to merge two file systems. Mounting of file systems are done with mount command.


The figure shows the unix file system before mounting and after mounting.

The Mount command
Mount command has many options and hence little complex. But most of the time you will be able to mount file systems easily with few options. Mount command takes following general format.
mount -t filesystem_type -o mount_options /dev/device_file /mnt/mount_point

Usually we don't specify t option because kernel can usually identify the file system type by looking at partition table. The o options are also optional.We can unmount a device by it's device file name or by the mount point.
#umount /dev/sda
#umount /mnt/flash

Mounting a CD ROM/DVD ROM
Following command tells the kernel to auto detect (t auto) file system type and mount the device /dev/cdrom on /mnt/cdrom.
#mount -t auto /dev/cdrom /mnt/cdrom

If mounting fails, check whether you have a /mnt/cdrom directory, you can do it by using ,
#ls -l /mnt/cdrom

If it is not there then create it,
#mkdir /mnt/cdrom

Now try the mount command if it fails again check whether you have /dev/cdrom. If it does not exist, try
#dmesg | grep -i cdrom to find out the device file.

Now you can retry the command assuming that /dev/hdb is your CD ROM drive.
#mount -t auto /dev/hdb /mnt/cdrom.

Mounting a floppy, USB drive and windows partition
You can mount floppy as root user with following command.
#mount -t auto /dev/fd0 /mnt/floppy

If you get any error follow steps given earlier.
For USB drive, as root user
#mount -t vfat /dev/sda1 /mnt/usb

If you get any error follow steps given above. If you still get error saying that /dev/sda is not a valid block device then check whether the disk is partitioned. You can do this with fdisk command.
#fdisk -l /dev/sda

If you still find problems restart your hotplug sub system and remove and reinsert the device.
#/etc/init.d/hotplug restart

When mounting DOS/Windows partitions first make sure whether it is fat formated or ntfs the following commands can be used.
#mount -t vfat /dev/hda1 /mnt/windows
#mount -t ntfs /dev/hda5 /mntwinxp

If you want to mount so that all users can read and write, you may want to try:
#mount -t vfat -o user,rw,exec,umask=000 /dev/hda1 /mnt/c

“-o user,rw,exec,umask=000” gives every body all the permission to all the files on your partition.

Mounting a loopback device
Create a file containing all zeros. A 10MB file.
#dd if=/dev/zero of=myblock.img bs=1k count=1024

Now attach this to loop back device and format.
#losetup /dev/loop0 myblock.img
#mkfs -t vfat /dev/loop0

Now we can mount the device by using the file as the device.
#mount -o loop myblock.img /mnt/loop

How can you allow a normal user to mount a device?
All you have to do is adding an entry to the /etc/fstb file It has the following format.
<file> <mount> <type> <options> <dump> <pass>
/dev/sda1 /mnt/usb vfat user,rw 0 0

Monday, June 23, 2008

Sendmail

Sendmail is a mail transfer agent (MTA) that is a well-known project of the open source, free software and Unix communities, which is distributed both as free software and proprietary software. Its also called the mail server daemon. Other mail server daemons include qmail, postfix, exim, mmdf, smail etc. server daemons looks after the receiving incoming mail and delivers outgoing mail.

Sendmail configuration files
All sendmail related configuration files have to be put in /etc/mail directory.

1)/etc/mail/access

It specifies what hosts or IP addresses have access to the local mail server and what kind of access(OK, REJECT,RELAY) they have.
OK - allowed to send mail to the host as long as mail's final destination is the local machine.
REJECT - reject for all mail connections
RELAY - allowed to send mail for any destination through this server.
e.g.
cyberterror.com     550 we dont expect mail from you
a.source.of.spam     REJECT
cyberspammer.com     OK
128.32          RELAY

2)etc/mail/aliases
This database contains a list of virtual mailboxes that are expanded to other user(s), files, programs or other aliases.
e.g
root: ajantha
webmaster:kamal,lal
customers: :include: /etc/mail/lists/customer-list

The last alias causes how to keep a list of users for an aliases in an external file.

3)/etc/mail/local-host-names
Consist list of host names that sendmail is to accept as the local mail host. if the mail server was to accept mail for the domains cmb.ac.lk and ucsc.cmb.ac.lk the above file will contain:
cmb.ac.lk
ucsc.cmb.ac.lk

4)/etc/mail/sendmail.cf
It controls the overall behavior of sendmail. The master sendmail configuration file can be built from m4 macros.

5)/etc/mail/virtusertable
This maps email addressse for virtual domains and mailboxes to real mail boxes. The mail boxes can be local, remote, aliases defined.
e.g
info@msc.cmb.ac.lk ajantha
info@bit.cmb.ac.lk saman







Monday, June 9, 2008

Using SSH

SSH is a program to log into another computer over a network, to execute commands in a remote machine, and to move files from one machine to another. It provides strong authentication and secure communications over insecure channels. SSH is most useful when logging into a UNIX machine from another machine where the traditional telnet and rlogin programs would not provide password and session encryption.

Now we'll take a look at some basic SSH commands in networking.
To login to a remote machine running sshd server you can use the any of the following formats.

# ssh -l remote_user host_name_or_ip
# ssh remote_user@host_name_or_ip
e.g.
# ssh -l root 192.248.16.100
# ssh bud@server.cmb.ac.lk

To execute a command on the remote machine without logging in explicitly you can use,
# ssh -l remote_user host_name_or_ip remote_command
e.g.
# ssh -l bud@192.248.16.100 /usr/bin/x11/xclock
It starts the xclock application in the remote machine.

To ftp securely you can use sftp.
e.g
# sftp bud@192.248.16.100

sftp> cd downloads - Used to change directory
sftp>mput *.rpm - Used to upload multiple files
sftp>mget httpd* - Used to download multiple files
sftp>help - See a list of commands

To copy files from one host to another try
# scp [-r] source user@remote_host:target
e.g.
# scp bud@192.248.16.100:/etc/lilo.conf /tmp

Still there is SSH server and client configuration and do you knw how to configure passwordless SSH login?
http://www.keepandshare.com/doc/view.php?id=624904&da=y