今天呢,我过得非常的充实,我们的谢导游,教会了我们很多东西,今天几乎是没有停过打命令的。这样的感觉我很喜欢,也谢谢谢导游教会了我们那么多。
那今天的作业呢,如下:1.新增4个用户u1 u2 u3 u4.并查看配置文件是否账号增加成功。禁用u2,测试效果;再重新启u2,测试效果;
[root@bogon home]# ls
dwb u1 u2 u3 u4
[root@bogon home]# tail /etc/shadow
avahi:!!:17007::::::
postfix:!!:17007::::::
ntp:!!:17007::::::
sshd:!!:17007::::::
tcpdump:!!:17007::::::
dwb:$6$jO9BfdRARAx.sMh4$TXJhdUpWHdh50qWnKLNo5agqrQ8FkupKI3tM1pbAadkM9C1cC4BKXw32AEGea2F5i6AI1DcbS6Nv5HekD4jhp/::0:99999:7:::
u1:!!:17009:0:99999:7:::
u2:!!:17009:0:99999:7:::
u3:!!:17009:0:99999:7:::
u4:!!:17009:0:99999:7:::
[root@bogon home]# passwd u2
Changing password for user u2.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
Sorry, passwords do not match.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@bogon home]# usermod -L u2
[root@bogon home]# su u1
[u1@bogon home]$ su u2
Password:
su: Authentication failure
2.删除账号u1及家目录。
[root@bogon home]# userdel u1
userdel: user u1 is currently used by process 3785
[root@bogon home]# groups u1
u1 : u1
[root@bogon home]# userdel -r u1
userdel: user u1 is currently used by process 3785
[root@bogon home]# ^C
[root@bogon home]# ^C
[root@bogon home]# ls
dwb u2 u3 u4
3.修改u3的密码为:mashen
[root@bogon home]# passwd u3
Changing password for user u3.
New password:
BAD PASSWORD: The password fails the dictionary check - it is based on a dictionary word
Retype new password:
Sorry, passwords do not match.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[root@bogon home]# su u2
[u2@bogon home]$ su u3
Password:
[u3@bogon home]$
4.新增组g1,g2,把用户u2加入g2组,并把g1组删除了。
[root@bogon /]# groupadd g1
[root@bogon /]# groupadd g2
[root@bogon /]# gpasswd -a u2 g2
Adding user u2 to group g2
[root@bogon /]# groups u2
u2 : u2 g2
[root@bogon /]# groupdel g1
[root@bogon /]# tail /etc/group
tcpdump:x:72:
stapusr:x:156:
stapsys:x:157:
stapdev:x:158:
dwb:x:1000:dwb
u1:x:1001:
u2:x:1002:
u3:x:1003:
u4:x:1004:
g2:x:1006:u2
5.使用root用户新建文件aa,并在aa中使用vi编辑器写入“welcome to java5!”。
[root@bogon /]# touch aa
[root@bogon /]# ls
aa bin boot dev disk1 etc home iso lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
[root@bogon /]# vi aa
6.然后针对aa授权,把文件所有者由root改成u3,把文件所属组改成g2,所有者拥有所有权限,所属组g2能写入,其他的用户u4只能查看。
[root@bogon /]# ls -l
total 44
-rw-r--r--. 1 root root 20 Jul 28 09:26 aa
lrwxrwxrwx. 1 root root 7 Jul 25 12:15 bin -> usr/bin
dr-xr-xr-x. 3 root root 4096 Jul 27 17:24 boot
drwxr-xr-x. 19 root root 3300 Jul 28 08:45 dev
drwxr-xr-x. 2 root root 30 Jul 27 17:00 disk1
drwxr-xr-x. 136 root root 8192 Jul 28 09:23 etc
drwxr-xr-x. 6 root root 43 Jul 28 08:56 home
drwxr-xr-x. 2 root root 6 Jul 25 17:02 iso
lrwxrwxrwx. 1 root root 7 Jul 25 12:15 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 Jul 25 12:15 lib64 -> usr/lib64
drwxr-xr-x. 2 root root 6 May 25 2015 media
drwxr-xr-x. 2 root root 6 May 25 2015 mnt
drwxr-xr-x. 5 root root 62 Jul 27 11:38 opt
dr-xr-xr-x. 508 root root 0 Jul 28 08:44 proc
dr-xr-x---. 15 root root 4096 Jul 28 08:46 root
drwxr-xr-x. 37 root root 1140 Jul 28 08:47 run
lrwxrwxrwx. 1 root root 8 Jul 25 12:15 sbin -> usr/sbin
drwxr-xr-x. 2 root root 6 May 25 2015 srv
dr-xr-xr-x. 13 root root 0 Jul 28 08:45 sys
drwxrwxrwt. 64 root root 8192 Jul 28 09:15 tmp
drwxr-xr-x. 13 root root 4096 Jul 25 12:15 usr
drwxr-xr-x. 20 root root 4096 Jul 28 08:44 var
[root@bogon /]# chown u3:g2 aa
[root@bogon /]# ls -l
total 44
-rw-r--r--. 1 u3 g2 20 Jul 28 09:26 aa
lrwxrwxrwx. 1 root root 7 Jul 25 12:15 bin -> usr/bin
dr-xr-xr-x. 3 root root 4096 Jul 27 17:24 boot
drwxr-xr-x. 19 root root 3300 Jul 28 08:45 dev
drwxr-xr-x. 2 root root 30 Jul 27 17:00 disk1
drwxr-xr-x. 136 root root 8192 Jul 28 09:23 etc
drwxr-xr-x. 6 root root 43 Jul 28 08:56 home
drwxr-xr-x. 2 root root 6 Jul 25 17:02 iso
lrwxrwxrwx. 1 root root 7 Jul 25 12:15 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 Jul 25 12:15 lib64 -> usr/lib64
drwxr-xr-x. 2 root root 6 May 25 2015 media
drwxr-xr-x. 2 root root 6 May 25 2015 mnt
drwxr-xr-x. 5 root root 62 Jul 27 11:38 opt
dr-xr-xr-x. 508 root root 0 Jul 28 08:44 proc
dr-xr-x---. 15 root root 4096 Jul 28 08:46 root
drwxr-xr-x. 37 root root 1140 Jul 28 08:47 run
lrwxrwxrwx. 1 root root 8 Jul 25 12:15 sbin -> usr/sbin
drwxr-xr-x. 2 root root 6 May 25 2015 srv
dr-xr-xr-x. 13 root root 0 Jul 28 08:45 sys
drwxrwxrwt. 64 root root 8192 Jul 28 09:15 tmp
drwxr-xr-x. 13 root root 4096 Jul 25 12:15 usr
drwxr-xr-x. 20 root root 4096 Jul 28 08:44 var
[root@bogon /]# chmod 724 aa
[root@bogon /]# ls -l
total 44
-rwx-w-r--. 1 u3 g2 20 Jul 28 09:26 aa
lrwxrwxrwx. 1 root root 7 Jul 25 12:15 bin -> usr/bin
dr-xr-xr-x. 3 root root 4096 Jul 27 17:24 boot
drwxr-xr-x. 19 root root 3300 Jul 28 08:45 dev
drwxr-xr-x. 2 root root 30 Jul 27 17:00 disk1
drwxr-xr-x. 136 root root 8192 Jul 28 09:23 etc
drwxr-xr-x. 6 root root 43 Jul 28 08:56 home
drwxr-xr-x. 2 root root 6 Jul 25 17:02 iso
lrwxrwxrwx. 1 root root 7 Jul 25 12:15 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 Jul 25 12:15 lib64 -> usr/lib64
drwxr-xr-x. 2 root root 6 May 25 2015 media
drwxr-xr-x. 2 root root 6 May 25 2015 mnt
drwxr-xr-x. 5 root root 62 Jul 27 11:38 opt
dr-xr-xr-x. 509 root root 0 Jul 28 08:44 proc
dr-xr-x---. 15 root root 4096 Jul 28 08:46 root
drwxr-xr-x. 37 root root 1140 Jul 28 08:47 run
lrwxrwxrwx. 1 root root 8 Jul 25 12:15 sbin -> usr/sbin
drwxr-xr-x. 2 root root 6 May 25 2015 srv
dr-xr-xr-x. 13 root root 0 Jul 28 08:45 sys
drwxrwxrwt. 64 root root 8192 Jul 28 09:15 tmp
drwxr-xr-x. 13 root root 4096 Jul 25 12:15 usr
drwxr-xr-x. 20 root root 4096 Jul 28 08:44 var
这是第一个作业哦
然后第二个作业呢就是2.文件与磁盘管理有关
A、使用虚拟机新增一个15G磁盘,把磁盘格式成xfs,新建一个目录disk,并开机能自动挂载到这上目录;
B、通过winscp中考备一个winscp的安装exe文件到这个disk目录中
C、把disk中通过securecrt把这个文件下载到windows本地
[root@bogon ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 10G 3.0G 7.0G 31% /
devtmpfs 475M 0 475M 0% /dev
tmpfs 489M 144K 489M 1% /dev/shm
tmpfs 489M 7.1M 482M 2% /run
tmpfs 489M 0 489M 0% /sys/fs/cgroup
/dev/sdb1 2.0G 33M 2.0G 2% /disk1
/dev/sda3 28G 33M 28G 1% /opt
tmpfs 98M 12K 98M 1% /run/user/0
/dev/sr0 3.8G 3.8G 0 100% /run/media/root/RHEL-7.2 Server.x86_64
[root@bogon ~]# fdisk /dev/sdc
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x245a0783.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-31457279, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-31457279, default 31457279):
Using default value 31457279
Partition 1 of type Linux and of size 15 GiB is set
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@bogon ~]# mkfs.xfs /dev/sdc1
meta-data=/dev/sdc1 isize=256 agcount=4, agsize=982976 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=3931904, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@bogon ~]# mkdir /disk1
mkdir: cannot create directory ‘/disk1’: File exists
[root@bogon ~]# mkdir /disk
[root@bogon ~]# mount /dev/sdc1 /disk
[root@bogon ~]# vi /etc/fstab
#
# /etc/fstab
# Created by anaconda on Mon Jul 25 12:14:46 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=c49842e7-390b-44cb-95f6-c882f2e1283b / xfs defaults 0 0
UUID=11c1cccc-a2c8-480c-84ef-cda54a866714 /opt xfs defaults 0 0
/dev/sdc1 /disk xfs defaults 0 0
/dev/sdb1 /disk1 xfs defaults 0 0
UUID=ac29e365-5a12-415f-b660-656a13f47897 swap swap defaults 0 0
~
~
~
~
~
~
~
"/etc/fstab" 13L, 632C
[root@bogon ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 10G 3.0G 7.0G 30% /
devtmpfs 475M 0 475M 0% /dev
tmpfs 489M 144K 489M 1% /dev/shm
tmpfs 489M 7.1M 482M 2% /run
tmpfs 489M 0 489M 0% /sys/fs/cgroup
/dev/sdb1 2.0G 33M 2.0G 2% /disk1
/dev/sda3 28G 33M 28G 1% /opt
tmpfs 98M 8.0K 98M 1% /run/user/0
/dev/sr0 3.8G 3.8G 0 100% /run/media/root/RHEL-7.2 Server.x86_64
/dev/sdc1 15G 33M 15G 1% /disk
[root@bogon ~]#