Linux 2 unit7 挂载网络共享

简介:

##挂载网络共享###

###文件的共享(samba)###

[root@localhost mnt]# yum install samba-client.x86_64 -y   ##

Loaded plugins: langpacks

Resolving Dependencies

--> Running transaction check

---> Package samba-client.x86_64 0:4.2.3-10.el7 will be installed

--> Processing Dependency: samba-common = 4.2.3-10.el7 for package: samba-client-4.2.3-10.el7.x86_64

--> Processing Dependency: samba-common = 4.2.3-10.el7 for package: samba-client-4.2.3-10.el7.x86_64

 

Installed:

  samba-client.x86_64 0:4.2.3-10.el7               

 

Dependency Installed:

  samba-client-libs.x86_64 0:4.2.3-10.el7          

  samba-common-libs.x86_64 0:4.2.3-10.el7          

  samba-common-tools.x86_64 0:4.2.3-10.el7                      

 

Complete!

[root@localhost mnt]# smbclient -L //172.25.254.250    ##共享此ip下的文件

Enter root's password:

Domain=[MYGROUP] OS=[Unix] Server=[Samba 4.1.1]

 

Sharename       Type      Comment

---------       ----      -------

westos1         Disk      test share

westos2         Disk      test share

westos3         Disk      test share

westos4         Disk      test share

westos5         Disk      test share

westos6         Disk      test share

westos7         Disk      test share

westos8         Disk      test share

westos9         Disk      test share

westos10        Disk      test share

IPC$            IPC       IPC Service (Samba Server Version 4.1.1)

Domain=[MYGROUP] OS=[Unix] Server=[Samba 4.1.1]

 

Server               Comment

---------            -------

 

Workgroup            Master

---------            -------

[root@localhost mnt]# smbclient //172.25.254.250/westos1  ##进入到westos1

Enter root's password:

Domain=[MYGROUP] OS=[Unix] Server=[Samba 4.1.1]

smb: \> ls

  .                                   D        0  Sun Apr 30 01:32:45 2017

  ..                                  D        0  Wed Dec  2 20:43:01 2015

 

100221120 blocks of size 1024. 21820400 blocks available

smb: \> !ls    ##查看本机有什么

creat_user.sh  passwd  userfile

file.sh        rule    westos

smb: \> put file.sh

putting file file.sh as \file.sh (32.7 kb/s) (average 32.7 kb/s)

smb: \> exit

[root@localhost ~]# mount //172.25.254.250/westos1 /mnt -o username=guest

[root@localhost ~]# touch xiao

[root@localhost ~]# cd mnt/

[root@localhost mnt]# touch xiao

[root@localhost mnt]# rm -f  xiao

[root@localhost mnt]# df

Filesystem               1K-blocks     Used Available Use% Mounted on

/dev/vda1                 10473900  4230560   6243340  41% /

devtmpfs                    922268        0    922268   0% /dev

tmpfs                       942660       84    942576   1% /dev/shm

tmpfs                       942660    17028    925632   2% /run

tmpfs                       942660        0    942660   0% /sys/fs/cgroup

/dev/sr0                   3654720  3654720         0 100% /run/media/root/RHEL-7.0 Server.x86_64

//172.25.254.250/westos1 100221120 78405328  21815792  79% /mnt

[root@localhost mnt]# touch file1

[root@localhost mnt]# touch file2

[root@localhost mnt]# exit

 

###开机自动挂载###

[root@localhost ~]# vim /etc/fstab

wKioL1kIFIjQj8aiAACQ-UILp-Q201.png-wh_50

[root@localhost ~]# df

Filesystem               1K-blocks     Used Available Use% Mounted on

/dev/vda1                 10473900  4230600   6243300  41% /

devtmpfs                    922268        0    922268   0% /dev

tmpfs                       942660       84    942576   1% /dev/shm

tmpfs                       942660    17028    925632   2% /run

tmpfs                       942660        0    942660   0% /sys/fs/cgroup

/dev/sr0                   3654720  3654720         0 100% /run/media/root/RHEL-7.0 Server.x86_64

//172.25.254.250/westos1 100221120 78407756  21813364  79% /mnt

[root@localhost ~]# mount -a

[root@localhost ~]# df

Filesystem               1K-blocks     Used Available Use% Mounted on

/dev/vda1                 10473900  4230600   6243300  41% /

devtmpfs                    922268        0    922268   0% /dev

tmpfs                       942660       84    942576   1% /dev/shm

tmpfs                       942660    17028    925632   2% /run

tmpfs                       942660        0    942660   0% /sys/fs/cgroup

/dev/sr0                   3654720  3654720         0 100% /run/media/root/RHEL-7.0 Server.x86_64

//172.25.254.250/westos1 100221120 78407756  21813364  79% /mnt

 

 

做下次实验室时保证实验环境干净##

[root@localhost ~]# vim /etc/fstab

[root@localhost ~]# mount -a

[root@localhost ~]# umount /mnt/

[root@localhost ~]# df

Filesystem     1K-blocks    Used Available Use% Mounted on

/dev/vda1       10473900 4230584   6243316  41% /

devtmpfs          922268       0    922268   0% /dev

tmpfs             942660      84    942576   1% /dev/shm

tmpfs             942660   17028    925632   2% /run

tmpfs             942660       0    942660   0% /sys/fs/cgroup

/dev/sr0         3654720 3654720         0 100% /run/media/root/RHEL-7.0 Server.x86_64

 

 

###nfs-utils共享软件

[root@localhost ~]# yum install nfs-utils.x86_64 -y    ##安装nfs共享软件

Loaded plugins: langpacks

Resolving Dependencies

--> Running transaction check

---> Package nfs-utils.x86_64 1:1.3.0-0.el7 will be updated

---> Package nfs-utils.x86_64 1:1.3.0-0.21.el7 will be an update

--> Processing Dependency: gssproxy >= 0.3.0-0 for package: 1:nfs-utils-1.3.0-0.21.el7.x86_64

 

Dependencies Resolved

 

===================================================

 Package       Arch   Version       Repository

                                              Size

===================================================

Updating:

 nfs-utils     x86_64 1:1.3.0-0.21.el7

                                    rhel_dvd 370 k

Installing for dependencies:

 gssproxy      x86_64 0.4.1-7.el7   rhel_dvd  84 k

 libbasicobjects

               x86_64 0.1.1-25.el7  rhel_dvd  25 k

 libcollection x86_64 0.6.2-25.el7  rhel_dvd  40 k

 libini_config x86_64 1.2.0-25.el7  rhel_dvd  59 k

 libpath_utils x86_64 0.2.1-25.el7  rhel_dvd  27 k

 libref_array  x86_64 0.1.5-25.el7  rhel_dvd  26 k

 libverto-tevent

               x86_64 0.2.5-4.el7   rhel_dvd 9.0 k

Updating for dependencies:

 krb5-libs     x86_64 1.13.2-10.el7 rhel_dvd 837 k

 

Transaction Summary

===================================================

Install             ( 7 Dependent packages)

Upgrade  1 Package  (+1 Dependent package)

 

Total size: 1.4 M

Downloading packages:

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction            

 

Updated:

  nfs-utils.x86_64 1:1.3.0-0.21.el7                

 

Dependency Updated:

  krb5-libs.x86_64 0:1.13.2-10.el7                 

 

Complete!

[root@localhost ~]# showmount -e 172.25.254.250

Export list for 172.25.254.250:

/nfsshare/nfs5 *

/nfsshare/nfs4 *

/nfsshare/nfs3 *

/nfsshare/nfs2 *

/nfsshare/nfs1 *

/content       172.25.0.0/255.255.0.0

[root@localhost ~]# mount 172.25.254.250:/nfsshare/nfs1 /mnt/  

[root@localhost ~]# df

Filesystem                    1K-blocks     Used Available Use% Mounted on

/dev/vda1                      10473900  4231560   6242340  41% /

devtmpfs                         922268        0    922268   0% /dev

tmpfs                            942660       84    942576   1% /dev/shm

tmpfs                            942660    17032    925628   2% /run

tmpfs                            942660        0    942660   0% /sys/fs/cgroup

/dev/sr0                        3654720  3654720         0 100% /run/media/root/RHEL-7.0 Server.x86_64

172.25.254.250:/nfsshare/nfs1 100221952 78403584  21818368  79% /mnt

[root@localhost ~]# cd /mnt/

[root@localhost mnt]# ls

[root@localhost mnt]# touch xiaoxiaoxiao

[root@localhost mnt]# ls

 xiaoxiaoxiao

[root@localhost mnt]# rm -fr xiaoxiaoxiao

[root@localhost mnt]# cd

[root@localhost ~]# umount /mnt

[root@localhost ~]# vim /etc/fstab

wKioL1kIFLjAEGo4AACK6k3N_Lw078.png-wh_50

[root@localhost ~]# mount -a

[root@localhost ~]# df

Filesystem                    1K-blocks     Used Available Use% Mounted on

/dev/vda1                      10473900  4231600   6242300  41% /

devtmpfs                         922268        0    922268   0% /dev

tmpfs                            942660       84    942576   1% /dev/shm

tmpfs                            942660    17032    925628   2% /run

tmpfs                            942660        0    942660   0% /sys/fs/cgroup

/dev/sr0                        3654720  3654720         0 100% /run/media/root/RHEL-7.0 Server.x86_64

172.25.254.250:/nfsshare/nfs1 100221952 78411776  21810176  79% /mnt

[root@localhost ~]# cat /etc/fstab

 

#

# /etc/fstab

# Created by anaconda on Wed May  7 01:22:57 2014

#

# 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=9bf6b9f7-92ad-441b-848e-0257cbb883d1 /                       xfs     defaults        1 1

172.25.254.250:/nfsshare/nfs1 /mnt nfs defaults 0 0    ##自动挂载脚本

 

 

[root@localhost ~]# yum install autofs.x86_64 -y

Loaded plugins: langpacks

Resolving Dependencies

--> Running transaction check

---> Package autofs.x86_64 1:5.0.7-54.el7 will be installed

--> Processing Dependency: libhesiod.so.0()(64bit) for package: 1:autofs-5.0.7-54.el7.x86_64

--> Running transaction check

---> Package hesiod.x86_64 0:3.2.1-3.el7 will be installed

--> Finished Dependency Resolution

 

Dependencies Resolved

 

===================================================

 Package Arch    Version           Repository

                                              Size

===================================================

Installing:

 autofs  x86_64  1:5.0.7-54.el7    rhel_dvd  793 k

Installing for dependencies:

 hesiod  x86_64  3.2.1-3.el7       rhel_dvd   30 k

 

Transaction Summary

===================================================

Install  1 Package (+1 Dependent package)

 

Total download size: 823 k

Installed size: 5.1 M

Downloading packages:

(1/2): hesiod-3.2.1-3.el7.x86 |  30 kB   00:00     

(2/2): autofs-5.0.7-54.el7.x8 | 793 kB   00:00     

---------------------------------------------------

Total                 3.0 MB/s | 823 kB  00:00     

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  Installing : hesiod-3.2.1-3.el7.x86_64       1/2

  Installing : 1:autofs-5.0.7-54.el7.x86_64    2/2

  Verifying  : 1:autofs-5.0.7-54.el7.x86_64    1/2

  Verifying  : hesiod-3.2.1-3.el7.x86_64       2/2

 

Installed:

  autofs.x86_64 1:5.0.7-54.el7                     

 

Dependency Installed:

  hesiod.x86_64 0:3.2.1-3.el7                      

 

Complete!

[root@localhost ~]# systemctl start autofs

[root@localhost ~]# cd /net

[root@localhost net]# ls

[root@localhost net]# cd 172.25.254.250

[root@localhost 172.25.254.250]# ls

content  nfsshare

[root@localhost 172.25.254.250]# pwd

/net/172.25.254.250

[root@localhost 172.25.254.250]# cd nfsshare/

[root@localhost nfsshare]# ls

nfs1  nfs2  nfs3  nfs4  nfs5

[root@localhost nfsshare]# cd nfs3

[root@localhost nfs3]# ls

[root@localhost nfs3]# touch xiao

[root@localhost nfs3]# rm -fr xiao

[root@localhost nfs3]# ls

[root@localhost nfs3]# df

Filesystem                    1K-blocks     Used Available Use% Mounted on

/dev/vda1                      10473900  4237048   6236852  41% /

devtmpfs                         922268        0    922268   0% /dev

tmpfs                            942660       84    942576   1% /dev/shm

tmpfs                            942660    17044    925616   2% /run

tmpfs                            942660        0    942660   0% /sys/fs/cgroup

/dev/sr0                        3654720  3654720         0 100% /run/media/root/RHEL-7.0 Server.x86_64

172.25.254.250:/nfsshare/nfs1 100221952 78411776  21810176  79% /mnt

172.25.254.250:/nfsshare/nfs3 100221952 78411776  21810176  79% /net/172.25.254.250/nfsshare/nfs3

[root@localhost nfs3]# vim /etc/sysconfig/autofs   ##在配置文件中更改自动挂载不使用卸载时间

[root@localhost nfs3]# umount /mnt

[root@localhost nfs3]# df

Filesystem                    1K-blocks     Used Available Use% Mounted on

/dev/vda1                      10473900  4237068   6236832  41% /

devtmpfs                         922268        0    922268   0% /dev

tmpfs                            942660       84    942576   1% /dev/shm

tmpfs                            942660    17044    925616   2% /run

tmpfs                            942660        0    942660   0% /sys/fs/cgroup

/dev/sr0                        3654720  3654720         0 100% /run/media/root/RHEL-7.0 Server.x86_64

 

[root@localhost ~]# mkdir /westos

[root@localhost ~]# vim /etc/auto.master

[root@localhost ~]# vim /etc/auto.westos

[root@localhost ~]# head -10 /etc/auto.master

#

# Sample auto.master file

# This is a 'master' automounter map and it has the following format:

# mount-point [map-type[,format]:]map [options]

# For details of the format look at auto.master(5).

#

/misc/etc/auto.misc

/westos /etc/auto.westos

#

# NOTE: mounts done from a hosts map will be mounted with the

[root@localhost ~]# cat /etc/auto.westos

* 172.25.254.250:/nfsshare/&    ##将任意挂载到/nfsshare/下面

[root@localhost ~]# systemctl restart autofs.service

[root@localhost ~]# cd /westos

[root@localhost westos]# ls

[root@localhost westos]# cd nfs1

[root@localhost nfs1]# pwd

/westos/nfs1

[root@localhost nfs1]# df

Filesystem                    1K-blocks     Used Available Use% Mounted on

/dev/vda1                      10473900  4237068   6236832  41% /

devtmpfs                         922268        0    922268   0% /dev

tmpfs                            942660       84    942576   1% /dev/shm

tmpfs                            942660    17048    925612   2% /run

tmpfs                            942660        0    942660   0% /sys/fs/cgroup

/dev/sr0                        3654720  3654720         0 100% /run/media/root/RHEL-7.0 Server.x86_64

172.25.254.250:/nfsshare/nfs1 100221952 78409728  21812224  79% /westos/nfs1

[root@localhost nfs1]# cd

[root@localhost ~]# cd /westos/nfs2

[root@localhost nfs2]# df

Filesystem                    1K-blocks     Used Available Use% Mounted on

/dev/vda1                      10473900  4237068   6236832  41% /

devtmpfs                         922268        0    922268   0% /dev

tmpfs                            942660       84    942576   1% /dev/shm

tmpfs                            942660    17048    925612   2% /run

tmpfs                            942660        0    942660   0% /sys/fs/cgroup

/dev/sr0                        3654720  3654720         0 100% /run/media/root/RHEL-7.0 Server.x86_64

172.25.254.250:/nfsshare/nfs2 100221952 78413824  21808128  79% /westos/nfs2



本文转自 AELY木 51CTO博客,原文链接:http://blog.51cto.com/12768057/1921095,如需转载请自行联系原作者

相关文章
|
16天前
|
监控 安全 Linux
在 Linux 系统中,网络管理是重要任务。本文介绍了常用的网络命令及其适用场景
在 Linux 系统中,网络管理是重要任务。本文介绍了常用的网络命令及其适用场景,包括 ping(测试连通性)、traceroute(跟踪路由路径)、netstat(显示网络连接信息)、nmap(网络扫描)、ifconfig 和 ip(网络接口配置)。掌握这些命令有助于高效诊断和解决网络问题,保障网络稳定运行。
48 2
|
3月前
|
5G 调度 UED
5G中的动态频谱共享(DSS):高效利用频谱资源,加速5G网络演进
5G中的动态频谱共享(DSS):高效利用频谱资源,加速5G网络演进
645 4
|
28天前
|
域名解析 网络协议 安全
|
2月前
|
运维 监控 网络协议
|
29天前
|
存储 Ubuntu Linux
2024全网最全面及最新且最为详细的网络安全技巧 (三) 之 linux提权各类技巧 上集
在本节实验中,我们学习了 Linux 系统登录认证的过程,文件的意义,并通过做实验的方式对 Linux 系统 passwd 文件提权方法有了深入的理解。祝你在接下来的技巧课程中学习愉快,学有所获~和文件是 Linux 系统登录认证的关键文件,如果系统运维人员对shadow或shadow文件的内容或权限配置有误,则可以被利用来进行系统提权。上一章中,我们已经学习了文件的提权方法, 在本章节中,我们将学习如何利用来完成系统提权。在本节实验中,我们学习了。
|
2月前
|
Ubuntu Linux 虚拟化
Linux虚拟机网络配置
【10月更文挑战第25天】在 Linux 虚拟机中,网络配置是实现虚拟机与外部网络通信的关键步骤。本文介绍了四种常见的网络配置方式:桥接模式、NAT 模式、仅主机模式和自定义网络模式,每种模式都详细说明了其原理和配置步骤。通过这些配置,用户可以根据实际需求选择合适的网络模式,确保虚拟机能够顺利地进行网络通信。
|
2月前
|
网络协议 安全 Ubuntu
Linux中网络连接问题
【10月更文挑战第3天】
34 1
|
2月前
|
Linux
linux开机挂载镜像
【10月更文挑战第1天】在 Linux 系统中,开机挂载镜像通常涉及几个关键步骤,包括创建挂载点、编辑配置文件以及重新加载配置
83 0
|
3月前
|
算法 自动驾驶 物联网
解读蜂窝网络中的频谱共享技术
解读蜂窝网络中的频谱共享技术
87 5
|
2月前
|
监控 Linux 测试技术
Linux系统命令与网络,磁盘和日志监控总结
Linux系统命令与网络,磁盘和日志监控总结
59 0