Search This Blog

Wednesday, January 6, 2016

Linux

iostat = to monitor i/o at disks

mpstat = microprocessor activity

vmstat = virtual memory

netstat = network activity

swapon -s = swap memory usage

top = to view most resource consuming processes

free = to view free space available


$head
is used to display top lines of the file
$head -10 filename

$tail 
to see the last lines of a file

$tail -20 filename

$cal
is used to display calendar
$cal -3 --> displays previous, current and next months calendar


Some usefull files:
/etc/group -> group settings

/etc/hosts -> hostname information

/etc/exports -> it states how partitions are mounted and shared with other Linux/Unix systems.

/etc/fstab -> this file automatically mounts filesystems that are spread across multiple drives

/etc/inittab -> describes which processes are started at bootup or at different runlevels.

/etc/passwd -> contains user information

/etc/shells -> contains the names of all the shells installed on the system

/etc/ftpusers -> contains the login names of users who are not allowed to log in by way of FTP

/etc/shadow -> it contains encrypted passwords are stored in /etc/shadow

/etc/profile -> This file contains settings and global startup info the bash shell

/etc/crontab -> Lists commands and times to run them for the cron deamon

/var/log/messages -> The main system message log file

/var/spool/mail -> where mailboxes are usually stored

/etc/resolv.conf -> Configures the name resolver, specifying the address of your name server and your domain name.

/etc/sysconfig/network -> Defines a network interface

/proc/version -> The kernel version

/etc/redhat-release -> Includes one line stating the Red Hat release number and name



vi EDITOR

vi editor is used to make new text files, scripting files or modifying contents of existing files.

modes of vi editor: command mode, execution mode

command mode:

i - to start insertion from current cursor position
I - to start editing from beginning of line
a - to append contents to right side of your current cursor position
A - to append contents to the end of the current cursor line
r - to replace a char from current cursor position
R - to replace a whole word from current cursor position
x - to remove the char from current cursor position
dd - to remove or to delete a line
2dd - to remove 2 lines from current cursor position
yy - to copy the line of current cursor position
2yy - to copy 2 lines from current cursor position
p - to paste the copied content to after cursor position
P - to paste the content above the cursor line
u - to undo previous operations
dgg - to remove or delete above lines including current cursor line till beginning of file
dG - to remove or delete below lines including current cursor line till end of file
l - to move cursor to character by character at a time
h - to move cursor back char by char
k - to move cursor to above line
j - to go to next line
H - to go to end of the file
G - to go to beginning of file

Execution mode
esc - to go to execution mode
:w - to save changes in the file
:q - to quit from the file
:wq - to save and quit
:x - to save and quit
:wq! - Forcibly save changes in the file and quit
:%s/oldtext/newtext/g - to replace all oldtext with newtext in the file
:se no - to display line number
:no se - to hide line number


Partitioning with fdisk
fdisk -l  - to view all available partitions
fdisk -l /dev/sda - view partitions of a specific hard disk 
fdisk -s /dev/sda - to view the size of an existing partition
mkfs.ext3 /dev/sda - after partition is created, format it using the mkfs command
partprobe /dev/sda - It will update in kernel
mount /dev/sda /u03 - mount on a particular directory
Save the /etc/fstab file.(To make partition permanent)
/dev/sda /u03 ext3 defaults 0 0

fsck /dev/sda2 - To repair a corrupted file system.

1 comment: