Showing posts with label LINUX. Show all posts
Showing posts with label LINUX. Show all posts

Monday, 5 December 2011

Powerful of Linux CD Command for Admins,Devlopers,Testers,Supporters


Powerful of Linux CD Command for Admins,Devlopers,Testers,Supporters


CD is one of the most frequently used command during a UNIX and LINUX session. I am going to add some useful practical examples of CD command. This will increase your productivity and make it easier to navigate the directory from CLI.

CDPATH: If you are performing CD to sub directories  of a any specific parent directory and you can set the CDPATH variable to the parent directory and perform CD to to the sub directories without Giving parent directory path.

Example:




To make this change permanent, add export CDPATH=/etc to your
~/.bash_profile

export CDPATH=.:~:/var:/usr:/etc

Directory stack

dirs: Display the directory stack
pushd: Push directory into the stack
popd: Pop directory from the stack and cd to that directory




Automatically Correct Mistyped Directory Names using shopt -s

Use shopt -s cdspell to correct the typos in the cd command
automatically as shown below




Friday, 25 November 2011

Create SWAP file system


What is swap partition?

Swap partition is used for paging in memory management method by which computer can store and retrieve data from secondary storage (Hard disk) and then for use in primary storage (RAM).

What is paging?

Operating system retrieves data from secondary storage in same size blocks called  pages

Why its required?

The main purpose of this file system is when an Application or process data not fit into physical memory (RAM) then disk storage (Hard disk) is used as temporary memory.

Example:Your system having 1GB RAM and running Apache web server and because of huge traffic on server 1 GB RAM exceded. Then memory management schemes moved the low proiprty process (tasks) to Swap file sysem and started execute remaining high priority process first.

If system needs run moved process then it copies pages from swap partion to System RAM.

what is the size of swap partition?

Common recommendation is 2 times of your physical RAM.

But According to Open BSD FAQ:

Nonsense rule: Twice the size of your main system RAM for Servers

Many people follow an old rule of thumb that your swap partition should be twice the size of your main system RAM. This rule is nonsense. On a modern system, that's a LOT of swap, most people prefer that their systems never swap. You don't want your system to ever run out of RAM+swap, but you usually would rather have enough RAM in the system so it doesn't need to swap

My recommendation: If you are a kernel hacker (debugging and fixing kernel issues) and generating core dumps, you need twice the RAM swap space.

example: Your server having 2GB RAM then Swap partion should be 4GB

How to create swap partition?

There are 2 methods

1.While installing new OS
2.After installing OS


While installing new OS

While installing new OS you have to select new partion of file system type SWAP with Size.

After installing OS
Check previous swap partitions and their size as below.

cat /proc/swaps
swapon -s
free -m
top

Create a file for swap usage as shown below







Use the mkswap command to make our file swap-consumable for the Linux kernel. Again as root, carefully 








To turn on our swap file, we should run swapon







Add the following line to /etc/fstab and reboot the system for the swap
to take into effect.
/root/swap-fs swap swap defaults 0 0