1.Taming Vi
cd dir1 || mkdir dir1 && cd dir1
cd dir1 || mkdir !$ && cd !$
mkdir dir1
cd !$ #The !$ part represents the last argument,it means cd dir1
!?73 #!$ symbols to represent the last argument or the part of the argument
date --date "73 days ago"
***************************************************************
1.Vim is a contraction of Vi IMproved and was first publicly released in 1991
2.it is distributed with the vim-enhanced package
3.install the graphical interface for Vim, you will need to add the vim-X11 package as follows:
# yum install -y vim-X11
***************************************************************
Vim read settings from /etc/vimrc(or ~/.vimrc)
Vi read settings from /etc/virc
**********************************************************************
在每个用户的根目录下有bash_history,所以切换用户后使用历史命令时注意
**********************************************************************
vi +97 test.php
vi +/install readme
:nohlsearch 取消关键词高亮(Vim中)
set nohlsearch(配置文件中)
:set number(:set nu) 显示行号
:set nonumber(:set nonu)
use 2G or 2gg to navigate to line 2 of the current file
**********************************************************************
Search and replace
sed -i 's/Dungeons/Dragons/g' /path/file
:%s/Dungeons/Dragons/g
:3,12s/Dungeons/Dragons/g
**********************************************************************
egrep -c '^#' httpd.conf
sed -i '/^#/d' httpd.conf
:g/^#/d
**********************************************************************
2.Cold Stars
Lilo: This is the original Linux loader
EXTLinux: This is part of the SYSLinux family that includes the following:
EXTLinux to boot from fixed drives
ISOLinux to boot from CDs and DVDs
SYSLinux to boot from a USB device
PXELinux to boot from the network
GRUB2: More recently, this is making its appearance as a replacement to
GRUB, or what is now referred to as the legacy GRUB. GRUB2 is likely to
debut in CentOS 7 in 2014.
The GRUB bootloader is most commonly stored in the MBR of the bootable drive.
The MBR makes up the first 512 bytes of the disk, allowing up to 466 bytes of storage
for the bootloader; the additional space will be used to store the partition table for
that drive.
lsblk /dev/sda #lsblk reads from memory and not the disk. lsblk disply the partition table
dd if=/tmp/sda.mbr of=/dev/sda #恢复MBR
/boot/grub/menu.lst # OS menu
*****************************************************************************
menu.lst:
Each entry in the GRUB menu is known as a stanza
1.root
2.kernel
3.initd
*****************************************************************************
title Red Hat Enterprise Linux 6 (2.6.32-573.el6.i686)# title 后面显示的内容没有引号
root directive:
This identifies the root filesystem to GRUB and not the OS root; in simple terms,
this should point to the partition that is marked as bootable in the partition table.
display the bootable partition:
fdisk -l /dev/sda
parted /dev/sda print
(The fdisk shows the bootable partition with * and parted
with the word boot.)
****************************************************************************************
The legacy GRUB,for example, cannot access a filesystem built on Logical Volume Management
(LVM); this is the default partitioning proposal in CentOS 6. The same applies
to software Redundant Array of Inexpensive Disks (RAID) arrays.
*****************************************************************************************
title Red Hat Enterprise Linux 6 (2.6.32-573.el6.i686)
root (hd0,0)
GRUB should mount the first partition on the first
drive (both the drive and partition numbering starts at 0) as the bootable partition
*****************************************************************************************
内网地址
192.168.0.0 -- 192.168.255.255
172.16.0.0 -- 172.31.255.255
10.0.0.0 -- 10.255.255.255
******************************************************************************************
view the version of the kernel with either of the following commands:
cat /proc/version
uname -r
display which the kernel was booted
cat /proc/cmdline
******************************************************************************************
the initrd directive will point to the initialization
RAM disk; a mini OS that is compiled with the drivers needed to access the OS
root filesystem.
The RAM disk can be recompiled if the root filesystem changes or the
drivers need to access the hardware change with the mkinitrd command.
******************************************************************************************
To recover a forgotten root password, we can boot the system to runlevel 1;
by default, this will log you in directly as root.
1. Firstly, we must select the entry in the menu to boot to. If there is more than
one, do not use the Enter key.
2. With the menu entry highlighted, choose the letter a.
3. This will take you directly to the end of the kernel line where you can add
the number 1 to boot to runlevel 1.
******************************************************************************************
edit the /etc/sysconfig/init file by changing the SINGLE=/sbin/sushell line to the following:
SINGLE=/sbin/sulogin
If sulogin has been set and you still need emergency access
as root, it is possible by specifying init=/bin/bash instead
of 1 as the runlevel.
********************************************************************************************
grub> setup(hd0)
The preceding command will check to see if /boot/grub/stage1 or /grub/stage1
exists on the bootable partition. This way, it determines which partition to use as
root and copies the stage1 file to the MBR complete with the drivers needed to
access the bootable partition. We can then choose to restart the system with the
reboot command.
*******************************************************************************************
/boot/grub/grub.conf
/boot/grub/menu.lst
/etc/grub.conf
*******************************************************************************************
default=0
timeout=5
hiddenmenu
password=secret