Everything is Linux

Saturday, September 20, 2008

Secure Shell

Normally for logging in to any Linux  PCs, we use Telnet or ftp.But Communication will be happen in normal text mode.Any network hackers or network sniffers can hack our password.
Best method of logging remotely is Secure Shell(ssh).
In ssh login , Communication is happened through encrypted form.
Through this ssh connection, we can able to login to any Linux box without password also if configured.
This ssh service is run by sshd daemon.This is the daemon which is enabled by default.
Command Syntax : # ssh linux.test.com (where linux.test.com is the remote server)
After this command execution ,it will ask to add the generated  RSA key to  the file known_hosts in ~/.sshd/ Give yes to that line.then it will ask for password. Give password of root.
Now you are connected to remote linux server.
Even 
a.We can copy files from remote server and vice versa without logging in .
b.We can login without passwords.
These two will be discussed in coming post.

Tuesday, September 16, 2008

VNC configuration in RHEL 4 and RHEL 5

First enable service "vncserver" on Server
#chkconfig vncserver on

Restart the service
#service vncserver start

#vncserver
New ':1 (root)' desktop is Server_Ip_Address:1

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/Server_Ip_Address:3.log

#vncpasswd
Password:
Verify:

# vim /root/.vnc/xstartup
The entry should look like as follows,

#!/bin/sh

# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
#xsetroot -solid grey
#vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &


Now u can view through vnc viewer using Server_Ip_Address:1

Thursday, September 11, 2008

What is in /etc/fstab?

The file fstab contains descriptive information about the various file systems. It is the duty of the system administrator to properly create and main-tain this file. fstab can be modified by special utils (e.g. fstab-sync). Each filesystem is described on a separate line; fields on each line are separated by tabs or spaces. Lines starting with # are comments. The order of records in fstab is important because fsck, mount, and umount sequentially iterate through fstab doing their thing.

The first field, (fs_spec), describes the block special device or remote filesystem to be mounted.
A block special device node (like /dev/cdrom or /dev/sdb7. For procfs, use proc.

The second field, (fs_file), describes the mount point for the filesystem. For swap partitions, this field should be specified as none.

The third field, (fs_vfstype), describes the type of the filesystem. Linux supports lots of filesystem types, such as adfs, affs, autofs, coda, coher-ent, cramfs, devpts, efs, ext2, ext3, hfs, hpfs, iso9660, jfs, minix, msdos, ncpfs, nfs, ntfs, proc, qnx4, reiserfs, romfs, smbfs, sysv, tmpfs, udf,ufs, umsdos, vfat, xenix, xfs, and possibly others.

For the filesystems currently supported by the running kernel, see /proc/filesystems. An entry swap denotes a file or partition to be used for swapping, cf. swapon (8). An entry ignore causes the line to be ignored.This is useful to show disk partitions which are currently unused.

The fourth field describes the mount options associated with the filesystem. By Default, it will be defaults.

The fifth field is used for these filesystems by the dump command to determine which filesystems need to be dumped. If the fifth field is not present, a value of zero is returned and dump will assume that the filesystem does not need to be dumped.

The sixth field is used by the fsck program to determine the order in which filesystem checks are done at reboot time. The root filesystem should be specified with a fs_passno of 1, and other filesystems should have a fs_passno of 2. Filesystems within a drive will be checked sequentially, but filesystems on different drives will be checked at the same time to utilize parallelism available in the hardware. If the sixth field is not present or zero, a value of zero is returned and fsck will assume that the filesystem does not need to be checked.

Wednesday, September 10, 2008

What is Iptables ?

iptables - Administration tool for IPv4 packet filtering and NAT

Iptables  is  used  to set up, maintain, and inspect the tables of IP packet filter rules in the Linux kernel.  Several different tables may be defined.Each table contains a number of built-in chains and may also contain user-defined chains.
Each chain is a list of rules which can match a set of packets.  Each rule specifies what to do with a packet that matches.  This is called a  target,which may be a jump to a user-defined chain in the same table.

A  firewall  rule  specifies  criteria for a packet, and a target.  If the packet does not match, the next rule in the chain is the examined; if it does match, then the next rule is specified by the value of the target, which can be the name of a user-defined chain or one of the  special  values  ACCEPT,DROP, QUEUE, or REJECT

Tuesday, September 9, 2008

Some Basic Commands in Linux

Basics commands in Linux

The ls command

ls        -----      Command is equivalent of the DOS dir command. It lists the files and subdirectories contained within the present directory.

Some possible flags which can be used with the ls command are:

ls -a                List all files including hidden files which starts with.(Dot).these hidden files will not be displayed with simple ls command

ls | more         Lists files and directories page after page on keystroke. The above command actually is a combination of two commands. It introduces a new concept called 'Piping'. It is done using the logical OR or | character found just above the Enter key on your keyboard. In Linux it is possible to give the output of one command to another command as an input. The ls command lists files & subdirectories and the more commands divides its input into page length views. Thus piping the ls output to more results in page length views of files and subdirectories.

ls –R            It lists the files and subdirectories of a directory and further lists the contents of each subdirectory recursively. The output of this command is usually large and is best seen when piped through more.

pwd            The pwd or the present working directory command gives you the path to the directory in which you presently are. It is used without flags simply as 'pwd'

su                Many times you might have logged in as a normal used and might need to be root to install a software or for some other small task. You could logout then login as root complete the work logout and login back as a normal user. Instead, you can just use the su command. The format is:

su username
e.g.: su root

When you 'su' to become root from a normal user, you are asked for the root password. But if you are root, you can use 'su' to become any user without using a password. Once your work is finished, use 'exit' to become yourself.

whoami     It will tell you which user you are logged in as. Useful when you have used 'su' many times and now don't know who you are.

cp              This one copies files / directories from one place to another its syntax is

cp source_file_with_path destination_path

e.g.: cp /home/bala/secret.txt /ftp/pub

This would make a copy of secrets.txt from /home/bala to /ftp/pub.

cp –i         Interactive copying, prompts before overwriting files or directories

cp -l source_file_with_path destination_path

Makes a link (shortcut) to the source_file at the destination path instead of actually copying it there.

cp –p        Preserve file attributes while copying if possible

cp –R       Copy Recursively. Used when copying directories. This command also copies the contents of the subdirectories.

cp –u       Update i.e. Copy only if the source file is newer than the destination file or the destination file does not exist.

rm           The rm command is used to remove or delete files or directories. Its general format is:

rm -flag file_or_directory_with_path

Eg: rm /home/bala/recycle.txt

Some flags which can be used with the rm command are

rm -v test.txt

Remove verbosely, explain what is being done.

rm -r directory

Remove the directory and its contents recursively.

mkdir                 This command is used to create new a new directory. Its syntax is

mkdir -optional_flag directory_name

The possible flags are

mkdir -v directory_name

Tell what is going on.

mkdir -p directory_with_path

This is a cool command. Suppose you need a directory named data  within another directory called report in /usr/local and the parent directory report itself does not exist, then you can use :

mkdir -p /usr/local/report/data

This command creates the report directory and the data subdirectory in one go.

man         For someone new to linux, the man command is one of the most important commands. The syntax is:

man command_name

Suppose you have not understood fully one of the above commands or want to find out about a new command you have learnt, the man command provides a manual for that command