Showing posts with label Unix. Show all posts
Showing posts with label Unix. Show all posts

Thursday, June 12, 2008

Managing File System Inconsistencies and Disk space in UNIX\Solaris:

This article explains how to manage disk space and file system inconsistencies. In general, Unix file system uses a set of tables to keep track of used inodes and available blocks. Inconsistencies will arise, for example, abrupt termination of the operating system. The reason for inconsistencies are listed below

1. Software error in the kernel.

2. Turning off the system without proper shutdown procedure.

3. Defective hardware, such as problem with the disk.

fsck Command:

Used to find the inconsistencies and repair them.

Syntax:

#fsck {option} {device}

Options

-F {fstype} – limit to check the specified file system.
-m – check but do not repair, for checking the status of the file system.

df Command:

Used to monitor disk space usage at file system level, also used to determine the following,

1. The amount of disk space occupied by currently mounted or unmounted file systems.
2. The total amount of the used and available space.
3. The fraction of the file system’s total capacity that has been used.

Syntax:

#df {-F fstype} {option} {file system}

du Command:

Used to get the report on disk usage at the directory and file level, also used to determine the following,

1. Total space allocated to a directory.
2. Total space allocated to a directory subtree.
3. Total space allocated to a non-directory file.

Syntax:

#du {option} {file}

quot Command:

Used to get the report on disk usage by user name, if you want to know how much space is being used by each user on a given file system, can make use of this command.

Syntax:

#quot {option} {filesystem}

Hope this is informative.

Thanks

Logu

Logu_microsoft@hotmail.com
91-98414 99143

Managing Hard and Symbolic Links in Solaris/Unix:

This article explains the purpose and usage of hard and symbolic links. A link is a file that points to another file. There are two kinds of link available

1.Hard Link:

a. A Hard Link is a pointer to a file that is indistinguishable from the original file.

b. Any changes made to a file are effective regardless of the name used to refer to the file – the link file or the original file name.

c. The link and the file are on the same file system because both have the same inode number.

d. A hard link can only point to a file, not to a directory.

e. You cannot create a hard link file without having the existing file.

f. The hard link file will consume the same amount of the disk as that of the original file.

g. If you delete the link file, the other will exist and the reverse is also applicable.

Syntax of the Hard Link file:

To create a hard link file,
#ln {source} {Target}

To remove the same file,
#rm {linkfile}

2.Symbolic Link:

a. A Symbolic Link is an indirect pointer to a file and it can span the file systems.

b. A symbolic link can be pointed to either file or directory.

c. You can create a symbolic link without having the existing file.

d. The symbolic link file will have the different inode number.

e. The symbolic link file will just have the details of the pointer information of the original file alone. Hence it won’t consume the same space as that of the original file.

f. It is just like a shortcut in the Windows.

g. If you delete the shortcut link file, the original file will exist. The reverse is obviously not applicable. It is better to clean up the shortcut files i.e, symbolic file before deleting the source file.

Syntax of the Symbolic Link file:

#ln –s {Source} {Target}

Thanks

Logu

Logu_microsoft@hotmail.com
91-98414 99143

Directory Hierarchy in Solaris:

This articles the directory hierarchy structure in the Solaris file systems. Just like other OS, Solaris organized into directories and directories organized into a hierarchy called a directory tree. The understanding of the directories in Solaris file system is more important.

1./bin - symbolic link to the /usr/bin directory.

2./dev – Contains logical devices names for the devices.

3./device – device related files controlled by the file system: devfs.

4./lib – Contains shared libraries such as SMF executables.

5./etc – administrative and configuration files.

6./export – Commonly used to hold user home directories.(you can define as per your wish)

7./home – Default mount point for user home directories.

8./mnt – Default mount point used to temporarily mount file systems.

9./sbin – Contains system administration command s and utilities.

10./tmp – Contains temporary files that are deleted when the system is rebooted.

11./usr – UNIX system resources, Holds OS commands and programs.

Thanks

Logu

Logu_microsoft@hotmail.com
91-98414 99143

Installation of Solaris 10:

This article explains the step by step procedure for installing the Solaris 10 on the SPARC machine and X86 machines. The installation of Solaris 10 in X86 is somewhat similar to the deployment of the Linux. Installation of Solaris 10 in SPARC machine is bit different.

Hardware Requirements:

Before starting the installation process, all the hardware components must be checked for the hardware compatibility first. Please make sure all the needed drivers available for the X86 machines.

Installation in the X86 Machine:

1.Insert the Solaris 10 CD or DVD into the appropriate drive.

2.Set the Boot priority as required in the BIOS.

3.On the initial, Solaris Booting Systems. Decide whether you need to modify the device settings.
a.Install device driver or install time updates.
b.Disable ACPI – Advanced Configuration and Power Interfaces.
c.Set up a serial console.
d.Reset the default boot device.

4.Select the installation type
a.Solaris Interactive. (Default GUI)
b.Custom Jumpstart.
c.Solaris Interactive Text (Desktop session).
d.Solaris Interactive Text (Console session).

5.Two scenario to proceed
a.If it detects all the devices, then proceed to step 7.
b.If the problem in detecting the keyboard, monitor and mouse, go to step 6.

6. Two ways to go from here
a.Configure the keyboard, Monitor and Mouse as per the instruction on the screen.
b.If you want to do the text installation, press f4 to skip the steps related to the GUI display and will let directly to the step 7.

7.Select the language.

8.Please precede the installation and configure the disk space for the file system. Can use the automatic partitioning or can do the manual partitioning as well. The recommended disk partitioning is /boot (100 MB), /swap (twice the RAM) and / (remaining space).

9.Select the default package list or select the package manually.

10.Answer any additional configuration questions, if you are prompted.

11.After the installing the package, it will automatically reboot.

Installation in the SPARC Machine:

1.Insert the Solaris 10 CD or DVD into the appropriate drive.

2.Set the Boot priority as required in the BIOS.

3.Start the Solaris installation program by booting through CD / DVD
a.For GUI installation, type the below command in the ok prompt
Ok boot cdrom
b.For Text installer in a desktop session, type the below command in the ok prompt
Ok boot cdrom –text
c.For Text installer in a console session, type the below command in the ok prompt
Ok boot cdrom –nowin

4.Select the language.

5.Answer the system configuration questions such as hostname, IP address and others.

6.Select the reboot option at the end of installation and specify the media you are using to install.

7.Please precede the installation and configure the disk space for the file system. Can use the automatic partitioning or can do the manual partitioning as well. The recommended disk partitioning is /boot (100 MB), /swap (twice the RAM) and / (remaining space).

8.Select the default package list or select the package manually.

9.Answer any additional configuration questions, if you are prompted.

Please revert if you have any issue while deploying the package.

Thanks

Logu

Logu_microsoft@hotmail.com
91-98414 99143

Monday, June 9, 2008

Evolution/History of UNIX:

This article gives information on the history and evolution of the UNIX. UNIX was the first operating system; it also has been a trail blazer in the field of operating systems. Other OS like windows, Linux and others have adopted the features first proposed by and implemented in UNIX. UNIX is not an operating system that was built by one company with a wonderful marketing department.

UNIX, pronounced as yoo-niks, is not the name of one operating system; it refers to a family of operating systems.

Brief History of UNIX:

1. The roots lie in Comprehensive time sharing system CTSS developed by Corbato at MIT in the early 1960s.
2. In 1969, emergence of UNIX at the AT & T Bell labs.
3. After several hits, first BSD Berkeley Software Distribution version released in 1978.
4. In 1982, Sun Microsystems released first UNIX workstation based on the BSD flavor of UNIX.
5. Finally in the year, SPARC station1 introduced.

UNIX Flavors:

UNIX is the oldest OS that pioneered several OS concepts used by other OS such as Microsoft DOS and Microsoft Windows. Originally, Bell Lab distributed UNIX along with the source code so that, anybody could modify and customize the OS to meet specific needs. The following are the different flavors of UNIX with Vendor and Chip architecture.

1. Solaris – Sun Microsystems – SPARC, X86
2. HP-UX – Hewlett Packard – IA 64 and HP PA-RISC
3. Irix- Silicon Graphics – MIPS
4. AIX – IBM – PowerPC
5. UNIXWare – SCO/Caldera – Xeon, Pentium, X86
6. Linux – Freeware – Alpha, SPARC, PowerPC and Intel

Characteristics of UNIX:

1. UNIX is built from small components; each component does one job and does it well.
2. Support for virtually all n/w protocols.
3. Many flavors of UNIX.
4. Wide variety of s/w available for UNIX.
5. Open standard and open source.
6. Multitasking and multiprocessing.

The underlying philosophy of UNIX may be classified as independence, interconnection and innovation.

Hope the above information is useful.

Thanks

Logu

Logu_microsoft@hotmail.com
91-98414 99143

Saturday, November 24, 2007

Sendmail

Hi friends

This article explains the basic configuration of sendmail. In this example, i use the sendmail package from the RHEL 5 and use mailserver.example.com(192.168.10.2) and dns1.example.com(192.168.10.1) as fqdn for this mail server and dns server. Lemme give you the step by step procedure for building the sendmail server.

1. Install the sendmail package:

# yum install sendmail

2. Check the Existence of package:

# rpm -qa | grep sendmail
sendmail-cf-8.13.8-2.el5
sendmail-.13.8-2.el5

3. Services:

# chkconfig --level 345 sendmail on
# service sendmail start|stop|restart|status or
# /etc/init.d/sendmail start|stop|restart|status

4. Sendmail configuration file :

# /etc/mail/sendmail.cf //main sendmail config file
# /etc/mail/sendmail.mc //file used to edit and push the updates to the main file

All configuration changes can be done only at /etc/mail/sendmail.mc and with the help of macro push it to the file /etc/mail/sendmail.cf

5. Macro m4 :

To find the macro path
# locate cf.m4
/usr/share/sendmail-cf/m4/cf.m4
#m4 /usr/share/sendmail-cf/m4/cf.m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
and then restart to make the changes to take effect.

6. Disabling line in /etc/mail/sendmail.mc file:

These statements are disabled by dnl commenting.
dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')
dnl # DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')

This statement is incorrectly disabled:
# DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')

This statement is active:
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')

7. DNS Server

The proper implementation of DNS server is important before configuring the sendmail. Please test the dns name resoultion with the tools like nslookup, host and dig tool.In this eg, consider the dns1.example.com (192.168.10.1) as primary dns server.

# host dns1.example.com
dns1.example.com has address 192.168.10.1
#host mailserver.example.com
mailserver.example.com address 192.168.10.2

8. Check /etc/resolv.conf file:
make sure /etc/resolv.conf file contains the correct dns server details
# vi /etc/resolv.conf
localdomain example.com
nameserver 192.168.10.1

9. Check /etc/hosts file:
# vi /etc/hosts
127.0.0.1 mailserver.example.com localhost.localdomain localhost mailserver

10. Edit /etc/mail/sendmail.mc file:

First, using dnl disable the line like
dnl "DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')"

Second, disable the smarthost option
dnl define(`SMART_HOST',`mail.my-site.com')

Use macro and restart the sendmail daemon

Check the local NIC card is enabled for receive all packets by
# netstat -an | grep :25 | grep tcp
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN

11. Edit /etc/mail/access file:

# vi /etc/mail/access
localhost.localdomain RELAY
localhost RELAY
127.0.0.1 RELAY
192.168.30 REJECT // rejects the mails from 192.168.30.0 n/w
192.168.20.5 RELAY // relay the mails from the host 192.168.20.5
192.168.10 RELAY // relay the mails from 192.168.10.0 n/w
example.com RELAY // relay the mails from the suffix example.com

12. Edit /etc/mail/local-host-names file:

add hostnames or domain names for which the sendmail accept mail for local delivery.


# vi /etc/mali/local-host-names
example.com
otherdomain.com

13. Edit /etc/mail/virtusertable file:

# vi /etc/mail/virtusertable
// first column is the target email address
// second column may be created user mailbox in the mailserver, aliase name or groupname created in the /etc/aliase or even remote email address.

logu@example.com logu // logu - local user
sonia@example.com sonia
test@example.com test
testaliase@example.com testaliase // testaliase entry created in /etc/aliase
@example.com error:nouser User Unknown // answer for other than the above user

14. Edit /etc/aliases file:

add the below lines at the bottom of the file

# vi /etc/aliases
..........
..........

#setting new aliase
testaliase: logu,test

As per virtusertable above, the mail to testaliase@example.com will go to logu@example.com and sonia@example.com.

15. Configuring POP3/IMAP :
By configuring the sendmail for pop3/imap, we will be able to acces mail from thunderbird, evolution, Outlook, etc.

First, check the existence of dovecot and services using

# chkconfig --level 345 dovecot on
# service dovecot start|stop|restart|status or
# /etc/init.d/dovecot start|stop|restart|status

Second, edit the /etc/dovecot.conf file

# vi /etc/dovecot.conf
........
//search for protocols
//protocols = imap imaps pop3 pop3s
protocols = pop3 // configure pop3 or imap as per your need
........
........

Third, test the NIC listening for pop3 using,

# netstat -a | egrep -i 'pop|imap'
tcp 0 0 *:pop3 *:* LISTEN

Fourth, use Outlook or any client tool to test the mail flow.

16. Troubleshooting via telnet:

Please refer this article in my blog.

Thanks
Logu
logu_microsoft@hotmail.com
91-98414-99143

Sunday, November 18, 2007

Linux/UNIX Basic Commands - Part 2

Hi Friends,

Here is the continuation of the topic Linux/UNIX Basic Commands Part 1.

SSH:

ssh user@host – connect to host as user
ssh -p port user@host – connect to host on port as user
ssh-copy-id user@host – add your key to host for user to enable a keyed or passwordless login

Searching:

grep pattern files – search for pattern in files
grep -r pattern dir – search recursively for pattern in dir
command | grep pattern – search for pattern in the output of command
locate file – find all instances of file

Compression:

tar cf file.tar files – create a tar named file.tar containing files
tar xf file.tar – extract the files from file.tar
tar czf file.tar.gz files – create a tar with Gzip compression
tar xzf file.tar.gz – extract a tar using Gzip
tar cjf file.tar.bz2 – create a tar with Bzip2 compression
tar xjf file.tar.bz2 – extract a tar using Bzip2
gzip file – compresses file and renames it to file.gz
gzip -d file.gz – decompresses file.gz back to file

Network:

ping host – ping host and output results
whois domain – get whois information for domain
dig domain – get DNS information for domain
dig -x host – reverse lookup host
wget file – download file
wget -c file – continue a stopped download

Installation

Install from source:
./configure
make
make install
dpkg -i pkg.deb – install a package (Debian)
rpm -ivh pkg.rpm – install a package (RPM)
yum install pkgname - using the yum tool

Shortcuts:

Ctrl+C – halts the current command
Ctrl+Z – stops the current command, resume with fg in the foreground or bg in the background
Ctrl+D – log out of current session, similar to exit
Ctrl+W – erases one word in the current line
Ctrl+U – erases the whole line
Ctrl+R – type to bring up a recent command
!! - repeats the last command
exit – log out of current session

Thanks

Logu
logu_microsoft@hotmail.com
91-98414-99143

Linux/UNIX Basic Commands - Part 1

Hi friends

Please find the Basic linux/Unix commands below for your reference

File Commands:

ls – directory listing
ls -al – formatted listing with hidden files
cd dir - change directory to dir
cd – change to home
pwd – show current directory
mkdir dir – create a directory dir
rm file – delete file
rm -r dir – delete directory dir
rm -f file – force remove file
rm -rf dir – force remove directory dir *
cp file1 file2 – copy file1 to file2
cp -r dir1 dir2 – copy dir1 to dir2; create dir2 if it doesn't exist
mv file1 file2 – rename or move file1 to file2 if file2 is an existing directory, moves file1 into directory file2
ln -s file link – create symbolic link link to file
touch file – create or update file
cat > file – places standard input into file
more file – output the contents of file
head file – output the first 10 lines of file
tail file – output the last 10 lines of file
tail -f file – output the contents of file as it grows, starting with the last 10 lines.

System Info:

date – show the current date and time
cal – show this month's calendar
uptime – show current uptime
w – display who is online
whoami – who you are logged in as
finger user – display information about user
uname -a – show kernel information
cat /proc/cpuinfo – cpu information
cat /proc/meminfo – memory information
man command – show the manual for command
df – show disk usage
du – show directory space usage doesn't exist
free – show memory and swap usage
whereis app – show possible locations of app
which app – show which app will be run by default
locate filename - to find the location of the file
find / -name filename or namespace - to find the file with some namespace

Process Management:

ps – display your currently active processes
top – display all running processes
kill pid – kill process id pid
killall proc – kill all processes named proc *
bg – lists stopped or background jobs; resume a stopped job in the background
fg – brings the most recent job to foreground
fg n – brings job n to the foreground

File Permissions:

chmod octal file – change the permissions of file to octal, which can be found separately for user, group, and world by adding:
  • 4 – read (r)
  • 2 – write (w)
  • 1 – execute (x)
Examples:
chmod 777 – read, write, execute for all
chmod 755 – rwx for owner, rx for group and world
For more options, see man chmod.

Please read Linux/UNIX Basic Commands - Part 2 also.

Thanks

Logu
logu_microsoft@hotmail.com
91-9841499143