Tuesday, December 22, 2009

How Do I Disable/Enable Firewall?

Next enter the following three commands to disable firewall.
 
# service iptables save
# service iptables stop
# chkconfig iptables off


If you are using IPv6 firewall, enter:
 

# service ip6tables save
# service ip6tables stop
# chkconfig ip6tables off


To Enable Firewall

# service iptables start
# chkconfig iptables on


And


# service ip6tables start
# chkconfig ip6tables on




THANKS

How to Disable SELinux

Steps to check if SELinux is enabled or disabled in RHEL 5 :

Try running command getenforce from command prompt in Red hat enterprise Linux :
[root@rhel 5 ~]# getenforce
Disabled
OR
[root@rhel 5 ~]# grep SELINUX /etc/selinux/config
# SELINUX= can take one of these three values:
SELINUX=disabled

Steps to disabled SElinux in RHEL 5

There is file called config in /etc/selinux which is used to enable/disable SElinux in RHEL5:
[root@rhel 5#cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
# targeted - Only targeted network daemons are protected.
# strict - Full SELinux protection.
SELINUXTYPE=targeted
# SETLOCALDEFS= Check local definition changes
SETLOCALDEFS=0


While installing RHEL 5 linux if you haven't paid much attention then chances are, you probably have missed reading one of the installation window where installation program ask you to enable/disable SElinux. SElinux can run as enforcing or in permissive mode. If in /etc/selinux/config file selinux is set as permissive or enforcing then change it to disabled. You would need to reboot your RHEL 5 server to disable selinux. This change wouldn't work without rebooting your linux box.

Thursday, December 17, 2009

Installing X Window on Debian

Installing X Window X-Server and Window Managers

To install X-window, lets first update our resource lists with
 
apt-get update

Then, to install X-window
 
apt-get install x-window-system

I started using the XFCE window manager and its one of the most lightweight WMs on Linux. It has the look of Gnome and the lightweight of IceWM and X.
To install XFCE 4,
 
apt-get install xfce4 xfce4-themes

To install other window managers like IceWM, Fluxbox, GNOME)
 
apt-get install icewm fluxbox gnome

I like gdm (Gnome Desktop Manager) as my graphical login program, so
 
apt-get install gdm

However you can also try xdm (X Desktop Manager) or kdm (KDE Desktop Manager)
 
apt-get install xdm kdm

Changing your screen resolution

dpkg-reconfigure xserver-xfree86

Choose your resolution and restart your X with either
 
/etc/init.d/gdm restart

or
 
startx

Removing graphical login

You are finally tired of graphical logins. To turn off the graphical logins (default in Sarge), you have to remove X startup from all run levels.
 
update-rc.d xdm remove

X won't start again when your computer boots up. You'll be greeted by the console.

sudo and sudoers


apt-get install sudo


Do not edit directly the file
To edit it, use the command


# visudo


You will see a file more or less like this.
# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#

Defaults        env_reset

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL) ALL
As you can see there is basically one line
root ALL=(ALL) ALL
This lines means that the user root can execute from ALL terminals, acting as ALL (any) users, and run ALL (any) command.
So the first part is the user, the second is the terminal from where the user can use sudo, the third is as which user he may act, and the last one, is which commands he may run.
Let's see some other examples.
operator ALL= /sbin/poweroff


This makes that users operator can from any terminal, run the command poweroff.
You can also create aliases for: users -> User_Alias, run comands as other users -> Runas_Alias, host -> Host_Alias and command-> Cmnd_Alias
These are some examples:


User_Alias OPERATORS = joe, mike, jude
Runas_Alias OP = root, operator
Host_Alias OFNET = 10.1.2.0/255.255.255.0
Cmnd_Alias PRINTING = /usr/sbin/lpc, /usr/bin/lprm



As you can see the alias OPERATORS includes the users joe, mike and jude, the alias OP includes the users root and operator, alias OFNET includes the network 10.1.2.0 (all the C class), and the command alias PRINTING includes the commands lpc and lprm.
So a typical sudoers file may look like this.
 
User_Alias     OPERATORS = joe, mike, jude
 Runas_Alias    OP = root, operator
 Host_Alias     OFNET = 10.1.2.0/255.255.255.0
 Cmnd_Alias     PRINTING = /usr/sbin/lpc, /usr/bin/lprm

OPERATORS ALL=ALL

#The users in the OPERATORS group can run any command from any terminal.

linus ALL=(OP) ALL

# The user linus can run any command from any terminal as any user in the OP group (root or operator).

user2 OFNET=(ALL) ALL

# user user2 may run any command from any machine in the OFNET network, as any user.

user3 ALL= PRINTING

# user user3 may run lpc and lprm from any machine.

go2linux ALL=(ALL) ALL

# user go2linux may run any command from any machine acting as any user. (like Ubuntu)
You may want to read sudoers man page

Monday, December 7, 2009

LVM SCENARIO for RHEL5

LVM

I have a 13.9 GB harddisk (/dev/sda). Initially it just had one
partition /dev/sda1 of size 5766 MB. To demonstrate LVM, using fdisk
utility I partitioned my harddisk in following manner:

PARTITION          SIZE (MB)            TYPE                      FILESYSTEM
/dev/sda1           5766                       PRIMARY             ext3
/dev/sda2           1653                       PRIMARY
/dev/sda3           1653                       PRIMARY
/dev/sda4           4886                       EXTENDED


To use /dev/sda2 & /dev/sda3 for Logical Volume Manager, follow the
following steps:

1.] Using fdisk utility change the partition id of /dev/sda2 and
/dev/sd3 to lvm (8e)

fdisk /dev/sda
m
p
l
m
t
Partition number: 2
Hex Code: 8e
p
w

fdisk /dev/sda
p
l
t
Partition Number: 3
Hex Code: 8e
p
w

#partprobe

#pvdisplay
#pvcreate /dev/sda2
#pvdisplay
#pvscan

#vgdisplay
#vgscan
#vgcreate Volgroup001 /dev/sda2
#vgscan
#vgdisplay

#lvdisplay
#lvscan
#lvcreate -L 788.48m -n cdrive /dev/Volgroup001
#lvdisplay
#lvscan

#lvdisplay
#lvscan
#lvcreate -l 196 -n ddrive /dev/Volgroup001
#lvdisplay
#lvscan

#pvdisplay
#vgdisplay
#vgscan
#vgextend /dev/Volgroup001 /dev/sda3
#vgscan
#vgdisplay

#lvscan
#lvdisplay
#lvextend -L +788.48m /dev/Volgroup001/cdrive
#lvscan
#lvdisplay

#mke2fs -j /dev/Volgroup001/ddrive
#mount /dev/Volgroup001/ddrive /var2
#dd if=/dev/null /var2/file1 count=780MB
#lvextend -l +196 /dev/Volgroup001/ddrive
#resize2fs /dev/Volgroup001/ddrive
#dd if=/dev/null /var2/file1 count=780MB


Mounting NTFS partition on DEBIAN in RW mode


FIRST METHOD




The first and the best method to mount a NTFS partition on DEBIAN in
RW mode is to use the application called "ntfs-3g"


All you need to follow the steps prescribed below:


1.] First download the following two binaries:


ntfs-3g
libntfs-3g




2.] Then install the dependencies if at all there are using following command:


#sudo apt-get install fuse-utils libfuse2






P.S: There should not be any dependency in Debian 4.0 (Etch) but to be
on the safer side verify it using above command .


3.] Finally you can install ntfs-3g (using the 2 Debian packages you
just downloaded) using:


#sudo dpkg -i libntfs-3g0_0.0.0+20061031-6_i386.deb
#sudo dpkg -i ntfs-3g_0.0.0+20061031-6_i386.deb




4.] To use the utility ntfs-3g, execute #man ntfs-3g and understand
the command and it's options.






SECOND METHOD


You can also mount the NTFS partition by placing following entry in /etc/fstab:


/dev/sda1 /windows ntfs rw,users,umask=022 0 0






However I am not being able to write over the NTFS partition from
Linux box using second method

Enabling "root" user account in Ubuntu

In Ubuntu, you can change the root password or activate the root
account with this command :

$ sudo passwd root

But still GDM will not allow you to log on as root in the GUI.

If you still want to do it (bad idea), you have to allow "root login"
(or something similar) in "gdmsetup" :

$ gksu gdmsetup