GOOGLE Search

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

Wednesday, March 26, 2008

Linux Tip No. 36: How to Enable IP Forwarding

Enable IP Forwarding

1. Check if IP Forwarding is enabled

Using sysctl:

[root@proxy ~]# sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 0

or just checking out the value in the /proc system:

[root@proxy ~]# cat /proc/sys/net/ipv4/ip_forward
0

Value 0 means it is disabled.

2. Enable IP Forwarding on the fly

[root@proxy ~]#sysctl -w net.ipv4.ip_forward=1

or

[root@proxy ~]#echo 1 > /proc/sys/net/ipv4/ip_forward

the setting is changed instantly; the result will not be preserved after rebooting the system.


3. Permanent setting using /etc/sysctl.conf

If we want to make this configuration permanent the best way to do it is using the file /etc/sysctl.conf where we can add a line containing net.ipv4.ip_forward = 1

[root@proxy ~]#vi /etc/sysctl.conf 
# Controls IP packet forwarding
net.ipv4.ip_forward = 1


if you already have an entry net.ipv4.ip_forward with the value 0 you can change that 1.

To enable the changes made in sysctl.conf you will need to run the command:

[root@proxy ~]#sysctl -p /etc/sysctl.conf

Restart the network service

[root@proxy ~]#service network restart

Linux Tip No. 35: Enable service at boot up

To Check:
[root@jepoy ~]# chkconfig --list |grep httpd
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

To enable at boot up:
[root@jepoy ~]# chkconfig httpd on

Linux Tip No. 34: How to Check Services

This command is used to start/stop your services.

service   start/stop/restart/status
To Start:
[root@jepoy ~]# service httpd start

To Stop:
[root@jepoy ~]# service httpd stop

To Restart:
[root@jepoy ~]# service httpd restart

To check:
[root@jepoy ~]# service httpd status


Monday, March 24, 2008

Linux Tip No. 33: How to check your DHCP server

This command tells you what DHCP server you are using.

[root@jepoy ~]# grep dhcp-server-identifier /var/lib/dhcp/dhclient.leases
option dhcp-server-identifier 192.168.0.254;

Linux Tip No. 32: Checking the top 10 directories

Top 10 directories eating up your disk space:

[root@mail etc]# du -cksh * | sort -rn | head -10
852K sysconfig
784K termcap
704K selinux
704K makedev.d
632K firmware
552K X11
544K pam.d
472K prelink.cache
460K alsa
444K postfix

Linux Tip No. 31: Renew/Release DHCP client

[root@proxy ~]# dhclient -r

[root@proxy ~]# dhclient
Internet Systems Consortium DHCP Client V3.0.2
Copyright 2004 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/products/DHCP


The -r flag
explicitly releases the current lease, and once the lease has been released, the client exits.

Tuesday, March 18, 2008

Linux Tip No. 30: Managing Disk Space

[root@mail ~]# fdisk -l

Disk /dev/sda: 36.4 GB, 36419584000 bytes
255 heads, 63 sectors/track, 4427 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 63 506016 83 Linux
/dev/sda2 64 3905 30860865 83 Linux
/dev/sda3 3906 4427 4192965 82 Linux swap

Disk /dev/sdb: 36.4 GB, 36419584000 bytes
255 heads, 63 sectors/track, 4427 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 4427 35559846 83 Linux

Linux Tip No. 29: Becoming a Super User

Becoming Super User (The su Command)

[docadmin@mail ~]$ su
Password: ******
[root@mail docadmin]#

When you are prompted, type in the root user's password. The prompt for the regular user ($) will be changed to the super user prompt (#). At this point, you have full permission to run any command and use any file on the system. However, one thing that the su command doesn't do when used this way is read in the root user's environment. As a result, you may type a command that you know is available and get the message "command not found." To fix this problem, you can use the su command with the dash (-) option instead, as follows:

[docadmin@mail ~]$ su -
Password:
[root@mail docadmin]#




When you are prompted, type in the root user's password. The prompt for the regular user ($) will be changed to the super user prompt (#). At this point, you have full permission to run any command and use any file on the system. However, one thing that the su command doesn't do when used this way is read in the root user's environment. As a result, you may type a command that you know is available and get the message "command not found." To fix this problem, you can use the su command with the dash (-) option instead, as follows:

$ su -
Password: ******
#




Linux Tip No. 28: Command-Line Recall

Command-Line Recall

After you type a command line, that entire command line is saved in your shell's history list. The list is stored in a history file, from which any command can be recalled to run again.


[docadmin@mail ~]$ history 20
526 exit
527 su -
528 cd /etc
529 more inittab
530 exit
531 su
532 lspcis
533 lspci
534 su
535 su -
536 su
537 su -
538 su -
539 su -
540 su -
541 id
542 su jepoy
543 history
544 history 10
545 history 20

Linux Tip No. 27: Exiting the Shell

Exiting the Shell

To exit the shell when you are done, type exit or press Ctrl+D.


[jepoy@mail ~]$ exit
exit
There are stopped jobs.

Linux Tip No. 26: Checking Directories

To find out what your current directory is, type the pwd command:

$ pwd
/usr/bin

To find out the name of your home directory, type the echo command, followed by the $HOME variable:

$ echo $HOME
/home/jepoy

To change your directory, use the cd command. You could also use the tilde (~) character to indicate the home directory. So cd ~ would have the same resultas just cd.

$ cd /var/log
$ pwd
/var/log


To check if its a directory, use the ls -la command. "d" means its a directory.
[jepoy@mail ~]$ ls -al
total 33048
drwx------ 7 jepoy jepoy 4096 Mar 15 12:12 .
drwxr-xr-x 85 root root 4096 Jan 28 13:35 ..
-rw-r--r-- 1 jepoy jepoy 304 Jul 27 2007 .bash_logout
-rw-r--r-- 1 jepoy jepoy 191 Jul 27 2007 .bash_profile
-rw-r--r-- 1 jepoy jepoy 124 Jul 27 2007 .bashrc
drwxr-xr-x 3 jepoy jepoy 4096 Aug 29 2007
dr-x------ 2 jepoy jepoy 4096 Mar 14 15:50 download_only
drwxr-xr-x 2 jepoy jepoy 4096 Aug 16 2007 DVBH
drwxr-xr-x 2 jepoy jepoy 4096 Aug 16 2007 Dynamips

Linux Tip No. 25: Checking Your Login Session

To find out information about your identity, use the id command as follows:

[jepoy@mail docadmin]$ id
uid=10023(jepoy) gid=10023(jepoy) groups=10023(jepoy)

Thursday, March 13, 2008

Linux Tip No. 24: How to check speed/duplex of your NIC

How to determine the speed/negotiation of your NIC
a. dmesg
[root@mail ~]# dmesg | grep -i duplex
tg3: eth1: Link is up at 100 Mbps, full duplex.

b. ethtool
[root@mail ~]# ethtool eth1
Settings for eth1:
Supported ports: [ MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Advertised auto-negotiation: Yes
Speed: 100Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: g
Wake-on: d
Current message level: 0x000000ff (255)
Link detected: yes

c. mii-tool
[root@mail ~]# mii-tool eth1
eth1: negotiated 100baseTx-FD, link ok

Wednesday, March 12, 2008

Linux Tip No. 23: How to check your NIC

How to check your NIC
[root@mail docadmin]# /sbin/lspci |grep -i eth
00:04.0 Ethernet controller: Broadcom Corporation NetXtreme BCM5702X Gigabit Ethernet (rev 02)
02:01.0 Ethernet controller: Intel Corporation 82557/8/9 [Ethernet Pro 100] (rev 08)

Thursday, March 6, 2008

Linux Tip No. 22: How to check your sound card

[root@proxy /]# arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: AudioPCI [Ensoniq AudioPCI], device 0: ES1371/1 [ES1371 DAC2/ADC]
Subdevices: 1/1
Subdevice #0: subdevice #0
[root@proxy /]#

Wednesday, March 5, 2008

Linux Tip No. 21: How to check your video card

a. Check the graphics card
[root@mail docadmin]# /sbin/lspci |grep -i vga
00:03.0 VGA compatible controller: ATI Technologies Inc Rage XL (rev 27)

b. Check the video card memory size
[root@mail docadmin]# /sbin/lspci -v -s 00:03.0
00:03.0 VGA compatible controller: ATI Technologies Inc Rage XL (rev 27) (prog-if 00 [VGA])
Subsystem: Compaq Computer Corporation: Unknown device 001e
Flags: bus master, stepping, medium devsel, latency 64
Memory at f6000000 (32-bit, non-prefetchable) [size=16M]
I/O ports at 2c00 [size=256]
Memory at f5ff0000 (32-bit, non-prefetchable) [size=4K]
Capabilities: [5c] Power Management version 2


Tuesday, February 19, 2008

Linux Tip No. 20: Change your Default Gateway

How to Change Your Default Gateway

Temporary
[root@jepoy /]# route add default gw 192.168.1.1 eth0


Permanent

Config file: /etc/sysconfig/network

NETWORKING=yes
HOSTNAME=jepoy
GATEWAY=192.168.1.1

Monday, February 18, 2008

Linux Tip No. 19: View your routing table

[root@proxy ~]# netstat -nr
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
203.189.11.64 0.0.0.0 255.255.255.224 U 0 0 0 eth0
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1
0.0.0.0 203.189.11.65 0.0.0.0 UG 0 0 0 eth0

Sunday, February 17, 2008

Linux Tip No. 18: Restart Network Service

[root@proxy docadmin]# /sbin/service network restart
Shutting down interface eth0: [ OK ]
Shutting down interface eth1: [ OK ]
Shutting down loopback interface: [ OK ]
Disabling IPv4 packet forwarding: net.ipv4.ip_forward = 0
[ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: [ OK ]
Bringing up interface eth1: [ OK ]

Thursday, February 14, 2008

Linux Tip No. 17: Enable/Disable interface

[root@jepoy]# ifdown eth0
[root@jepoy]# ifup eth0