guo20082200的个人博客分享 http://blog.sciencenet.cn/u/guo20082200

博文

linux_centos第8 次课

已有 3611 次阅读 2015-8-6 22:59 |个人分类:Linux学习|系统分类:科研笔记| style

8次课

压缩打包

压缩

压缩成.gz 文件gzip命令

 

[root@localhost /]#mkdir guohuiqiang

[root@localhost /]# ls

aming.log  etc         lost+found  proc    sbin    strong[root@localhost  var

bin        guohuiqiang  media      pub     selinux  sys

boot       home         mnt         public srv      tmp

dev        lib          opt         root   strong   usr

[root@localhost /]# cdguohuiqiang

[root@localhostguohuiqiang]# ls

[root@localhostguohuiqiang]# cp -p /etc/passwd /

[root@localhostguohuiqiang]# cp -p /etc/passwd .

[root@localhostguohuiqiang]# ls

passwd

[root@localhostguohuiqiang]# cp -p /etc/fstab .

[root@localhostguohuiqiang]# cp -p /etc/inittab .

[root@localhostguohuiqiang]# ls

fstab  inittab passwd

[root@localhostguohuiqiang]# gzip fstab

[root@localhostguohuiqiang]# ls

fstab.gz  inittab passwd(后缀是.gz文件)

[root@localhostguohuiqiang]# gunzip fstab

[root@localhostguohuiqiang]# ls

fstab  inittab passwd

bzip2命令

[root@localhostguohuiqiang]# bzip2 inittab

[root@localhostguohuiqiang]# ls

fstab inittab.bz2 passwd(后缀是.bz2

[root@localhostguohuiqiang]# bunzip2 inittab.bz2

[root@localhostguohuiqiang]# ls

fstab  inittab passwd

最好的压缩方式.zip压缩,可以在windows上解压

[root@localhostguohuiqiang]# zip passwd.zip passwd

 adding: passwd (deflated 59%)

[root@localhostguohuiqiang]# ls

fstab  inittab passwd  passwd.zip(原文件还在)

zip可以压缩目录,前面两个命令bzip2gzip不能压缩目录

[root@localhostguohuiqiang]# mkdir guo

[root@localhostguohuiqiang]# cd guo.

-bash: cd: guo.: Nosuch file or directory

[root@localhostguohuiqiang]# cd guo/

[root@localhostguo]# cp ../* .copy上一级目录的所有内容到当前目录)

cp: omitting directory `../guo'

[root@localhost guo]#ls

aming.log  fstab inittab  passwd  passwd.zip

[root@localhost guo]#cd ..

[root@localhostguohuiqiang]# ls

aming.log  fstab guo  inittab  passwd passwd.zip

[root@localhostguohuiqiang]# zip guo.zip guo

 adding: guo/ (stored 0%)

[root@localhostguohuiqiang]# ls

aming.log  fstab guo  guo.zip  inittab  passwd passwd.zip

[root@localhostguohuiqiang]# zip -r guo.zip guozip压缩目录需要加–r的参数)

updating: guo/ (stored0%)

 adding: guo/inittab (deflated 47%)

 adding: guo/fstab (deflated 54%)

 adding: guo/aming.log (stored 0%)

 adding: guo/passwd (deflated 59%)

 adding: guo/passwd.zip (stored 0%)

[root@localhostguohuiqiang]# ls

aming.log  fstab guo  guo.zip  inittab passwd  passwd.zip

[root@localhost guo]#ls

aming.log  fstab inittab  passwd  passwd.zip

[root@localhost guo]#rm -rf *

[root@localhost guo]#ls

[root@localhost guo]#mv ../passwd.zip .

[root@localhost guo]#ls

passwd.zip

[root@localhostguo]# unzip passwd.zip (解压缩)

Archive:  passwd.zip

 inflating: passwd

[root@localhost guo]#ls

passwd  passwd.zip

打包命令tar

[root@localhostguo]# ls

passwd  passwd.zip

[root@localhost guo]# tar -cvf guo.tar passwd passwd.zip

cvf c-createv是过程, f-file,文件

passwd

passwd.zip

[root@localhostguo]# ls

guo.tar  passwd passwd.zip

[root@localhost guo]# tar -tvf guo.tar

-rw-r--r--root/root      1469 2015-07-30 19:27passwd

-rw-r--r--root/root       762 2015-08-06 05:58passwd.zip

即压缩又打包,tar只能和gzipbzip2配合,不能和zip配合。

[root@localhost guohuiqiang]# tar -zcvfgzip-hezuo.tar.gz fatab inittab guo passwd               tar: fatab: Cannot stat: No suchfile or directory

inittab

guo/

guo/passwd

guo/passwd.zip

guo/guo.tar

passwd

tar:Exiting with failure status due to previous errors

[root@localhostguohuiqiang]# ls

aming.log  fstab guo  guo.zip  gzip-hezuo.tar.gz  inittab passwd

 

[root@localhost guohuiqiang]# tar -zxvf gzip-hezuo.tar.gz -C /opt/-C 指定压缩路径)

inittab

guo/

guo/passwd

guo/passwd.zip

guo/guo.tar

passwd

[root@localhostguohuiqiang]# cd /opt/

[root@localhostopt]# ls

guo  inittab passwd  rh

 

 

系统启动流程    如果系统启动出现了问题,知道系统启动到了那里出现了错误。

 

第一步:开电源,先启动bios(基本输入输出系统),加电自检,会检测显卡,内存,cpu

第二步:会寻找启动磁盘,有启动级别,从硬盘启动,

第三步:寻找第一个启动扇区,住引导记录,就是MBR

MBR512字节,有3部分组成:

1.      引导程序 446字节

2.      分区表  64字节16个字节是一个分区表,最多是4个分区

3.      校验码  2 字节

[root@localhost guohuiqiang]# dd if=/dev/sda of=/mbr bs=1 count=512

512+0records in

512+0records out

512bytes (512 B) copied, 0.00474296 s, 108 kB/s

 

[root@localhost guohuiqiang]# hexdump -C /mbr(查看mbr的命令)

00000000  eb 48 90 10 8e d0 bc 00  b0 b8 00 00 8e d8 8e c0  |.H..............|

00000010  fb be 00 7c bf 00 06 b9  00 02 f3 a4 ea 21 06 00  |...|.........!..|

00000020  00 be be 07 38 04 75 0b  83 c6 10 81 fe fe 07 75  |....8.u........u|

00000030  f3 eb 16 b4 02 b0 01 bb  00 7c b2 80 8a 74 03 02  |.........|...t..|

00000040  80 00 00 80 ea 89 04 00  00 08 fa 90 90 f6 c2 80  |................|

00000050  75 02 b2 80 ea 59 7c 00  00 31 c0 8e d8 8e d0 bc  |u....Y|..1......|

00000060  00 20 fb a0 40 7c 3c ff  74 02 88 c2 52 f6 c2 80  |. ..@|<.t...R...|

00000070  74 54 b4 41 bb aa 55 cd  13 5a 52 72 49 81 fb 55  |tT.A..U..ZRrI..U|

00000080  aa 75 43 a0 41 7c 84 c0  75 05 83 e1 01 74 37 66  |.uC.A|..u....t7f|

00000090  8b 4c 10 be 05 7c c6 44  ff 01 66 8b 1e 44 7c c7  |.L...|.D..f..D|.|

000000a0  04 10 00 c7 44 02 01 00  66 89 5c 08 c7 44 06 00  |....D...f...D..|

000000b0  70 66 31 c0 89 44 04 66  89 44 0c b4 42 cd 13 72  |pf1..D.f.D..B..r|

000000c0  05 bb 00 70 eb 7d b4 08  cd 13 73 0a f6 c2 80 0f  |...p.}....s.....|

000000d0  84 f0 00 e9 8d 00 be 05  7c c6 44 ff 00 66 31 c0  |........|.D..f1.|

000000e0  88 f0 40 66 89 44 04 31  d2 88 ca c1 e2 02 88 e8  |..@f.D.1........|

000000f0  88 f4 40 89 44 08 31 c0  88 d0 c0 e8 02 66 89 04  |..@.D.1......f..|

00000100  66 a1 44 7c 66 31 d2 66  f7 34 88 54 0a 66 31 d2  |f.D|f1.f.4.T.f1.|

00000110  66 f7 74 04 88 54 0b 89  44 0c 3b 44 08 7d 3c 8a  |f.t..T..D.;D.}<.|

00000120  54 0d c0 e2 06 8a 4c 0a  fe c1 08 d1 8a 6c 0c 5a  |T.....L......l.Z|

00000130  8a 74 0b bb 00 70 8e c3  31 db b8 01 02 cd 13 72  |.t...p..1......r|

00000140  2a 8c c3 8e 06 48 7c 60  1e b9 00 01 8e db 31 f6  |*....H|`......1.|

00000150  31 ff fc f3 a5 1f 61 ff  26 42 7c be 7f 7d e8 40  |1.....a.&B|..}.@|

00000160  00 eb 0e be 84 7d e8 38  00 eb 06 be 8e 7d e8 30  |.....}.8.....}.0|

00000170  00 be 93 7d e8 2a 00 eb  fe 47 52 55 42 20 00 47  |...}.*...GRUB .G|

00000180  65 6f 6d 00 48 61 72 64  20 44 69 73 6b 00 52 65  |eom.Hard Disk.Re|

00000190  61 64 00 20 45 72 72 6f  72 00 bb 01 00 b4 0e cd  |ad. Error.......|

000001a0  10 ac 3c 00 75 f4 c3 00  00 00 00 00 00 00 00 00  |..<.u...........|

000001b0  00 00 00 00 00 00 00 00  2c 2a 08 00 00 00 80 20  |........,*..... |

000001c0  21 00 83 5e 38 26 00 08  00 00 00 60 09 00 00 5e  |!..^8&.....`...^|

000001d0  39 26 83 fe ff ff 00 68  09 00 00 98 37 02 00 fe  |9&.....h....7...|

000001e0  ff ff 82 fe ff ff 00 00  41 02 00 00 3f 00 00 00  |........A...?...|

000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55aa  |..............U.|

00000200                                     (校验码55 aa

 

内核肯定会大于446字节,小程序(boot loader)加载内核

Lilo   Grub  grub基本取代了lilo

/boot 下面有个grub的文件夹

[root@localhostguohuiqiang]# cd /boot

[root@localhostboot]# ls

aming_soft                  grub                              symvers-2.6.32-431.el6.i686.gz

config-2.6.32-431.el6.i686  initramfs-2.6.32-431.el6.i686.img  System.map-2.6.32-431.el6.i686

efi                         lost+found                        vmlinuz-2.6.32-431.el6.i686

[root@localhostboot]# ll

total22051

lrwxrwxrwx.1 root root        9 Aug  4 18:26 aming_soft -> aming.log

-rw-r--r--.1 root root   109953 Nov 21  2013 config-2.6.32-431.el6.i686

drwxr-xr-x.3 root root     1024 Jul 30 05:17 efi

drwxr-xr-x. 2 root root    1024 Jul 29 21:25 grub

-rw-------.1 root root 16269122 Jul 30 05:25 initramfs-2.6.32-431.el6.i686.img

drwx------.2 root root    12288 Jul 30 05:10lost+found

-rw-r--r--.1 root root   190104 Nov 21  2013 symvers-2.6.32-431.el6.i686.gz

-rw-r--r--.1 root root  1982877 Nov 21  2013 System.map-2.6.32-431.el6.i686

-rwxr-xr-x.1 root root  4002656 Nov 21  2013 vmlinuz-2.6.32-431.el6.i686

[root@localhost boot]# cd grub

[root@localhost grub]# ls

device.map     grub.conf         minix_stage1_5     stage2

e2fs_stage1_5  iso9660_stage1_5  reiserfs_stage1_5  ufs2_stage1_5

fat_stage1_5   jfs_stage1_5      splash.xpm.gz      vstafs_stage1_5

ffs_stage1_5   menu.lst         stage1             xfs_stage1_5

最主要的是stage1,然后由stage1加载stage1_5,然后加载stage2

 

另一个文件grub.conf grub的配置文件,立即修改,立即生效,不用重启电脑

(lilo需要重启电脑)

-rw-------.1 root root  763 Jul 30 05:22 grub.conf

查看grub文件

[root@localhost grub]# vim grub.conf

grub.confgenerated by anaconda

#

#Note that you do not have to rerun grub after making changes to this file

#NOTICE:  You have a /boot partition.  This means that

#          all kernel and initrd paths arerelative to /boot/, eg.

#          root (hd0,0)

#          kernel /vmlinuz-version roroot=/dev/sda2

#          initrd /initrd-[generic-]version.img

#boot=/dev/sda

default=0

timeout=5

splashimage=(hd0,0)/grub/splash.xpm.gz

hiddenmenu

title CentOS (2.6.32-431.el6.i686)

       root(hd0,0)hd0 代表第一块硬盘,0是第一个分区)

       kernel (相对路径,在boot/grub下面)/vmlinuz-2.6.32-431.el6.i686 ro root=UUID=7a8b8919-2614-4e67-ba15-63dc72549cc6rd_NO_LUKS rd_NO_LVM.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16crashkernel=auto  KEYBOARDTYPE=pcKEYTABLE=us rd_NO_DM rhgb quiet

       initrd /initramfs-2.6.32-431.el6.i686.img(静态驱动)

 

[root@localhostgrub]# df -h

Filesystem      Size Used Avail Use% Mounted on

/dev/sda2        18G 2.7G   14G  16% /

tmpfs           504M   72K 504M   1% /dev/shm

/dev/sda1       291M   33M 244M  12% /boot (boot分区,第一快硬盘的第一个分区)

 

初始化,执行/etc/inittab文件

 

#Default runlevel. The runlevels used are:

#   0 - halt (Do NOT set initdefault to this)

#   1 - Single user mode

#   2 - Multiuser, without NFS (The same as 3,if you do not have networking)

#   3 - Full multiuser mode

#   4 - unused

#   5 - X11

#   6 - reboot (Do NOT set initdefault to this)

#

id:5:initdefault:(默认值是5

 

 

[root@localhostgrub]# cd /etc

[root@localhostetc]# ls

abrt                     fprintd.conf    my.cnf                        rpc

acpi                     fstab           nanorc                        rpm

adjtime                  gai.conf        NetworkManager                rsyslog.conf

aliases                  gconf           networks                      rsyslog.d

aliases.db               gcrypt          nsswitch.conf                 rwtab

alsa                     gdm             ntp                           rwtab.d

alternatives             ghostscript     ntp.conf                      samba

anacrontab               gnome-vfs-2.0   obex-data-server              sane.d

asound.conf              gnupg           openldap                      sasl2

at.deny                  group           opt                           scl

audisp                   group-          PackageKit                    securetty

audit                    grub.conf       pam.d                         security

avahi                    gshadow         pango                         selinux

bash_completion.d        gshadow-        passwd                        services

bashrc                   gtk-2.0         passwd-                       sestatus.conf

blkid                    hal             passwd.OLD                    setuptool.d

bluetooth                host.conf       pbm2ppa.conf                  sgml

bonobo-activation        hosts           pcmcia                        shadow

centos-release           hosts.allow     pinforc                       shadow-

chkconfig.d              hosts.deny      pkcs11                        shells

ConsoleKit               hp              pki                           skel

cron.d                   httpd           plymouth                      smartd.conf

cron.daily               init            pm                            snmp

cron.deny                init.d          pm-utils-hd-apm-restore.conf  sos.conf

cron.hourly              inittab         pnm2ppa.conf                  sound

cron.monthly             inputrc         polkit-1                      ssh

crontab                  iproute2        popt.d                        ssl

cron.weekly              issue           portreserve                   statetab

crypttab                 issue.net       postfix                       statetab.d

csh.cshrc                kdump-adv-conf  ppp                           sudo.conf

csh.login                kdump.conf      prelink.cache                 sudoers

cups                     krb5.conf       prelink.conf                  sudoers.d

dbus-1                   ld.so.cache     prelink.conf.d                sudo-ldap.conf

default                  ld.so.conf      printcap                      sysconfig

depmod.d                 ld.so.conf.d    profile                       sysctl.conf

dhcp                     libaudit.conf   profile.d                     system-release

DIR_COLORS               libreport       protocols                     system-release-cpe

DIR_COLORS.256color      libuser.conf    pulse                         terminfo

DIR_COLORS.lightbgcolor  localtime       quotagrpadmins                tpvmlp.conf

dnsmasq.conf             login.defs      quotatab                      udev

dnsmasq.d                logrotate.conf  rc                            updatedb.conf

dracut.conf              logrotate.d     rc0.d                         vimrc

dracut.conf.d            lvm             rc1.d                         virc

drirc                    magic           rc2.d                         vmware-tools

enscript.cfg             mailcap         rc3.d                         warnquota.conf

environment              mail.rc         rc4.d                         wgetrc

ethers                   makedev.d       rc5.d                         wpa_supplicant

event.d                  man.config      rc6.d                         X11

exports                  mime.types      rc.d                         xdg

favicon.png              mke2fs.conf     rc.local                      xinetd.d

festival                 modprobe.d      rc.sysinit                    xml

filesystems              motd            readahead.conf                yum

fonts                    mtab            redhat-release                yum.conf

foomatic                 mtools.conf     resolv.conf                   yum.repos.d

[root@localhost etc]# ls rc5.d(非常关键)

K01smartd        K75quota_nld       S12rsyslog           S50bluetooth

K05wdaemon       K84wpa_supplicant  S13cpuspeed          S55sshd

K10psacct        K87restorecond     S13irqbalance        S57vmware-tools-thinprint

K10saslauthd     K89rdisc           S15mdmonitor         S70spice-vdagentd

K15htcacheclean  K99rngd            S20kdump             S80postfix

K15httpd         S01sysstat         S22messagebus        S82abrt-ccpp

K50dnsmasq       S02lvm2-monitor    S23NetworkManager    S82abrtd

K50netconsole    S03vmware-tools    S25blk-availability  S90crond

K50snmpd         S08ip6tables       S25cups              S95atd

K50snmptrapd     S08iptables        S25netfs             S99firstboot

K73winbind       S10network         S26acpid             S99local

K74ntpd          S11auditd          S26haldaemon

K75ntpdate       S11portreserve     S26udev-post

 

 

[root@localhost etc]# vim rc.sysinit

[root@localhost etc]# vim rc.local 系统初始化的时候最后加载的一个配置文件

 

系统登录:会执行四个文件,决定了家用户的一些信息,和环境变量

Vim /etc/bashrc

Vim /etc/profile

Vim /root/,bash_profile

Vim /root/.bashrc (环境变量),将其删除,无法登陆。


 


查看系统启动级别:

[root@localhostetc]# runlevel

N5



8.docx



https://blog.sciencenet.cn/blog-575910-911157.html

上一篇:linux_centos第六次课
下一篇:第7次课
收藏 IP: 61.164.211.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-9-28 07:24

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部