N25-第7周博客作业

N25-第7周博客作业

1、创建一个10G分区,并格式为ext4文件系统;

       (1) 要求其block大小为2048, 预留空间百分比为2,   卷标为MYDATA, 默认挂载属性包含acl;

       (2)   挂载至/data/mydata目录,要求挂载时禁止程序自动运行,且不更新文件的访问时间戳;

1.创建分区/dev/sdb1,容量为10G
[root@localhost ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xa5b8f2f4.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
 
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
 
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
 switch off the mode (command 'c') and change display units to
 sectors (command 'u').
 
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1435, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1435, default 1435): +10G
 
Command (m for help): w
 
 2.查看创建的分区
[root@localhost ~]# fdisk  -l /dev/sdb
 
Disk /dev/sdb: 11.8 GB, 11811160064 bytes
255 heads, 63 sectors/track, 1435 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xa5b8f2f4
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        1306    10490413+  83  Linux
   
  3.格式化
  [root@localhost ~]# mke2fs -b 2048 -m 2 -t ext4 -L MYDATA    /dev/sdb1
  4.修改分区属性
  [root@localhost ~]# tune2fs -o acl /dev/sdb1
tune2fs 1.41.12 (17-May-2010)
  5.查看分区属性
  [root@localhost ~]# dumpe2fs -h  /dev/sdb1
dumpe2fs 1.41.12 (17-May-2010)
Filesystem volume name:   MYDATA
Last mounted on:          <not available>
Filesystem UUID:          d97d8ba2-ebed-413b-a4c7-a9a0a4986fa1
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize
Filesystem flags:         signed_directory_hash 
Default mount options:    acl
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              657408
Block count:              5245206
Reserved block count:     104904
Free blocks:              5123382
Free inodes:              657397
First block:              0
Block size:               2048
Fragment size:            2048
Reserved GDT blocks:      512
Blocks per group:         16384
Fragments per group:      16384
Inodes per group:         2048
Inode blocks per group:   256
Flex block group size:    16
Filesystem created:       Wed Sep 21 17:33:07 2016
Last mount time:          n/a
Last write time:          Wed Sep 21 17:34:14 2016
Mount count:              0
Maximum mount count:      39
Last checked:             Wed Sep 21 17:33:07 2016
Check interval:           15552000 (6 months)
Next check after:         Mon Mar 20 17:33:07 2017
Lifetime writes:          226 MB
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:              256
Required extra isize:     28
Desired extra isize:      28
Journal inode:            8
Default directory hash:   half_md4
Directory Hash Seed:      043a3a0c-ac3a-4728-8bdf-e0347fa690da
Journal backup:           inode blocks
Journal features:         (none)
Journal size:             64M
Journal length:           32768
Journal sequence:         0x00000001
Journal start:            0
4.挂载
[root@localhost ~]# mount -o noexec,nodiratime  /dev/sdb1 /data/mydata/
 
5.设置开机自动挂载
[root@localhost ~]# vim /etc/fstab 
#
# /etc/fstab
# Created by anaconda on Mon Aug 22 18:25:35 2016
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/VolGroup-lv_root /                       ext4    defaults        1 1
UUID=e36e7a7c-97a5-4712-ac29-7973c98c847c /boot                   ext4    defaults        1 2
/dev/mapper/VolGroup-lv_swap swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/sdb1               /mnt                    ext4    defaults        0 0

2、创建一个大小为1G的swap分区,并创建好文件系统,并启用之;

1.查看当前swap分区大小,目前为3G
[root@c7 ~]# free -m
 total       used       free     shared    buffers     cached
Mem:          1862        303       1559          0         19        105
-/+ buffers/cache:        178       1683
Swap:         3071          0       3071
 
2.创建swap类型的分区/dev/sdb1
[root@c7 ~]# fdisk -l /dev/sdb
 
Disk /dev/sdb: 11.8 GB, 11811160064 bytes
255 heads, 63 sectors/track, 1435 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xa5b8f2f4
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         132     1060258+  82  Linux swap / Solaris
3.转换为交换分区
[root@c7 ~]# mkswap /dev/sdb1
Setting up swapspace version 1, size = 1060252 KiB
no label, UUID=898c07c8-5460-44d5-9ae9-049568b339bc
4.启动交换分区
[root@c7 ~]# swapon /dev/sdb1
5.再次查看交换分区。变成了4G
[root@c7 ~]# free -m
 total       used       free     shared    buffers     cached
Mem:          1862        304       1558          0         19        105
-/+ buffers/cache:        179       1683
Swap:         4107          0       4107

    3、写一个脚本

       (1)、获取并列出当前系统上的所有磁盘设备;

       (2)、显示每个磁盘设备上每个分区相关的空间使用信息;

#!/bin/bash
#show dev info
for dev in $(fdisk -l|grep -o "^/dev/[[:alnum:]]\{3,\}");do
   echo   $dev 
   echo -e "$(df -h  $dev)\n"
done

    4、总结RAID的各个级别及其组合方式和性能的不同;

blob.png

    5、创建一个大小为10G的RAID1,要求有一个空闲盘,而且CHUNK大小为128k;

1.创建2个raid类型的分区,/dev/sdc1,/dev/sdd1,/dev/sde1,创建raid1
[root@c7 ~]# mdadm -C -l 1 -c 128 -n 2 -x 1 /dev/sdc1 /dev/sdd1 /dev/sde1
mdadm: device /dev/sdc1 exists but is not an md array.
[root@c7 ~]# mdadm -C /dev/md0  -l 1 -c 128 -n 2 -x 1 /dev/sdc1 /dev/sdd1 /dev/sde1
mdadm: Note: this array has metadata at the start and
may not be suitable as a boot device.  If you plan to
store '/boot' on this device please ensure that
your boot-loader understands md/v1.x metadata, or use
--metadata=0.90
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
 
2.查看raid信息
[root@c7 ~]# mdadm -D /dev/md0  
/dev/md0:
Version : 1.2
  Creation Time : Mon Sep 26 20:03:48 2016
 Raid Level : raid1
 Array Size : 10482112 (10.00 GiB 10.73 GB)
  Used Dev Size : 10482112 (10.00 GiB 10.73 GB)
   Raid Devices : 2
  Total Devices : 3
Persistence : Superblock is persistent
 
Update Time : Mon Sep 26 20:04:21 2016
  State : clean, resyncing 
 Active Devices : 2
Working Devices : 3
 Failed Devices : 0
  Spare Devices : 1
 
  Resync Status : 28% complete
 
   Name : bogon:0  (local to host bogon)
   UUID : c63aeb60:7f098351:3ed32a55:e3caca40
 Events : 4
 
Number   Major   Minor   RaidDevice State
   0       8       33        0      active sync   /dev/sdc1
   1       8       49        1      active sync   /dev/sdd1
 
   2       8       65        -      spare   /dev/sde

 6、创建一个大小为4G的RAID5设备,chunk大小为256k,格式化ext4文件系统,要求可开机自动挂载至/backup目录,而且不更新访问时间戳,且支持acl功能;

1.创建3个raid类型的分区,/dev/sdd1,/dev/sdd2,/dev/sde1,创建raid5
[root@c7 ~]# mdadm -C /dev/md0 -l 5 -c 256 -n 3 /dev/sdd1 /dev/sdd2 /dev/sde1
2.格式化为ext4
[root@c7 ~]# mke2fs -t ext4 /dev/md0
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=64 blocks, Stripe width=128 blocks
525200 inodes, 2098304 blocks
104915 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2151677952
65 block groups
32768 blocks per group, 32768 fragments per group
8080 inodes per group
Superblock backups stored on blocks: 
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
 
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
 
This filesystem will be automatically checked every 29 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
 
3.设置开机自动挂载
[root@c7 ~]# vim /etc/fstab 
#
# /etc/fstab
# Created by anaconda on Mon Aug 22 18:25:35 2016
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/VolGroup-lv_root /                       ext4    defaults        1 1
UUID=e36e7a7c-97a5-4712-ac29-7973c98c847c /boot                   ext4    defaults        1 2
/dev/mapper/VolGroup-lv_swap swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/md0                /backup                 ext4    defaults,nodiratime,acl  0 0

    7、写一个脚本

       (1) 接受一个以上文件路径作为参数;

       (2) 显示每个文件拥有的行数;

       (3) 总结说明本次共为几个文件统计了其行数;

#!/bin/bash
#sum file line
if [ $# -lt 2 ];then
 echo "please input in least two file:"
 exit 2
else
   for i in $@;do
  if [ -e $i ] && [ -f $i ];then
echo " `wc -l $i`"
  else
  echo "no such file or this is diretory"
  fi
   done
fi
 
echo " the file number is:" $#

    8、写一个脚本

       (1) 传递两个以上字符串当作用户名;

       (2) 创建这些用户;且密码同用户名;

       (3) 总结说明共创建了几个用户;

!/bin/bash
if [ $# -lt 2 ]; then
  echo "At least two username."
  exit 2
fi
declare -x num=0;
for i in $@;do
   if  grep "^$i\>" /etc/passwd &> /dev/null; then
   echo "User $i exists"
   else
  useradd $i
  let num++
  echo $i | passwd --stdin $i &> /dev/null
  echo "Add user $i finished."
   fi
done
echo "Adding user number is:"$nu

    9、写一个脚本,新建20个用户,visitor1-visitor20;计算他们的ID之和;

#!/bin/bash
for user in {1..20};do
 useradd visitor$user
 a=`id -u visitor$user`
 sum=$[$sum+$a]
done
 echo $sum

      10、写一脚本,分别统计/etc/rc.d/rc.sysinit、/etc/rc.d/init.d/functions和/etc/fstab文件中以#号开头的行数之和,以及总的空白行数;

#!/bin/bash
for file in /etc/rc.d/rc.sysinit /etc/rc.d/init.d/functions /etc/fstab;do
a=$(grep "^#" $file |wc -l)
b=$(grep "^$" $file |wc -l)
echo "$file  $a  $b"
done

    11、写一个脚本,显示当前系统上所有默认shell为bash的用户的用户名、UID以及此类所有用户的UID之和;

#!/bin/bash
a=`grep "\<bash\>$" /etc/passwd |cut -d: -f3`
b=`grep "\<bash\>$" /etc/passwd |cut -d: -f 1,3`
echo -e "$b\n"
for i in $a;do
sum=$[$sum+$i]
done
echo  "uid sum is:"$sum

    12、写一个脚本,显示当前系统上所有,拥有附加组的用户的用户名;并说明共有多少个此类用户;

#!/bin/bash
 declare i=0
for user in $(cat /etc/passwd |cut -d: -f 1);do
   id $user |grep ","
  if [ $? -eq 0 ];then
  echo "$user"
  let i++
  fi
done
  echo  "the users is:" $i

      13、创建一个由至少两个物理卷组成的大小为20G的卷组;要求,PE大小为8M;而在卷组中创建一个大小为5G的逻辑卷mylv1,格式化为ext4文件系统,开机自动挂载至/users目录,支持acl;

1.创建分区/dev/sdb1,/dev/sdb2
[root@c7 ~]# fdisk -l /dev/sdb
Disk /dev/sdb: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x7e26fae5
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        1306    10490413+  83  Linux
/dev/sdb2            1307        2612    10490445   83  Linux
[root@c7 ~]# 
2.创建pv
[root@c7 ~]# pvcreate  /dev/sdb{1,2}
  dev_is_mpath: failed to get device for 8:17
  Physical volume "/dev/sdb1" successfully created
  dev_is_mpath: failed to get device for 8:18
  Physical volume "/dev/sdb2" successfully create
3.创建卷组vg0,pe大小为8m
[root@c7 ~]# vgcreate -s 8 vg0 /dev/sdb1 /dev/sdb2
  Volume group "vg0" successfully created
 4.查看vg信息
 [root@c7 ~]# vgdisplay 
  --- Volume group ---
  VG Name               vg0
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               20.00 GiB
  PE Size               8.00 MiB
  Total PE              2560
  Alloc PE / Size       0 / 0   
  Free  PE / Size       2560 / 20.00 GiB
  VG UUID               FvNYvj-86jM-1LJz-pyph-2vfv-LuGN-eMs3pI
  5.创建lv逻辑卷mylv1,大小为5G
  [root@c7 ~]# lvcreate -L 5g -n mylv1 /dev/vg0
  Logical volume "mylv1" created
[root@c7 ~]# lvdisplay 
  --- Logical volume ---
  LV Path                /dev/vg0/mylv1
  LV Name                mylv1
  VG Name                vg0
  LV UUID                8XmMvG-3Psh-3GnR-H9MD-ZwVh-smGH-MEr3mW
  LV Write Access        read/write
  LV Creation host, time MiWiFi-R1CM-srv, 2016-09-26 00:20:53 +0800
  LV Status              available
  # open                 0
  LV Size                5.00 GiB
  Current LE             640
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
  6.格式化为ext4格式     
  [root@c7 ~]# mke2fs -t ext4 /dev/vg0//mylv1  
  mke2fs 1.41.12 (17-May-2010)
  Filesystem label=
  OS type: Linux
  Block size=4096 (log=2)
  Fragment size=4096 (log=2)
  Stride=0 blocks, Stripe width=0 blocks
  327680 inodes, 1310720 blocks
  65536 blocks (5.00%) reserved for the super user
  First data block=0
  Maximum filesystem blocks=1342177280
  40 block groups
  32768 blocks per group, 32768 fragments per group
  8192 inodes per group
  Superblock backups stored on blocks: 
32768, 98304, 163840, 229376, 294912, 819200, 884736
 
  Writing inode tables: done                            
  Creating journal (32768 blocks): done
  Writing superblocks and filesystem accounting information: done
 
  This filesystem will be automatically checked every 24 mounts or
  180 days, whichever comes first.  Use tune2fs -c or -i to override.
  7.配置开机自动挂载
  # /etc/fstab
# Created by anaconda on Sun Sep 25 20:18:18 2016
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=f98e4337-9bbe-4d63-914b-1265dd7a9ddd /                       ext4    defaults        1 1
UUID=dc2e05ac-e97a-4369-83b6-a06cd6c32c3d swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/vg0/mylv1                  /users          ext4    defaults,acl    0 0

    14、新建用户magedu;其家目录为/users/magedu,而后su切换至此用户,复制多个文件至家目录;

[root@c7 ~]# useradd -d /users/magedu  magedu
[root@c7 ~]# su - magedu
[root@c7 ~]$ cp /etc/init
init/    init.d/  inittab  
[root@c7 ~]$ cp /etc/init
init/    init.d/  inittab  
[root@c7 ~]$ cp  -r /etc/init.d/* /users/magedu/
[root@c7 ~]$ cd /users/magedu/
[root@c7 ~]$ ls
abrt-ccpp         crond         irqbalance      nfs          rngd        snmptrapd
abrtd             cups          kdump           nfslock      rpcbind     spice-vdagentd
abrt-oops         dnsmasq       killall         ntpd         rpcgssd     sshd
acpid             firstboot     lvm2-lvmetad    ntpdate      rpcidmapd   sssd
atd               functions     lvm2-monitor    oddjobd      rpcsvcgssd  sysstat
auditd            haldaemon     mdmonitor       portreserve  rsyslog     udev-post
autofs            halt          messagebus      postfix      sandbox     wdaemon
blk-availability  htcacheclean  netconsole      psacct       saslauthd   winbind
bluetooth         httpd         netfs           quota_nld    single      wpa_supplicant
certmonger        ip6tables     network         rdisc        smartd      ypbind
cpuspeed          iptables      NetworkManager  restorecond  snmpd

    15、扩展mylv1至9G,确保扩展完成后原有数据完全可用;

[root@c7 ~]# lvextend -L +4G /dev/vg0/mylv1 
  Extending logical volume mylv1 to 9.00 GiB
  Logical volume mylv1 successfully resized
[root@c7 ~]# cd /users/magedu/
[root@c7 ~]# resize2fs /dev/vg0/mylv1 
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg0/mylv1 is mounted on /users; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/vg0/mylv1 to 2359296 (4k) blocks.
^[[CThe filesystem on /dev/vg0/mylv1 is now 2359296 blocks long.
 
[root@c7 ~]# df -h
Filesystem             Size  Used Avail Use% Mounted on
/dev/sda2               17G  3.3G   13G  21% /
tmpfs                  936M   72K  936M   1% /dev/shm
/dev/mapper/vg0-mylv1  8.9G  140M  8.3G   2% /users
[root@c7 ~]# ls
abrt-ccpp         crond         irqbalance      nfs          rngd        snmptrapd
abrtd             cups          kdump           nfslock      rpcbind     spice-vdagentd
abrt-oops         dnsmasq       killall         ntpd         rpcgssd     sshd
acpid             firstboot     lvm2-lvmetad    ntpdate      rpcidmapd   sssd
atd               functions     lvm2-monitor    oddjobd      rpcsvcgssd  sysstat
auditd            haldaemon     mdmonitor       portreserve  rsyslog     udev-post
autofs            halt          messagebus      postfix      sandbox     wdaemon
blk-availability  htcacheclean  netconsole      psacct       saslauthd   winbind
bluetooth         httpd         netfs           quota_nld    single      wpa_supplicant
certmonger        ip6tables     network         rdisc        smartd      ypbind
cpuspeed          iptables      NetworkManager  restorecond  snmpd

    16、缩减mylv1至7G,确保缩减完成后原有数据完全可用;

1.卸载
[root@c7 ~]# umount /dev/vg0/mylv1 
2.检查
[root@c7 ~]# e2fsck -f /dev/vg0/mylv1 
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/vg0/mylv1: 85/589824 files (0.0% non-contiguous), 72765/2359296 blocks
3.重设大小
[root@c7 ~]# resize2fs /dev/vg0/mylv1  7G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/vg0/mylv1 to 1835008 (4k) blocks.
The filesystem on /dev/vg0/mylv1 is now 1835008 blocks long.
4.减小逻辑卷大小
[root@c7 ~]# lvcreate -L 7G /dev/vg0/mylv1 
  Volume group name expected (no slash)
  Run `lvcreate --help' for more information.
[root@c7 ~]# lvreduce  -L 7G /dev/vg0/mylv1 
  WARNING: Reducing active logical volume to 7.00 GiB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce mylv1? [y/n]: y  
  Reducing logical volume mylv1 to 7.00 GiB
  Logical volume mylv1 successfully resized
5.重新挂载,并查看大小
[root@c7 ~]# mount -a
[root@c7 ~]# df -h
Filesystem             Size  Used Avail Use% Mounted on
/dev/sda2               17G  3.3G   13G  21% /
tmpfs                  936M   72K  936M   1% /dev/shm
/dev/mapper/vg0-mylv1  6.9G  140M  6.5G   3% /users

    17、对mylv1创建快照,并通过备份数据;要求保留原有的属主属组等信息;

1.创建快照
[root@c7 ~]# lvcreate -L 1G -p r  -s -n sn_mylv1 /dev/vg0/mylv1 
  Logical volume "sn_mylv1" created
2.将快照挂载至/backup
[root@c7 ~]# mount /dev/vg0/sn_mylv1 /back/
mount: block device /dev/mapper/vg0-sn_mylv1 is write-protected, mounting read-only
[root@c7 ~]# cd /back/
[root@c7 ~]# ls
lost+found  magedu
[root@c7 ~]# cd magedu/
[root@c7 ~]# ls
abrt-ccpp         crond         irqbalance      nfs          rngd        snmptrapd
abrtd             cups          kdump           nfslock      rpcbind     spice-vdagentd
abrt-oops         dnsmasq       killall         ntpd         rpcgssd     sshd
acpid             firstboot     lvm2-lvmetad    ntpdate      rpcidmapd   sssd
atd               functions     lvm2-monitor    oddjobd      rpcsvcgssd  sysstat
auditd            haldaemon     mdmonitor       portreserve  rsyslog     udev-post
autofs            halt          messagebus      postfix      sandbox     wdaemon
blk-availability  htcacheclean  netconsole      psacct       saslauthd   winbind
bluetooth         httpd         netfs           quota_nld    single      wpa_supplicant
certmonger        ip6tables     network         rdisc        smartd      ypbind
cpuspeed          iptables      NetworkManager  restorecond  snmpd
[root@c7 ~]# mkdir /backup2
[root@c7 ~]# ls
abrt-ccpp         crond         irqbalance      nfs          rngd        snmptrapd
abrtd             cups          kdump           nfslock      rpcbind     spice-vdagentd
abrt-oops         dnsmasq       killall         ntpd         rpcgssd     sshd
acpid             firstboot     lvm2-lvmetad    ntpdate      rpcidmapd   sssd
atd               functions     lvm2-monitor    oddjobd      rpcsvcgssd  sysstat
auditd            haldaemon     mdmonitor       portreserve  rsyslog     udev-post
autofs            halt          messagebus      postfix      sandbox     wdaemon
blk-availability  htcacheclean  netconsole      psacct       saslauthd   winbind
bluetooth         httpd         netfs           quota_nld    single      wpa_supplicant
certmonger        ip6tables     network         rdisc        smartd      ypbind
cpuspeed          iptables      NetworkManager  restorecond  snmpd
 
[root@c7 ~]# cd ..
[root@c7 ~]# ll
total 20
drwx------. 2 root   root   16384 Sep 26 00:23 lost+found
drwx------. 4 magedu magedu  4096 Sep 26 00:40 magedu
3.将快照的文件复制至/backup2
[root@c7 ~]# cp -a magedu/  /backup2/
[root@c7 ~]# cd /backup2
[root@c7 ~]# ls
magedu
4.查看权限,没有改变
[root@c7 ~]# ll
total 4
drwx------. 4 magedu magedu 4096 Sep 26 00:40 magedu
[root@c7 ~]# cd magedu/
[root@c7 ~]# ls
abrt-ccpp         crond         irqbalance      nfs          rngd        snmptrapd
abrtd             cups          kdump           nfslock      rpcbind     spice-vdagentd
abrt-oops         dnsmasq       killall         ntpd         rpcgssd     sshd
acpid             firstboot     lvm2-lvmetad    ntpdate      rpcidmapd   sssd
atd               functions     lvm2-monitor    oddjobd      rpcsvcgssd  sysstat
auditd            haldaemon     mdmonitor       portreserve  rsyslog     udev-post
autofs            halt          messagebus      postfix      sandbox     wdaemon
blk-availability  htcacheclean  netconsole      psacct       saslauthd   winbind
bluetooth         httpd         netfs           quota_nld    single      wpa_supplicant
certmonger        ip6tables     network         rdisc        smartd      ypbind
cpuspeed          iptables      NetworkManager  restorecond  snmpd

原创文章,作者:oranix,如若转载,请注明出处:http://www.178linux.com/66965

(0)
上一篇 2017-01-20 16:06
下一篇 2017-01-22 10:10

相关推荐

  • Linux磁盘管理

    一、磁盘管理总体分类  1)磁盘结构  2)分区类型  3)管理分区 4)管理文件系统  5)挂载设备 6)管理虚拟内存 ……………………………………………………………………………………………………………………… 重要分类模块详解 ………………………………………………………………………………………………………………………

    Linux干货 2016-08-29
  • grep和正则表达式

    grep       作用:文本搜索工具,根据用户指定的“模式(过滤条件)”对目标文件逐行进行匹配检查;打印匹配到的行;       模式:由正则表达式的元字符及文本所编写出的过滤条件    语法:【选项】【文件】  &…

    2017-08-04
  • DNS 笔记

    Ø DNS查询。工作流程如下图         n  客户端的DNS:8.8.8.8 /etc/hosts  14.215.177.38 www.baidu.com n  客户端访问www.baidu.com 不用向DSN服务器发生查询,只需要查询本地的 /e…

    Linux干货 2016-08-15
  • 文本处理工具grep

    正则表达式:Regular Expression REGEXP         由一类特殊字符及文本字符所编写的模式,表示控制或通配的功能 两类:     基本正则表达式BRE:     扩展正则表达式ERE: *** grep    GLoble searc…

    Linux干货 2016-08-04
  • bash中的变量

        对任何一门编程语言来说,最基础的部分就是变量。那什么事变量呢?变量就是把一个已知的可以变动的值,赋给一个固定名字的,用固定的名字代表这个可变动的值。在bash中也不例外,跟大多数编程语言一样,它也有一些自己的语法和规则 bash变量:     1.规则设置:变量和变量的值中间用=连接,=的两…

    Linux干货 2016-08-15
  • java基础与环境

    java 简述 java基础 jvm java环境搭建 简述 什么是java? java是一门面向对象的编程语言,具有简单性、面向对象、分布式、健壮性、安全性、平台独立与可移植性、多线程、动态性等特点,特别是可移植性,java所有的代码都需要在一个特定的虚拟环境中实现,所以可移植性方面非常好,一次编译,永久使用。 java可以做到什么? Java可以编写桌面…

    2016-06-24

评论列表(1条)

  • 马哥教育
    马哥教育 2017-04-10 16:00

    总结的很好,脚本的思路清晰,加油~~~