Wednesday, May 27, 2009

Understanding your (Red Hat Enterprise Linux) daemons

The term 'daemon' is used for processes that performs service in background.

rather than under the direct control of a user.

Unix processes works either in foreground or background. A process running in foreground interacts with the user in front of the terminal (makes I/O), whereas a background process runs by itself.

In a Unix environment, the parent process of a daemon is often (but not always) the init process (PID=1). Processes usually become daemons by forking a child process and then having their parent process immediately exit, thus causing init to adopt the child process. This is a somewhat simplified view of the process as other operations are generally performed, such as disassociating the daemon process from any controlling tty.

Monday, May 25, 2009

Samba configuration

Samba configuration

Prepare the system

If you want LDAP,

yum install openldap-clients perl-LDAP

Check LDAP's access,

ldapsearch -H ldap://LDAP_SERVER -x -b "dc=example,dc=com"

Configuration

Almost from scratch,

mv smb.conf smb.conf.dist

sed -e '/^#/d;/^[[:space:]]*$/d;/^;/d' smb.conf.dist > smb.conf

and adapt it to your needs,

[global]

workgroup = SAMBA2

security = user

load printers = no

username map = /etc/samba/smbusers

passdb backend = ldapsam:ldap://10.91.4.191

ldap suffix = dc=example,dc=com

#ldap machine suffix = ou=machines

#ldap user suffix = ou=users

#ldap group suffix = ou=groups

ldap admin dn = cn=admin,dc=example,dc=com

ldap delete dn = no

#domain logons = yes

#enable privileges = yes

#ldap passwd sync = yes

# domain logons = Yes

# domain master = Yes

[homes]

browseable = no

writable = yes

Check the configuration,

testparm

Configure the LDAP admin password,

smbpasswd -w examplepassword

ERROR: failed to setup guest info.

- Check secrets.tdb.

- Do,

net getlocalsid

net getlocalsid

pdbedit -L

pdbedit -Lv guest

- Check LDAP (ldapsearch uid=guest)

Ref. lists.samba.org/archive/samba/2006-June/121701.html

On the client

Check the service remotely,

smbclient -L SERVER_IP

[root or ldap admin password]

Configure some mountpoint,

//SERVER_IP/folder /destfolder smbfs rw,user,uid=500,gid=500,username=USERNAME,password=PASSWORD 0 0

Note. this works to mount share from Windows machines too.

Samba printing references

Printer driver download : www.mail-archive.com/samba@lists.samba.org/msg31626.html

Samba & CUPS : www.samba.org/samba/docs/man/Samba-HOWTO-Collection/CUPS-printing.html

Samba / LDAP references

IDEALX Howto : download.gna.org/smbldap-tools/docs/samba-ldap-howto/

Another Howto : www.unav.es/cti/ldap-smb/smb-ldap-3-howto.html

Samba / LDAP : www.nomis52.net/?section=docs&page=samldap

Other troubleshooting references

readlist.com/lists/lists.samba.org/samba/3/15742.html

Friday, May 22, 2009

What is the difference between processes and threads?

The memory space, where a given application is executed is called - process. A Process is the memory set aside for an application to be executed in.

Within this process the thing, which is really executed is the thread.

The key difference is that processes are fully isolated from each other; threads share (heap) memory with other threads running in the same application.

Threads share the address space of the process that created it; processes have their own address.

Threads have direct access to the data segment of its process; processes have their own copy of the data segment of the parent process.

Threads can directly communicate with other threads of its process; processes must use inter-process communication to communicate with sibling processes.

Threads have almost no overhead; processes have considerable overhead.

New threads are easily created; new processes require duplication of the parent process.

Threads can exercise considerable control over threads of the same process; processes can only exercise control over child processes.

Wednesday, May 20, 2009

Differences Between Threads and Processes

Differences Between Threads and Processes
Differences Between Threads and Processes

Threads share the address space of the process that created it; processes have their own address.
Threads have direct access to the data segment of its process; processes have their own copy of the data segment of the parent process.
Threads can directly communicate with other threads of its process; processes must use inter-process communication to communicate with sibling processes.
Threads have almost no overhead; processes have considerable overhead.
New threads are easily created; new processes require duplication of the parent process.
Threads can exercise considerable control over threads of the same process; processes can only exercise control over child processes.
Changes to the main thread (cancellation, priority change, etc.) may affect the behavior of the other threads of the process, changes to the parent process does not affect child processes.

Both have an id, set of registers, state, priority, and scheduling policy.
Both have attributes that describe the entity to the OS.
Both have an information block.
Both share resources with the parent process.
Both function as independent entities from the parent process.
The creator can exercise some control over the thread or process.
Both can change their attributes.
Both can create new resources.
Neither can access the resources of another process.

Monday, May 18, 2009

What is proc file system?

/proc

- is a virtual file system ( files are not stored on disk ) which gives system information

- gives detailed information about kernel , hardware and running processes

- normally used to display process info , memory resources , hardware devices , kernel memory etc

- can be used to get or set kernel configuration

- can be used to modify kernel features

- modifications apply immediately

- Entries are not persisitant : modifications get reinitialized after a reboot

Saturday, May 16, 2009

New features in Linux kernels 2.6.28 and 2.6.29

New features in Linux kernels 2.6.28 and 2.6.29

Linux Kernel MapLinux kernel has in recent times seen numerous advances. And the latest versions of the Linux kernel namely 2.6.28 and 2.6.29 have some fabulous features in-built into them.

Topping over 10 million lines of code, the current day Linux kernel is no push over and is forming a serious threat to its competition.

Some of the features that are there in the more recent Linux kernels are as follows:

* New file systems - Linux kernel supports a new file system called Ext4. Ext4 supports large number of files of greater size and deeper directory structures. Another file system which is still in experimental mode but is soon going to be a choice for Linux users is the Btrfs file system which competes with ZFS in features.

* Better memory management for the Linux kernel graphics stack.

* Boot tracer - This is a feature in built into the new kernels, which will allow the developers to find possible ways in which they can further reduce the time taken for the Linux kernel to completely boot up.

* Freezer - This new feature helps you to easily migrate your operating system to a new host.

* Improved virtual memory scalability

* Disk improvements - Such as better support for solid state devices, improvements for ATA hard disks and so on. For instance, Linux kernel now provides protection against sudden jolts and shocks in ATA hard disks.

Thursday, May 14, 2009

The 7 Habits of Highly Effective People who are Linux Users

The 7 Habits of Highly Effective People who are Linux Users

1. Never login as root - This is redundant if you are using a Linux distribution such as Ubuntu which uses sudo to elevate a user temporarily to super user mode. Nevertheless a valid point.

2. Properly name your files - I usually stick with that but even if you have spaces in the names of your files, bash completion helps you in getting the names of the files right.

3. Place /home in its own partition - I concur with that wholeheartedly. Read this article to know more about partitions.

4. Proper crash management - Use xkill and the likes to close a misbehaving application.

5. Try out multiple distributions - You have got a whole lot of them to choose from.

6. Brush up your command line skills - Learn to use command line tools to accomplish complex tasks. It is a big time saver. Don't forget to pick up some bash scripting skills on the way.

7. And finally, always be ready to unleash the power within - in other words experiment.

Tuesday, May 12, 2009

Process and Threads

Understabding what exactly is meant by a process is truely important let me tell you what microsoft tells about the question what is a process?

processes

An executable program, such as Windows Explorer, or a service, such as MSTask.

Coming to the threads

threads

An object within a process that runs program instructions. Threads allow concurrent operations within a process and enable one process to run different parts of its program on different processors simultaneously.

/*

Now let me share with you my opinion a process is nothing much than a executible file. When i sat executible file and if you are using windows OS the first thing That must strike your brain any file on windows machine with .exe extension :-)

Imagine in your you are sitting and you switch on your computer you find that some have uninstalled ie browser now u have to download it and reinstall it , at present if u go to the task manager if u look for processes running on your machines u will not find ie listed since its not present on ur machine so remeber when i say process it just a an executable programme when it comes to windows its nothing much than .exe file

Now if at all u wanna have a process running on ur machine with t he name ie (internet explorer) all that u need to do is just execute the corresponding executible file

*/

Representation

In general, a computer system process consists of (or is said to 'own') the following resources:

  • An image of the executable machine code associated with a program.
  • Memory (typically some region of virtual memory); which includes the executable code, process-specific data (input and output), a call stack (to keep track of active subroutines and/or other events), and a heap to hold intermediate computation data generated during run time.
  • Operating system descriptors of resources that are allocated to the process, such as file descriptors (Unix terminology) or handles (Windows), and data sources and sinks.
  • Security attributes, such as the process owner and the process' set of permissions (allowable operations).
  • Processor state (context), such as the content of registers, physical memory addressing, etc. The state is typically stored in computer registers when the process is executing, and in memory otherwise.[2]

The operating system holds most of this information about active processes in data structures called process control blocks (PCB).

Any subset of resources, but typically at least the processor state, may be associated with each of the process' threads in operating systems that support threads or 'daughter' processes.

The operating system keeps its processes separated and allocates the resources they need so that they are less likely to interfere with each other and cause system failures (e.g., deadlock or thrashing). The operating system may also provide mechanisms for inter-process communication to enable processes to interact in safe and predictable ways.

Monday, May 11, 2009

task

In computer programming, a task is a basic unit of programming that an operating system controls. Depending on how the operating system defines a task in its design, this unit of programming may be an entire program or each successive invocation of a program. Since one program may make requests of other utility programs, the utility programs may also be considered tasks (or subtasks). All of today's widely-used operating systems support multitasking , which allows multiple tasks to run concurrently, taking turns using the resources of the computer.

In preemptive multitasking , each task may be assigned a priority depending on its relative importance, the amount of resources it is consuming, and other factors. The operating system then preempts (cuts short) a task having a lower priority value so that a higher priority task is given a turn. Windows 2000 , OS/390 , Linux , and Amiga are examples of operating systems that use preemptive multitasking. Cooperative multitasking is the ability for an operating system to manage multiple tasks such as application programs at the same time, but without the ability to necessarily preempt them.

It's easy to confuse the terms multithreading and multitasking . Multithreading is the management of multiple concurrent uses of the same program. Most operating systems and modern computer languages also support multithreading.

An operating system concept that refers to the combination of a program being executed and bookkeeping information used by the operating system. Whenever you execute a program, the operating system creates a new task for it. The task is like an envelope for the program: it identifies the program with a task number and attaches other bookkeeping information to it.

Many operating systems, including UNIX, OS/2, and Windows, are capable of running many tasks at the same time and are called multitasking operating systems.

In most operating systems, there is a one-to-one relationship between the task and the program, but some operating systems allow a program to be divided into multiple tasks. Such systems are called multithreading operating systems.

The terms task and process are often used interchangeably, although some operating systems make a distinction between the two.

Saturday, May 9, 2009

LVM (Logical Volume Manager)

LVM (Logical Volume Manager)

Create 3 partitions for implementing RAID using fdisk command.

e.g. #fdisk /dev/hda

Press n to create the 3 new partitions each of 100Mb in size.

Press p to see the partition table.

Press t to change the partition id of all the three partitions created by you to 8e (Linux LVM).

Press wq to save and exit from fdisk utility in linux.

Use fdisk -l to list the partition table.

Creating LVM

# pvcreate /dev/hda6 /dev/hda7 /dev/hda8

# pvdisplay

#vgcreate vg /dev/hda6 /dev/hda7 /dev/hda8

#vgdisplay vg

#lvcreate -L +10M -n data vg

-L is used to define size.

-n is used to define the name.

#mkfs.ext3 /dev/vg/data

#lvdisplay /dev/vg/data

#mkdir disk

#mount /dev/vg/data disk

#df -h disk

#lvextend -L +10M /dev/vg/data

#ext2online /dev/vg/data

#df -h disk

#umount disk

#vgchange -an vg (optional) -a control the avability of the logical volume in the volume group for input and output.

#lvremove /dev/vg/data

Press y to continue

#lvdisplay

#vgremove /dev/vg

#vgdisplay

#pvremove /dev/hda6 /dev/hda7 /dev/hda8

#pvdisplay

01 - Lvm Fdisk

02 - Lvm Implementation

Friday, May 8, 2009

Recommended Partitioning Scheme for Red Hat linux

  • A swap partition (at least 32MB) — swap partitions are used to support virtual memory. In other words, data is written to a swap partition when there is not enough RAM to store the data your system is processing. The size of your swap partition should be equal to twice your computer's RAM, or 32MB, whichever amount is larger.

    For example, if you have 1GB of RAM or less, your swap partition should be at least equal to the amount of RAM on your system, up to two times the RAM. For more than 1GB of RAM, 2GB of swap is recommended. Creating a large swap space partition will be especially helpful if you plan to upgrade your RAM at a later time.

  • A /boot partition (100MB) — the partition mounted on /boot contains the operating system kernel (which allows your system to boot Red Hat Linux), along with files used during the bootstrap process. Due to the limitations of most PC BIOSes, creating a small partition to hold these files is a good idea. For most users, a 100MB boot partition is sufficient.

  • A root partition (1.7-5.0GB) — this is where "/" (the root directory) will be located. In this setup, all files (except those stored in /boot) are on the root partition. A 1.7GB root partition will permit the equivalent of a personal desktop installation (with very little free space), while a 5.0GB root partition will let you install every package.

Thursday, May 7, 2009

RAID (Redundant Array of Inexpensive Disks)

RAID (Redundant Array of Inexpensive Disks)

Create 3 partitions for implementing RAID using fdisk command.

e.g. #fdisk /dev/hda

Press n to create the 3 new partitions each of 100Mb in size.

Press p to see the partition table.

Press t to change the partition id of all the three partitions created by you to fd (linux raid auto).

Press wq to save and exit from fdisk utility in linux.

#partprobe

Use fdisk -l to list the partition table.

Creating RAID

# mdadm --create /dev/md0 --level=5 --raid-devices=3 /dev/hda6 /dev/hda7 /dev/hda8

Press y to create the arrays.

To see the details of raid use the following command: -

# cat /proc/mdstat

# mdadm --detail /dev/md0

Creating the file system for your RAID devices

#mkfs.ext3 /dev/md0

Mounting the RAID partition

#mkdir data

# mount /dev/md0 data

#df -h /root/data (Command is used to see the space allocation).

Crashing the raid devices

# mdadm --manage /dev/md0 --fail /dev/hda8

Removing raid devices

# mdadm --manage /dev/md0 --remove /dev/hda8

Adding raid devices

# mdadm --manage /dev/md0 --add /dev/hda8

View failed and working raid devices

# cat /proc/mdstat

# mdadm --detail /dev/md0

# tail /var/log/messages

To remove the RAID follow these steps: -

1) unmount the mounted directory where raid is mounted.

e.g. umount data

2) Stop the device

e.g. mdadm --stop /dev/md0

3) View the details of your raid level using following command: -

#cat /proc/mdstat

#mdadm --detail /dev/md0

Wednesday, May 6, 2009

Reconfiguring and Recompiling the Linux Kernel

Linux has a modular, customisable kernel with several switchable options (e.g. support for multiple processors and device drivers for various hardware devices). It may happen that some new hardware is added to a Linux machine which requires you to recompile the kernel so that it includes device driver support (and possibly new system calls) for the new hardware. To do this, you will need to rebuild the Linux kernel from scratch as follows:
  • Look in /usr/src/linux for the kernel source code. If it isn't there (or if there is just a message saying that only kernel binaries have been installed), get hold of a copy of the latest kernel source code from http://www.kernel.org and untar it into /usr/src/linux.
  • Change directory to /usr/src/linux.
  • To configure the kernel type either
  • # make config (simple text mode configuration), or
    # make menuconfig (menu-driven text configuration), or
    # make xconfig (graphical configuration for X)

    You will be asked to select which modules (device drivers, multiprocessor support etc.) you wish to include. For each module, you can chose to include it in the kernel code (y), incorporate it as an optional module that will be loaded if needed (m) or to exclude it from the kernel code (n). To find out which optional modules have actually been loaded you can run lsmod when the system reboots.

  • Now type:
  • # make dep (to build source code dependencies)
    # make clean (to delete all stale object files)
    # make bzImage (to build the new kernel)
    # make modules (to build the new optional modules)
    # make modules_install (to install the modules)

    The file /usr/src/linux/arch/i386/boot/bzImage now contains your new kernel image. It remains only to install it.

  • Change directory to /usr/src/linux/arch/i386/boot. In the same directory should be a script called install.sh which will copy your kernel image into /boot/vmlinuz:
  • # install.sh version bzImage /boot/System.map /boot

    where version is the kernel version number (of form 2.2.xx).

    else you can run the command #make install

  • Finally, you may need to update the /etc/lilo.conf file so that lilo (the Linux boot loader) includes an entry for your new kernel. Then run
  • # lilo

    to update the changes. When you reboot your machine, you should be able to select your new kernel image from the lilo boot loader.

 
Things You Should Know About Linux !!!