设为首页 收藏本站
查看: 422|回复: 0

[经验分享] CentOS System Administration Essentials

[复制链接]
累计签到:161 天
连续签到:1 天
发表于 2016-11-17 15:44:05 | 显示全部楼层 |阅读模式
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.

***************************************************************************
dd if=/dev/sda of=/tmp/sda.mbr count=1 bs=512 #备份mbr

dd if=/dev/zero of=/dev/sda count=1 bs=512 #注意:该命令会删除MBR,慎用。

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

default=0
timeout=5
hiddenmenu
password --md5 <password-hash>

grub-md5-crypt
*********************************************************************************************


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-301662-1-1.html 上篇帖子: Linux系统调优 下篇帖子: 文本处理cat more less head tail sort uniq grep cut jion sed awk
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表