COMPRESSION UTILITY

Wednesday, April 29, 2009
Your Ad Here
To compress all files in the current directory –
tar czvf myfile.tar.gz *
To de-compress or extract
tar xzvf myfile.tar.gz
To compress a file with zip utility -
gzip –v file_name (File_name will be zipped with .gz extension)
gunzip file_name.gz (Decompresses a zipped file)
gunzip –c file_name.gz (Decompresses a zipped file while keeping the original .gz file)
bzip2 –v file_name (Newer compression utility. Creates a zipped file with bz2 extension)
bunzip2 file_name.bz2 (Decompress .bz2 file)
tar cjvf myfile.tar.bz2 * (All files will be zipped with bz2 extension)
Use the following command a have low level formatted floppy disk –
fdformat /dev/fd0 H1440
We can save a zipped file in floppy disk (with low level format) without mounting the
floppy disk using this following command –
tar czvf /dev/fd0

Labels: , , , , , , , , ,

 
posted by Gautam at 11:34 PM, | 0 comments

IP Forwarding

Saturday, April 25, 2009
Your Ad Here
IP Forwarding is a feature of the LINUX kernel, which can be turned on or off,
if needed, without rebooting the computer. It is very much needed, especially
when a LINUX system is used as a Firewall/Router or a Proxy Server for
a network and is doing Network Address Translation (NAT) to masquerade
a private subnet behind a single public IP address. In this regard,
what Administrators do is –
Install two network cards (one will be assigned with the real or public IP
address and the second will be assign ed with the private IP address.)
To turn IP Forwarding on we can run the following command –
echo 1 > /proc/sys/net/ipv4/ip_forward
The above command will enable IP forwarding for the current session,
as the default setting is “disable”. To make it permanent, modify /etc/sysctl.conf as follows -
net.ipv4.ip_forward = 1
By default the value 0 is set, means the NATing is disabled. However, after modifying
/etc/sysctl.conf, reboot your machine to make it permanent. During the time of
booting the computer will check the /etc/sysctl.conf and read the IP forwarding related
parameters net.ipv4.ip_forward = x and load it to /proc/sys/net/ipv4/ip_forward file.
However, by executing - echo 1 > /proc/sys/net/ipv4/ip_forward you can enable IP
forwarding instantly.

Labels: , , , , , ,

 
posted by Gautam at 1:10 AM, | 0 comments

Configure Network Interface Card

Thursday, April 23, 2009
Your Ad Here
To view the current configuration of the Network Interface Card run : ifconfig
We can use ifconfig command to temporarily changes parameters of the NIC. The syntax is –
ifconfig eth0 ip_address net_mask
Example: ifconfig eth0 192.168.100.1 255.255.255.0
We must keep in mind that the ifconfig command is used to assign the IP address
temporarily. To change the IP address permanently we must use netconfig command.
Using netconfig command we can assign IP address, subnet mask and network related
parameters, like – Gateway address, DNS server address, Host name of this Server,
Domain name etc.
To make the configuration effected, we can restart the computer. However, we can also
restart the network service to apply the settings. To do this we can use the following
command – "service network restart "
We must remind, if we use netconfig it will configure the eth0. To configure eth1 we
should use the following command – " netconfig –d eth1 "
We can bind multiple IP address to a single Ethernet card. To do this we must configure
sub-interface for that particular Network Interface Card. To create sub-interface 0 for
eth0, we should use the following command – "netconfig –d eth0:0 "
To create sub-interface 1 for eth0, we should use command - "netconfig –d eth0:1 ". After setting values
to the sub-interface(s), don’t forget to restart the network service (service network restart).
If we want to configure network card from GUI, we will run "system-config-network " in a Terminal.
Please be noted, the DNS server related configuration goes to /etc/resolv.conf
It is also possible to bind a single or multiple range of IP addresses to a single network
interface card. To do this, go to / etc/sysconfig/network-scripts folder and create a file
named with ifcfg-eth0-range0. I am assuming we are binding a range of IP addresses to eth0.
The contents of this file will be –
IPADDR_START=192.168.0.50
IPADDR_END=192.168.0.100
CLONENUM_START=0
Do not forget to start the network service using service network restart command.
You can bind maximu m 256 IP addresses to a single network interface card.
To bring up/down an interface, say eth0, we use the following commands –
ifup eth0 (To bring up)
ifdown eth0 (To bring down)
To configure eth0 to obtain IP address from dhcp server, we can edit the
/etc/sysconfig/network-scripts/ifcfg-eth0 file as follows –
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
Yes, we can also use the netconfig command in this respect.
To allow a non-privileged user to control network interface card, we can add the following
line in /etc/sysconfig/network-scripts/ifcfg-eth0 file –
USERCTL=yes

Define IP route:
We can set static route per-interface basis. For exammple, if we want to add a route on
eth0, we must use the following file – /etc/sysconfig/network- scripts/route-eth0
The syntax is – ip-address/CIDR via gateway-address
Example - 192.168.1.0/24 via 192.168.100.254
If we use redhat-config-network command, the command uses a different file. It is
/etc/sysconfig/networking/devices/eth0.route. Here, the syntax used is different.
It will be like this –
ADDRESS0=192.168.1.0
NETMASK0=255.255.255.0
GATEWAY0=192.168.100.254
Please note, I define ADDRESS0,NETMASK0 and GATEWAY0. Because, they define the
first static route. For the second static you route, you must use ADDRESS1,NETMASK1
and GATEWAY1 with the same syntax.
OK?

Labels: , , , , , , , ,

 
posted by Gautam at 5:11 AM, | 0 comments

Vi editor

Monday, April 20, 2009
Your Ad Here
Use vi editor
There are so many editors available with RedHat Linux distribution.You must know one
of them. We will learn and use vi editor in our classroom. To configure and maintain a
RedHat Linux system we must know the followings –
To create/edit a file with vi editor we use vi file_name command.
Press ‘I’ or ‘Insert’ button to insert contents to a file.
:wq - Save and Exit
:w - Save
:q - Quit
:x - Save and Exit
:se nu - Sets number of lines
/text - Searches a text
?text - Searches the text above the current position
yy - Yanking (Copy) line
No.yy - Copy lines (Replace No. with the number you want to copy)
dd - Delete line
p - Paste line
u - Undo changes
G - Go to the last line in the file
1G - Go to the first line in the file
!!command - Replace the blank line with the output of the command.
:1,$s/text/newtext/g - Search and Replace – text will be replaced by newtext throughout the document.
:8,12s/text/newtext/g - Find and Replace – between line 8 and 12
:.,.+10s/text/newtext/g - Replace between current line and next 10 lines
:r file_name - Read file_name and place it after the cursor.
:1,20w newfile - 1s t to 20t h line will be saved to newfile
:10,20w >> newfile1 - 10th to 20t h line will be appended to newfile1

Labels: , ,

 
posted by Gautam at 10:52 PM, | 0 comments

Linux command

Wednesday, April 8, 2009
Your Ad Here
Some Important Commands:
Before we start, we must commit not to delete files except those, that are created by us.
Lets go…..
Log in as root
pwd is used to display full path name of the current directory.
cd command changes the current directory to a specified directory.
Example – cd /usr/bin
~ sign specifies full path for your home directory
mkdir is used to create a directory. Example – mkdir new (will create directory in the current directory) mkdir /home/new (will create directory under /home)
mkdir –p /all/{tom,dic,harry}/{old,new}
The above command will create tom, dic and harry directories in /all and also creates old and new directory in each tome, dic and harry directory.
ls is used to display list of files and directory.
ls –l displays a detail list of files and directories, indicating directory/file, file acess
permission, link ,file, directory, owner, group owner, size in bytes,creation date and time
and name of directory/ file. In the first field, “-“ indicates “file”, “d” indicates directory”.
ll will also gives the same result as ls –l.
ls –la or ll -a list all files including the hidden files.
ls –R –l recursive listing of files, includes contents of the specified/current directory and all the subdirectories.
ls –r –l displays files and directory in reverse order.
ls –s –l list files, sorts by file size.
cp command is used to copy file. Example – cp file1 file2 (here file1 is source file and
file2 is the destination).
cp /etc/* . (copy all files from the /etc directory into the current position)
cp –r file_name destination_directory (Copy file to destination and preserve
permission, ownership and time stamps)
cp –r /etc/* /home/user1 copy all files and directories, including subdirectories in
/home/user1directory.
rm * delets all files from the current directory. Here the system will ask your
confirmation. Only files will be deleted.
rm –f * deletes all files from the current directory forcefully. The system will not ask your confirmation before deleting files.
rm –Rf * this command removes all files and subdirectories
cat command is used to display contents of a file. Example – cat file1
cat > file2 command allows you to create file, named as file2, and it gives you an interface to add contents to this file. However after adding contents we can save the file using +d command.
cat file1 file2 > file3:it create a file, named file3, with the contents of file1 and file2
cat file1 > file2 (here, the contents of file2 will be overwritten by the contents of file1)
cat file1 >> file2 (here, the contents of file1 will be appended to the contents of file2)
touch command can be used to create file/files with no contents. Example -
touch file_name1 file_name2 file_name3
echo command is used display any string
rmdir deletes directory. Example rmdir /home/new. This command will remove /home/new directory if it is empty.
rm deletes file. Example rm file1
date command displays current date & time
clear will clear the console screen.
df –h displays partition(s) and space used in partitions
w OR who is used to view who are logged on to this server
useradd or adduser is used to create user object.Example: useradd user_name
passwd - a user can change his password using this command
passwd user_name :If root user wants to change the password for any user
Here are some important passwd commands: -
passwd –d user-name (will empty password for that user)
passwd –l user-name (will lock the user account)
passwd –u user-name (will unlock the user account

Labels: , ,

 
posted by Gautam at 1:38 AM, | 1 comments

X-Windows

Monday, April 6, 2009
Your Ad Here
The X Window System or X or X11 is the foundation for the Graphical User Interface on RedHat Linux. The X Server works with Graphics Hardware (VGA). Any application requires graphic display is an X Client. RedHat provides two desktop environment – GNOME and KDE. The GNOME is the default desktop. To switch between the GNOME and KDE run switchdesk and select your desired desktop. We will come to this point later. By default RedHat Linux has configured with six (6) virtual console and one X console. We can move to any virtual console by typing ctrl+alt+Fx (Where F – Function key and in place of x we can use 1 to 6 to switch from one virtual terminal to another) or we can switch to X console by typing ctrl+alt+F7. We can start the X server by running the following command – startx considering the system has started in run level 3. We will discuss “run level” later.

Labels: , ,

 
posted by Gautam at 8:56 PM, | 0 comments

X window

Your Ad Here

The X Window System or X or X11 is the foundation for the Graphical User Interface on

RedHat Linux. The X Server works with Graphics Hardware (VGA). Any application

requires graphic display is an X Client.

RedHat provides two desktop environment – GNOME and KDE. The GNOME is the default

desktop. To switch between the GNOME and KDE run switchdesk and select your

desired desktop. We will come to this point later.

By default RedHat Linux has configured with six (6) virtual console and one X console.

We can move to any virtual console by typing ctrl+alt+Fx (Where F Function key and

in place of x we can use 1 to 6 to switch from one virtual terminal to another) or we can

switch to X console by typing ctrl+alt+F7.

We can start the X server by running the following command –

startx considering the system has started in run level 3. We will discuss “run level”

later.

Labels: , ,

 
posted by Gautam at 8:56 PM, | 0 comments

Apache Web Server

Saturday, April 4, 2009
Your Ad Here
APACHE WEB SERVER
We are assuming the FQDN of our Web Server is – mail.bera.com and the IP address is 192.168.100.2. Our DNS Server is configured properly and it is running.
Minimum Configuration to start the Web Server: -
The main configuration file is /etc/httpd/conf/httpd.conf.
Please make a copy of the httpd.conf file by using the following command –
cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.org
Now you have to edit the file as below step.
1. Edit the /etc/httpd/conf/httpd.conf file -
(Find the ‘ServerName’ directive and place the FQDN or IP address as follows -
ServerName 192.168.100.2:80
2. Put an html file (which will be displayed as your ‘home page’) in the /var/www/html
directory. The preferred name of the file, may be, index.html.
3. Start the httpd server - service httpd start or /etc/init.d/httpd start
To start the service every time you boot the system, run the following command –
chkconfig httpd on

This is a very simple configuration. Isn’t it?

If you have any problem then post your comment’s that I can provide the solution.

Labels: , , , ,

 
posted by Gautam at 4:42 AM, | 0 comments

About Linux short briefing

Your Ad Here
Linus Torvalds introduced LINUX in 1991. LINUX is developed keeping UNIX as a
reference model. We can consider LINUX as another version of UNIX. Mr. Linus has made the source code of the LINUX KERNEL available for study, develop and change over the internet. LINUX is an open-development model. It accepts modification to the KERNEL code. Now different distributions are available in the internet. Like RedHat, Mandrake,Slackware, SUSE etc. The core of the LINUX System is KERNEL. It controls the resource of the computer and allots these resources to users and different tasks. In other words we can say the KERNEL allows the users to interact with the hardware. However, we must keep in mind,users cannot access the KERNEL directly. Rather they use a simple user interface to communicate with the KERNEL, called a SHELL.
We will use RedHat E nterprise Linux Release 4 in the training program.
Before starting here is quick look to -
UNIX SHELL
Bourne Shell (sh) : Original UNIX shell written by Steven Bourne at AT&T.
C Shell (csh) : Written by Bill Joy at UC Berkeley
Korn Shell (ksh) : Written by David Korn at AT&T.
Bourne Again Shell (bash) : The default shell for RedHat Linux. We will find
many of the extra features of all the above shells – these include –
Command line completion
Command line editing
Command line h istory
Prompt control.

Labels: , ,

 
posted by Gautam at 4:30 AM, | 0 comments