Sunday, August 28, 2011

Different types of Linux Editors

Different types of Linux Editors

Different types of editors are available.Some of them are vi, emacs, joe, pico etc.

Here we are going to deal with vi editor.

VI EDITOR

#vi is the command used to open vi editor. Inorder for this editor to work successfully, one has to use both command mode and insert mode.

Command mode (press Esc key)

Insert mode (press I or Insert key)—data entering is possible only in this mode.

#vi filename opens an existing file or creates a new file

To exit from vi first go to cmnd mode (ie, press Esc), then press

:q to simply quit

:q! to quit forcefully

:w save the changes or entries given

:w newfilename - to save the file in a new name (similar to copy cmnd)

:wq to write and quit

To edit, delete & change text using a vi editor, first go to cmnd mode, then

(i) press x to delete a character from the cursor position

(ii) press dd to delete or cut a line

press 2dd deletes 2 lines from cursor position

(iii) press r to replace a character

(iv) press yy to copy text

press 4yy copy 4 lines from current cursor position

(v) press p to paste the copied or cut lines

(vi) press u undo

(vii) type :set nu to display line numbers, temporarily

(viii) type :set nonu remove the line numbers

(ix) type :sh to return to shell prompt with out leaving the vi editor. To go back to vi editor from this shell prompt, type exit

(x) :!ls used to display directory contents in vi editor.

To search a string in an editor, first go to cmnd mode, then type

/var to search a string named var in the file opened in the vi editor.

To search and replace string in an editor, first go to cmnd mode, then type

:g/redhat/s//nascent/g the word redhat is searched and replaced with nascent.

DEVICE CONFIGURATION

#timeconfig used to configure time zone

#mouseconfig to configure mouse

#setup used for configuring devices like mouse,network,printer,system services,etc

#printconf used to configure printer

#netconfig to configure network.It replaces existing configuration file (/etc/sysconfig/networking/ifcfg-eth0).

Device Configuration in X-window Mode

# system -config-time for time settings

# system -config-keyboard for keyboard settings

# system -config-languages to configure language options

# system -config-mouse configure mouse

# system -config-network configures networking

# system -config-printer to configure printer

# system -config-xfree86 works in both text and graphical mode(display card)

# system -config-sevices configure system services

# system -config-securitylevel used for firewall configuration

# system -config-soundcard configures soundcard

# system -config-users configure users and groups

# system -config-packages to install or uninstall packages(like add/remove in windows)

DISK MOUNTING

CDROM

#mount /dev/cdrom /mnt/cdrom (OR) #mount /mnt/cdromcmnd used to mount a cdrom

to read the contents of a cdrom, you have to use the cmnd

#cd /mnt/cdrom then use ls cmnd and read.

To unmount a cdrom, first u have to come out of the cdrom’s directory and then

#umount /mnt/cdrom then give the cmnd #eject

FLOPPY DISK

#mount /mnt/floppy (OR) #mount /dev/fd0 /mnt/floppy.

To unmount a floppy, use the cmnd

#umount /mnt/floppy

FDD & CDROM gets automatically mounted in the case of X-Window mode.

The file /etc/mtab contains already mounted file systems.

#mount –a mounts all file systems (other than the ones with auto)

#umount –a unmounts all file system types.

Files to be mounted at boot time:

The file named /etc/fstab contains the file system to be mounted during system startup.

#cat /etc/fstab (contains the following entries)

LABEL=/ / ext3 defaults 1 1

LABEL=/boot /boot ext3 defaults 1 2

/dev/cdrom /mnt/cdrom udf iso9668 noauto,owner,kudzu……

/dev/fd0 /mnt/floppy auto noauto owner,kudz……

This file /etc/fstab contains 6 columns.

1st column indicates device information

2nd column indicates mount points

3rd column indicates file system (FAT,ext2/3 etc)

4th column indicates mount point options available with file systems

5th column indicates dump option (ie, if it has to be checked at rebooting)

6th column indicates the order in which file system checks are done at reboot time (here 1,2…indicates the priority)

DISK PARTITIONING and FORMATING

#fdisk command used for disk management (disk partitioning tool)

#fdisk /dev/hda hard disk then press Enter key.

Command (m or ? for help):m [displays help]

:p available partitions

:n adds a new partition

:d deletes a partition

:q quit

:w write/save partitions

:l list known partition types

:t changes a partitions system id

#mkfs –t file_systemtype partition_no: -->creates a file system(cmnd used to format) eg:- #mkfs –t ext3 /dev/hda….

#tune2fs used to adjust tunable file system parameters

#e2fsck check a Linux partition manually(like scan disk in windows)

#fdformat /dev/fd0 cmnd used to format floppy disk.

RUN LEVELS

The default run level information resides in /etc/inittab and the run control scripts for all run levels resides in /etc/rc.d/…

The default run levels used by Red Hat systems is :

#init 0 halt or shut down the machine

#init 1 single user mode or the maintenance mode

#init 2 multi-user mode with out NFS

#init 3 full multi-user mode

#init 4 unused (User-Defined)

#init 5 X-window mode

#init 6 Reboot

If we edit the file /etc/inittab, then we can change the default run level.

Messaging & Scheduling Shutdown

#wall ‘message’ broadcast the message typed to all users in that n/w

#write usrname/terminal [press enter] message [press cntrl+z] used to send message to a particular user.

#write nas [press enter] Hello [press cntrl+z]will send Hello to nas

#write nas tty3 [press enter] there? [press cntrl+z]if more than one person has logged in as nas and if u want to send to a person who is in

terminal3, then this cmnd helps to do so.

#mesg n ->controls/blocks user messages (only normal users not root users)

#shutdown –f –h +60 “message” server will shutdown automatically in 60 mins

#shutdown –c will cancel the scheduled shutdown process.

PACKAGE MANAGEMENT

In x-window mode, the command used to add/remove packages is

#redhat-config-packages

In text mode, we use rpm (red hat package management) command. For this

1st mount your Linux CD #mount /mnt/cdrom

then go to the dir #cd /mnt/cdrom/RedHat/RPMS

the extension of all files in this dir will be .rpm

#rpm –ivh packagename to install the specified package

eg:- #rpm –ivh telnet-serve… .rpm to install telnet server

Here ivh install verify hash(show #)

#rpm –e packagename to remove an existing package

#rpm –Uvh packagename will install if package is absent or upgrade an existing one

#rpm –ivh - -nodeps - -force packagename install packages with out dependencies.

#rpm –qa shows all installed packages

#rpm –q packagename shows if the mentioned package is installed or not

#rpm –qa | grep ‘string’ to display installed packages that has the specified string in it

#rpm –ql file_name To display package to which that file belongs to .

After installing or removing a package, u must update using the command #updatedb

1 comment: