This is default featured slide 1 title

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam. blogger theme by BTemplates4u.com.

This is default featured slide 2 title

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam. blogger theme by BTemplates4u.com.

This is default featured slide 3 title

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam. blogger theme by BTemplates4u.com.

This is default featured slide 4 title

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam. blogger theme by BTemplates4u.com.

This is default featured slide 5 title

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam. blogger theme by BTemplates4u.com.

  
Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Monday, January 30, 2012

How to setup VPN Server on Linux

VPN SERVER ON LINUX






Basic Configuration:

Disable firewall

1 - Go to networking settings and enable ipforwarding and enter gateway

To run vpn server

2 - Install pptpd

Apt-get install pptpd

Or go to yast than software management than install pptpd

3 - Configure pptpd Server

vi /etc/pptpd.conf

localip 192.168.0.1

remoteip 192.168.0.100-200,192.168.0.222

/etc/init.d/pptpd restart

Condition:

If pptpd doesn’t start or restart edit below mentioned file as per details

Solution:

vi /etc/pptpd.conf

change”option /etc/ppp/options.ppp0” to “option /etc/ppp/options.pptp”

rcpptpd start

Now it will start pptpd

4 -Edit file options.pptp

Change noauth to auth save file

Ms-dns 8.8.8.8

Ms-dns 8.8.4.4


5 - Add users

Echo “ *” >> /etc/ppp/chap-secrets

6 - add the following line into etc/ppp/ip-up

/sbin/ifconfig $1 mtu 1400


7 -Enable IP forwarding

Uncomment this line in /etc/sysctl.conf

Net.ipv4.ip_forward=1

Than use these commands

/usr/sbin/iptables –P FORWARD ACCEPT

/usr/sbin/iptables --table nat –A POSTROUTING –o eth0 –j MASQUERADE

Thursday, July 7, 2011

Querying the RPM database

As you already know, the RPM database contains a list of all installed RPM packages on your system. You can query this database to get info of the packages on your Linux system. To query a single package, you use the -q option. For example, to query a package whose name is "software":
# rpm -q software

After issuing this command, rpm either tells you the version of the package, or that the package isn't installed.

If you want a list of all packages installed on your system, you'll have to query all with -qa:
# rpm -qa

Most likely this list will be very long, so you'll need a way to scroll it. The best way is to pipe the list to less:
# rpm -qa | less

If you're looking for packages whose names contain a specific word, you can use grep for finding those packages. For example, to get a list of all installed RPM packages whose names contain the word "kde", you could do something like this:
# rpm -qa | grep kde

The above command makes rpm list all packages in its database and pass the list to grep. Then grep checks every line for "kde" and finally shows you all the lines that contain the word "kde".

Removing software installed with RPM

To remove software that was installed with RPM, you use the -e option (which stands for "erase"):
# rpm -e software-2.3.4

Note that when installing software, you have to type the name of the RPM package. But when removing software, you don't have to type the whole name of the package that contained the software. You don't have to type the .rpm extension when removing software. Probably you don't have to type the version number, either, so this would do exactly the same as the above:
# rpm -e software

This rpm -e command uses the RPM database to check where all the files related to this software were installed and then automatically removes all of those files. After removing the program files, it also removes the program from the database of installed software.

This is why it's so important you NEVER remove RPM software manually (for example, deleting single files with rm). If you just run around your system randomly deleting files that were installed with RPM, you'll get rid of the software but RPM doesn't know it and doesn't remove the software package from its database. The result is that RPM still thinks the program is installed on your system, and you may run into dependency problems later.

If you used RPM for installing a certain piece of software, use RPM for removing that piece of software, too!

RPM Error: failed dependencies

Issuing rpm -i or rpm -U installs the software and you can start using it. RPM is very easy when it works. However, RPM can be a devil when it doesn't work. There are many reasons why installing software goes wrong, but usually it's because of failed dependencies.

You see, many Linux programs need other files or programs in order to work properly. In other words, a certain piece of software depends on other software. When you try to install an RPM package, RPM automatically checks its database for other files that the software being installed needs. If RPM can't find those files in its database, it stops installing the software and complains about failed dependencies.

When you get a dependency error, RPM spits out a list of files the program needs. Take a look at the list. The files in the list are probably ones you don't have on your system, or files you have but are wrong versions. When you get the dreaded dependency error, you'll have to find the files RPM complains about, install or upgrade those files first, and then try to install the package you were installing in the first place.

However, sometimes RPM is just plain stupid. You see, only software that was installed with RPM gets added into the database of installed software. This means that if you've used some other method for installing a certain program, RPM doesn't know the program exists on your system. In this case RPM complains about failed dependencies even when the needed program does exist on your system and there are no failed dependencies!

If you know the needed files are there and RPM is just being stupid, you can ignore the dependencies. Use the --nodeps option if you want to tell RPM not to check any dependencies before installing the package:
# rpm -i software-2.3.4.rpm --nodeps

This forces RPM to ignore dependency errors and install software anyway, but note that if the needed files are missing anyway, the program won't work well or won't work at all. Use the --nodeps option only when you know what you're doing or when you're bone-headed enough ;-)

Installing and upgrading RPM packages

For installing a software package, you use the rpm command with -i option (which stands for "install"). For example, to install an RPM package called software-2.3.4.rpm:
# rpm -i software-2.3.4.rpm

If you already have some version installed on your system and want to upgrade it to the new version, you use -U option instead (which stands for "upgrade"). For example, if you have software-2.3.3.rpm installed and want to upgrade it:
# rpm -U software-2.3.4.rpm

If all goes well, the files in your package will get installed into your system and you can happily run your new program. But where is your new program? Note that rpm doesn't usually create a special directory for the software package's files. Instead, the different files from the package get placed into appropriate existing directories on your Linux system. Executable programs go usually into /bin, /usr/bin, /usr/X11/bin, or /usr/X11R6/bin after installing with rpm.

But how can you run your new program if you don't know where the executable is? Sometimes the program gets automatically added into your menu, but usually you can just run the program by typing its name at the command prompt. In most cases you don't have to know where the program was installed because you don't have to type the whole path when running the program, only the program's name is needed.

What is RPM

RPM stands for Red Hat Package Manager. However, these days RPM isn't only Red Hat specific because many other Linux distros use RPM for managing their software. For example, both Mandriva and SuSE use RPM for software management. With RPM, you can install, upgrade and uninstall software on Linux, as well as keep track of already installed RPM packages on your system. This can be done because RPM keeps a database of all software that was installed with it.

RPM uses software packages that have (surprise) the .rpm extension. An RPM package contains the actual software that gets installed, maybe some additional files for the software, information on where the software and its files get installed, and a list of other files you need to have on your system in order to run this specific piece of software.

When you use RPM for installing the software package, RPM checks if your system is suitable for the software the RPM package contains, figures out where to install the files the package provides, installs them on your system, and adds that piece of software into its database of installed RPM packages.

Note that different Linux distros may keep their software and the files related to that software in different directories. That's why it's important to use the RPM package that was made for your distribution. For example, if you install a SuSE specific software package on a Red Hat system, RPM may put the files from that package into wrong directories. In the worst case the result is that the program doesn't find all the files it needs and doesn't work properly.

There are some good graphical programs for installing RPM packages, but in this tuXfile I'll discuss the fool-proof command line method for installing software. Note that you need to be root when installing software in Linux. When you've got the root privileges, you use the rpm command with appropriate options to manage your RPM software packages.

Friday, July 1, 2011

what are init 0 init 1 init 2 init 3 init 4 init 5 init 6 init s init S init m

The best solution to know about these init levels is to understand the " man init " command output on Unix.

There are basically 8 runlevels in unix. I will briefly tell some thing about the different init levels and their use.
Run Level: At any given time, the system is in one of eight possible run levels. A run level is a software configuration under which only a selected group of processes exists. Processes spawned by init for each of these run levels are defined in /etc/inittab. init can be in one of eight run levels, 0-6 and S or s (S and s are identical). The run level changes when a privileged user runs /sbin/init.

init 0 : Shutdown (goes thru the /etc/rc0.d/* scripts then halts)
init 1 : Single user mode or emergency mode means no network no multitasking is present in this mode only root has access in this runlevel
init 2 : No network but multitasking support is present .
init 3 : Network is present multitasking is present but with out GUI .
init 4 : It is similar to runlevel 3; It is reserved for other purposes in research.
init 5 : Network is present multitasking and GUI is present with sound etc.
init 6 : This runlevel is defined to system restart.
init s : Tells the init command to enter the maintenance mode. When the system enters maintenance mode from another run level, only the system console
is used as the terminal.
init S : Same as init s.
init m : Same as init s and init S.
init M : Same as init s or init S or init m.

We can take it from above that 4 options(S,s,M,m) are synonymous.

What is fstab

How to edit and understand /etc/fstab

There's a file called /etc/fstab in your Linux system. Learn what its contents mean and how it's used in conjunction with the mount command. When you learn to understand the fstab file, you'll be able to edit its contents yourself, too.

In this tuXfile I assume you already know how to mount filesystems and partitions with the mount command. If you don't, I suggest reading the Mounting tuXfile before reading this one.

What is fstab and why it's useful

fstab is a configuration file that contains information of all the partitions and storage devices in your computer. The file is located under /etc, so the full path to this file is /etc/fstab.

/etc/fstab contains information of where your partitions and storage devices should be mounted and how. If you can't access your Windows partition from Linux, aren't able to mount your CD or write to your floppy as a normal user, or have problems with your CD-RW, you probably have a misconfigured /etc/fstab file. So, you can usually fix your mounting problems by editing your fstab file.

/etc/fstab is just a plain text file, so you can open and edit it with any text editor you're familiar with. However, note that you must have the root privileges before editing fstab. So, in order to edit the file, you must either log in as root or use the su command to become root.

Overview of the file

Of course everybody has a bit different /etc/fstab file because the partitions, devices and their properties are different on different systems. But the basic structure of fstab is always the same. Here's an example of the contents of /etc/fstab:

/dev/hda2 / ext2 defaults 1 1
/dev/hdb1 /home ext2 defaults 1 2
/dev/cdrom /media/cdrom auto ro,noauto,user,exec 0 0
/dev/fd0 /media/floppy auto rw,noauto,user,sync 0 0
proc /proc proc defaults 0 0
/dev/hda1 swap swap pri=42 0 0

What does all this gibberish mean? As you see, every line (or row) contains the information of one device or partition. The first column contains the device name, the second one its mount point, third its filesystem type, fourth the mount options, fifth (a number) dump options, and sixth (another number) filesystem check options. Let's take a closer look at this stuff.

1st and 2nd columns: Device and default mount point

The first and second columns should be pretty straightforward. They tell the mount command exactly the same things that you tell mount when you mount stuff manually: what is the device or partition, and what is the mount point. The mount point specified for a device in /etc/fstab is its default mount point. That is the directory where the device will be mounted if you don't specify any other mount point when mounting the device.

Like you already learned from the Mounting tuXfile, most Linux distros create special directories for mount points. Most distros create them under /mnt, but some (at least SuSE) under /media. As you probably noticed when looking at the example fstab, I use SuSE's mount points as an example.

What does all this mean? If I type the following command:
$ mount /dev/fd0
... my floppy will be mounted in /media/floppy, because that's the default mount point specified in /etc/fstab. If there is no entry for /dev/fd0 in my fstab when I issue the command above, mount gets very confused because it doesn't know where to mount the floppy.

You can freely change the default mount points listed in /etc/fstab if you're not satisfied with the defaults your distro has given you. Just make sure the mount point is a directory that already exists on your system. If it doesn't, simply create it.

Some partitions and devices are also automatically mounted when your Linux system boots up. For example, have a look at the example fstab above. There are lines that look like this:

/dev/hda2 / ext2 defaults 1 1
/dev/hdb1 /home ext2 defaults 1 2

As you've learned, these lines mean that /dev/hda2 will be mounted to / and /dev/hdb1 to /home. This is done automatically when your Linux system boots up... if it wouldn't, you'd have a hard time using your cool Linux system because all the programs you use are in / and you wouldn't be able to run them if / wasn't mounted! But how does the system know where you want to mount /dev/hda2 and /dev/hdb1? By looking at the /etc/fstab file of course.

3rd column: Filesystem type

The third column in /etc/fstab specifies the filesystem type of the device or partition. Many different filesystems are supported but we'll take a look at the most common ones only.

ext2 and ext3 Very likely your Linux partitions are Ext3. Ext2 used to be the standard filesystem for Linux, but these days, Ext3 and ReiserFS are usually the default filesystems for almost every new Linux distro. Ext3 is a newer filesystem type that differs from Ext2 in that it's journaled, meaning that if you turn the computer off without properly shutting down, you shouldn't lose any data and your system shouldn't spend ages doing filesystem checks the next time you boot up.

reiserfs Your Linux partitions may very well be formatted as ReiserFS. Like Ext3, ReiserFS is a journaled filesystem, but it's much more advanced than Ext3. Many Linux distros (including SuSE) have started using ReiserFS as their default filesystem for Linux partitions.

swap The filesystem name is self-explanatory. The filesystem type "swap" is used in your swap partitions.

vfat and ntfs Your USB stick is most likely formatted as Vfat (more widely known as FAT32). Your Windows partitions are probably either Vfat or NTFS. The 9x series (95, 98, ME) all use Vfat, and the NT series (NT, 2000, XP, Vista, 7) use NTFS but they may be formatted as Vfat, too.

auto No, this isn't a filesystem type :-) The option "auto" simply means that the filesystem type is detected automatically. If you take a look at the example fstab above, you'll see that the floppy and CD-ROM both have "auto" as their filesystem type. Why? Their filesystem type may vary. One floppy might be formatted for Windows and the other for Linux's Ext2. That's why it's wise to let the system automatically detect the filesystem type of media such as floppies and cdroms.

4th column: Mount options

The fourth column in fstab lists all the mount options for the device or partition. This is also the most confusing column in the fstab file, but knowing what some of the most common options mean, saves you from a big headache. Yes, there are many options available, but I'll take a look at the most widely used ones only. For more information, check out the man page of mount.

auto and noauto With the auto option, the device will be mounted automatically (at bootup, just like I told you a bit earlier, or when you issue the mount -a command). auto is the default option. If you don't want the device to be mounted automatically, use the noauto option in /etc/fstab. With noauto, the device can be mounted only explicitly.

user and nouser These are very useful options. The user option allows normal users to mount the device, whereas nouser lets only the root to mount the device. nouser is the default, which is a major cause of headache for new Linux users. If you're not able to mount your cdrom, floppy, Windows partition, or something else as a normal user, add the user option into /etc/fstab.

exec and noexec exec lets you execute binaries that are on that partition, whereas noexec doesn't let you do that. noexec might be useful for a partition that contains binaries you don't want to execute on your system, or that can't even be executed on your system. This might be the case of a Windows partition.

exec is the default option, which is a good thing. Imagine what would happen if you accidentally used the noexec option with your Linux root partition...

ro Mount the filesystem read-only.

rw Mount the filesystem read-write. Again, using this option might cure the headache of many new Linux users who are tearing their hair off because they can't write to their floppies, Windows partitions, or something else.

sync and async How the input and output to the filesystem should be done. sync means it's done synchronously. If you look at the example fstab, you'll notice that this is the option used with the floppy. In plain English, this means that when you, for example, copy a file to the floppy, the changes are physically written to the floppy at the same time you issue the copy command.

However, if you have the async option in /etc/fstab, input and output is done asynchronously. Now when you copy a file to the floppy, the changes may be physically written to it long time after issuing the command. This isn't bad, and may sometimes be favorable, but can cause some nasty accidents: if you just remove the floppy without unmounting it first, the copied file may not physically exist on the floppy yet!

async is the default. However, it may be wise to use sync with the floppy, especially if you're used to the way it's done in Windows and have a tendency to remove floppies before unmounting them first.

defaults Uses the default options that are rw, suid, dev, exec, auto, nouser, and async.

5th and 6th columns: Dump and fsck options

Dump and, uh, what options? Well, dump is a backup utility and fsck is a filesystem check utility. I won't discuss them in great length here, but I'll mention them, because otherwise you'd spend the rest of the day wondering what on God's green Earth do these things mean.

The 5th column in /etc/fstab is the dump option. Dump checks it and uses the number to decide if a filesystem should be backed up. If it's zero, dump will ignore that filesystem. If you take a look at the example fstab, you'll notice that the 5th column is zero in most cases.

The 6th column is a fsck option. fsck looks at the number in the 6th column to determine in which order the filesystems should be checked. If it's zero, fsck won't check the filesystem.

Example /etc/fstab entries

As an example, we'll take a look at a couple of fstab entries that have been a source of endless frustration for new Linux users: floppy and CD-ROM (although these days floppies aren't that important anymore).

/dev/fd0 /media/floppy auto rw,noauto,user,sync 0 0

This line means that the floppy is mounted to /media/floppy by default and that its filesystem type is detected automatically. This is useful because the type of the floppy may wary. Note especially the rw and user options: they must be there if you want to be able to mount and write to the floppy as a normal user. If you have trouble with this, check your fstab file to see if these options are there. Also note the sync option. It can be async just as well, but it's sync because of reasons discussed a bit earlier.

/dev/cdrom /media/cdrom auto ro,noauto,user,exec 0 0

Note, again, the user option that enables you to mount the CD as a normal user. The CD-ROM has the ro option because it's no use mounting a CD-ROM read-write because you wouldn't be able to write to it anyway. Also note the exec option. It's especially useful if you'd like to be able to execute something from your CD.

Also note that the noauto option is used with the floppy and CD-ROM. This means that they won't be automatically mounted when your Linux system boots up. This is useful for removable media, because sometimes there won't be any floppy or CD-ROM when you boot up your system, so there isn't any reason to try to mount something that doesn't even exist.

Thursday, April 7, 2011

How to Kill User Session in Linux

This command will be useful if in case your user is doing something “naughty” and you want to kill them this is how you do it:

How to stop and halt (pause) the user

# skill -STOP -u username

How to continue the halted user

# skill -CONT -u username

How to Kill and make them logout from the computer

# skill -KILL -u username

How to kill all the user in the system

# skill -KILL -v /dev/pts/*

Hope this will be useful for some of you to who have some difficult time with the user.