0713

来源:互联网 发布:域名后缀cc 编辑:程序博客网 时间:2024/04/30 18:51

1、用户组与权限管理

 

A、新增4个用户u1 u2 u3 u4.并查看配置文件是否账号增加成功。禁用u2,测试效果;再重新启u2,测试效果;

[root@bogon ~]# useradd u1

[root@bogon ~]# useradd u2

[root@bogon ~]# useradd u3

[root@bogon ~]# useradd u4

[root@bogon ~]# tail /etc/shadow

avahi:!!:16993::::::

postfix:!!:16993::::::

ntp:!!:16993::::::

sshd:!!:16993::::::

tcpdump:!!:16993::::::

xuyilong:$6$F2UKKjXxkXoyYvAQ$b6S6yw.VIhblC6iulMLoxp64R6HjxngRK91Oc4q3SJ2g64Ase6/HKdqEiCFomfQpPb.BnGs74jRFoRJlTqyHt1::0:99999:7:::

u1:!!:16995:0:99999:7:::

u2:!!:16995:0:99999:7:::

u3:!!:16995:0:99999:7:::

u4:!!:16995:0:99999:7:::

[root@bogon ~]# usermod -L u2

[root@bogon ~]# su u1

[u1@bogon root]$ su u2

Password:

su: Authentication failure

[u1@bogon root]$ exit

[root@bogon ~]# usermod -U u2

[root@bogon ~]# su u1

[u1@bogon root]$ su u2

Password:

[u2@bogon root]$

 

B、删除账号u1及家目录。

[root@bogon ~]# userdel -r u1

 

C、修改u3的密码为:mashen

[root@bogon ~]# passwd u3

Changing password for user u3.

New password:

BAD PASSWORD: The password is shorter than 8 characters

Retype new password:

passwd: all authentication tokens updated successfully.

 

D、新增组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 ~]# groupdel g1

 

E、使用root用户新建文件aa,并在aa中使用vi编辑器写入“welcome to java5!”。

 

[root@bogon Desktop]# vi aa

 

 

F、然后针对aa授权,把文件所有者由root改成u3,把文件所属组改成g2,所有者拥有所有权限,所属组g2能写入,其他的用户u4只能查看。

 

[root@bogon Desktop]# ls -l

total 828

-rw-r--r--. 1 root root     18 Jul 13 18:59 aa

[root@bogon Desktop]# chmod 724 aa

[root@bogon Desktop]# chown u3:g2 aa

[root@bogon Desktop]# ls -l

total 828

-rwx-w-r--. 1 u3   g2       18 Jul 13 18:59 aa

 

 

 

2、文件与磁盘管理有关

 

A、使用虚拟机新增一个15G磁盘,把磁盘格式成xfs,新建一个目录disk,并开机能自动挂载到这上目录;

 

[root@bogon /]# fdisk /dev/sdb

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 0xfe79098f.

 

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/sdb1

meta-data=/dev/sdb1              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 disk

[root@bogon /]# mount /dev/sdb1 /disk

[root@bogon /]# vi /etc/fstab

 

 

#

# /etc/fstab

# Created by anaconda on Mon Jul 11 11:58:58 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/rhel-root   /                       xfs     defaults        0 0

/dev/mapper/rhel-opt    /opt                    xfs     defaults        0 0

/dev/sdb1               /disk                   xfs     defaults        0 0

/dev/mapper/rhel-swap   swap                    swap    defaults        0 0

~

"/etc/fstab" 12L, 520C written

[root@bogon /]#

 

 

 

 

 

 

B、通过winscp中考备一个winscp的安装exe文件到这个disk目录中

 

 

 

C、把disk中通过securecrt把这个文件下载到windows本地

 

sftp> cd /disk

sftp> pwd

/disk

sftp> lcd E:\winscp

sftp> Lpwd

E:/winscp

sftp> ls   

winscp575windowsLinux文件传输.exe

sftp> get winscp575windowsLinux文件传输.exe

Downloading winscp575windowsLinux文件传输.exe from /disk/winscp575windowsLinux文件传输.exe

  100% 5724KB   5724KB/s 00:00:00     

/disk/winscp575windowsLinux文件传输.exe: 5861512 bytes transferred in 0 seconds (5724 KB/s)

sftp> 

0 0
原创粉丝点击