要移动复制文件,很大有必要压缩文件还是很大吗

用户名:Tanton008
文章数:68
评论数:15
访问量:27357
注册日期:
阅读量:1297
阅读量:3317
阅读量:458542
阅读量:1143198
51CTO推荐博文
文件的复制、移动、压缩等对SELinux属性关系详解1.临时修改文件的类型属性文件的类型属性不正确是常见的SELinux拒绝访问的主要原因1)修改文件的SELinux属性:[root@localhost ~]# touch test.file & ##新建文件[root@localhost ~]# ls -Z test.file & ##查看文件的SELinux属性-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 test.file[root@localhost ~]# chcon -t samba_share_t test.file &##修改文件的默认SELinux属性[root@localhost ~]# ls -Z test.file &&-rw-r--r--. root root unconfined_u:object_r:samba_share_t:s0 test.file[root@localhost ~]# restorecon -F -v test.file & ##恢复修改过的SELinux属性为默认属性restorecon reset /root/test.file context unconfined_u:object_r:samba_share_t:s0-&system_u:object_r:admin_home_t:s0[root@localhost ~]# ls -Z test.file&-rw-r--r--. root root system_u:object_r:admin_home_t:s0 test.file2)修改目录的SELinux属性(所有的操作与文件对比多了一个“-R”代表递归):[root@localhost ~]# mkdir /web[root@localhost ~]# touch /web/file{1,2}[root@localhost ~]# ls -dZ /web &##查看目录的SELinux属性drwxr-xr-x. root root unconfined_u:object_r:default_t:s0 /web[root@localhost ~]# ls -lZ /web/ & ##查看目录下文件的SELinux属性-rw-r--r--. root root unconfined_u:object_r:default_t:s0 file1-rw-r--r--. root root unconfined_u:object_r:default_t:s0 file2[root@localhost ~]# chcon -R -t httpd_sys_content_t /web/ & &##临时修改目录的SELinux属性为httpd_sys_content_t[root@localhost ~]# ls -dZ /web/drwxr-xr-x. root root unconfined_u:object_r:httpd_sys_content_t:s0 /web/[root@localhost ~]# ls -lZ /web/-rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0 file1-rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0 file2[root@localhost ~]# restorecon -R -v /web/ & ##恢复为默认SELinux属性restorecon reset /web context unconfined_u:object_r:httpd_sys_content_t:s0-&unconfined_u:object_r:default_t:s0restorecon reset /web/file2 context unconfined_u:object_r:httpd_sys_content_t:s0-&unconfined_u:object_r:default_t:s0restorecon reset /web/file1 context unconfined_u:object_r:httpd_sys_content_t:s0-&unconfined_u:object_r:default_t:s0[root@localhost ~]# ls -lZ /web/-rw-r--r--. root root unconfined_u:object_r:default_t:s0 file1-rw-r--r--. root root unconfined_u:object_r:default_t:s0 file2[root@localhost ~]# ls -dZ /web/drwxr-xr-x. root root unconfined_u:object_r:default_t:s0 /web/2.永久修改文件的类型属性永久修改文件及目录的类型属性使用下列命令:semanage fcontext -{a|d|l|m} [-frst] filespec &##-a增加、-d删除、-l显示、-m修改restorecon -v filespec & &##由于“semanage fcontext”命令只是将属性定义项加载到“/etc/selinux/targeted/contexts/files/file_contexts.local”文件中,使用该命令才是将文件的selinux属性永久地修改.1)文件的selinux属性修改[root@localhost tmp]# touch test.file[root@localhost tmp]# ls -Z test.file&-rw-r--r--. root root unconfined_u:object_r:user_tmp_t:s0 test.file[root@localhost tmp]# yum install policycoreutils-python &##安装semanage管理工具提供软件[root@localhost tmp]# semanage fcontext -a -t samba_share_t /tmp/test.file &##将测试文件的selinux属性设置为“samba_share_t”[root@localhost tmp]# ls -Z /tmp/test.file & ##测试文件的selinux属性未发生变化-rw-r--r--. root root unconfined_u:object_r:user_tmp_t:s0 /tmp/test.file[root@localhost tmp]# restorecon -v /tmp/test.file & &##使semanage设置的selinux属性永久的生效restorecon reset /tmp/test.file context unconfined_u:object_r:user_tmp_t:s0-&unconfined_u:object_r:samba_share_t:s0[root@localhost tmp]# ls -Z /tmp/test.file & ##测试文件的selinux属性已改-rw-r--r--. root root unconfined_u:object_r:samba_share_t:s0 /tmp/test.file2)目录的selinux属性修改:(完成后目录下新建的文件自动继承selinux属性)[root@localhost ~]# mkdir /html[root@localhost ~]# touch /html/file{1,2}[root@localhost ~]# ls -dZ /htmldrwxr-xr-x. root root unconfined_u:object_r:default_t:s0 /html[root@localhost ~]# ls -lZ /html/-rw-r--r--. root root unconfined_u:object_r:default_t:s0 file1-rw-r--r--. root root unconfined_u:object_r:default_t:s0 file2[root@localhost ~]# semanage fcontext -a -t httpd_sys_content_t "/html(/.*)?" &##正则表达式“/html(/.*)?”表示/html目录及其中的任何文件或子目录[root@localhost ~]# restorecon -R -v /html/ &##使semanage设置的selinux属性永久的生效restorecon reset /html context unconfined_u:object_r:default_t:s0-&unconfined_u:object_r:httpd_sys_content_t:s0restorecon reset /html/file2 context unconfined_u:object_r:default_t:s0-&unconfined_u:object_r:httpd_sys_content_t:s0restorecon reset /html/file1 context unconfined_u:object_r:default_t:s0-&unconfined_u:object_r:httpd_sys_content_t:s0[root@localhost ~]# ls -lZ /html/ & ##验证修改结果-rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0 file1-rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0 file2[root@localhost ~]# ls -dZ /html/drwxr-xr-x. root root unconfined_u:object_r:httpd_sys_content_t:s0 /html/3)如果要恢复/html的文件属性可使用下列命令:[root@localhost ~]# semanage fcontext -d "/html(/.*)?" & ##删除自定义的selinux属性[root@localhost ~]# restorecon -F -R -v /html/ &##永久生效restorecon reset /html context unconfined_u:object_r:httpd_sys_content_t:s0-&system_u:object_r:default_t:s0restorecon reset /html/file2 context unconfined_u:object_r:httpd_sys_content_t:s0-&system_u:object_r:default_t:s0restorecon reset /html/file1 context unconfined_u:object_r:httpd_sys_content_t:s0-&system_u:object_r:default_t:s0[root@localhost ~]# ls -lZ /html &##验证文件的selinux属性已经从“httpd_sys_content_t”改为默认的"default_t"-rw-r--r--. root root system_u:object_r:default_t:s0 & file1-rw-r--r--. root root system_u:object_r:default_t:s0 & file2[root@localhost ~]# ls -dZ /htmldrwxr-xr-x. root root system_u:object_r:default_t:s0 & /html4)file_t与default_tfile_t:文件没有selinux属性default_t:文件或目录的selinux属性与file-context配置文件定义的模式不匹配两种的类型的文件或目录,受限制的域的程序均不能访问3.移动文件对selinux属性的影响在SELinux环境中,文件和目录移动之后保持原有SELinux属性不变准备测试文件:[root@localhost ~]# touch test.file[root@localhost ~]# ls -Z test.file&-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 test.file[root@localhost ~]# ls -dZ /var/www/html/drwxr-xr-x. root root system_u:object_r:httpd_sys_content_t:s0 /var/www/html/移动测试:[root@localhost ~]# mv test.file /var/www/html/[root@localhost ~]# ls -Z /var/www/html/test.file & ##移动后selinux属性依然是“admin_home_t”,并未继承“httpd_sys_content_t”-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 /var/www/html/test.file注意:移动和复制对比中,复制更有利于保持文件的selinux属性,以便能正常访问。4.检测文件的默认属性利用matchpathcon,可以验证目录下的文件selinux属性标记是否正确。准备测试文件:[root@localhost ~]# touch /var/www/html/file{1,2,3} &##创建三个文件[root@localhost ~]# ls -Z /var/www/html/file*-rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0 /var/www/html/file1-rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0 /var/www/html/file2-rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0 /var/www/html/file3修改测试:[root@localhost ~]# chcon -t samba_share_t /var/www/html/file1 &##临时修改selinux属性[root@localhost ~]# ls -Z /var/www/html/file1-rw-r--r--. root root unconfined_u:object_r:samba_share_t:s0 /var/www/html/file1[root@localhost ~]# matchpathcon -V /var/www/html/file? & ##检测selinux属性的正确性,提示file1为“samba_share_t”应为“httpd_sys_content_t”/var/www/html/file1 has context unconfined_u:object_r:samba_share_t:s0, should be system_u:object_r:httpd_sys_content_t:s0/var/www/html/file2 verified./var/www/html/file3 verified.[root@localhost ~]# touch test.file &[root@localhost ~]# ls -Z-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 test.file[root@localhost ~]# mv test.file /var/www/html/ &##移动新文件测试mv:是否覆盖"/var/www/html/test.file"? y[root@localhost ~]# ls /var/www/html/test.file &-Z-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 /var/www/html/test.file[root@localhost ~]# restorecon -v /var/www/html/* & ##修复selinux属性restorecon reset /var/www/html/file1 context unconfined_u:object_r:samba_share_t:s0-&unconfined_u:object_r:httpd_sys_content_t:s0restorecon reset /var/www/html/test.file context unconfined_u:object_r:admin_home_t:s0-&unconfined_u:object_r:httpd_sys_content_t:s0[root@localhost ~]# matchpathcon -V /var/www/html/* & ##提示verified表示校验成功/var/www/html/file1 verified./var/www/html/file2 verified./var/www/html/file3 verified./var/www/html/test.file verified.5.tar文件与selinux属性标记tar命令不会保存属于扩展属性的selinux属性,使用“--selinux”或“--xattrs”可保存selinux属性信息。准备对比步骤:[root@localhost ~]# touch file{1..3} &##创建文件[root@localhost ~]# ls -Z-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 file1-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 file2-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 file3[root@localhost ~]# tar zcf test.tar.gz ./file* & ##不加“--selinux”选项[root@localhost ~]# cp test.tar.gz /tmp/ &##拷贝文件[root@localhost ~]# cd /tmp/ & ##进入/tmp目录[root@localhost tmp]# tar zxvf test.tar.gz & ##解压./file1./file2./file3[root@localhost tmp]# ls -Z & ##验证,selinux属性丢失-rw-r--r--. root root unconfined_u:object_r:user_tmp_t:s0 file1-rw-r--r--. root root unconfined_u:object_r:user_tmp_t:s0 file2-rw-r--r--. root root unconfined_u:object_r:user_tmp_t:s0 file3-rw-r--r--. root root unconfined_u:object_r:user_tmp_t:s0 test.tar.gz保留selinux属性:[root@localhost tmp]# cd[root@localhost ~]# touch file{4..5}&[root@localhost ~]# ls -Z file{4..5}-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 file4-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 file5[root@localhost ~]# tar zcf test.se.tar.gz ./file{4..5} --selinux & ##压缩是保留selinux属性标记[root@localhost ~]# cp test.se.tar.gz /tmp/[root@localhost ~]# cd /tmp/[root@localhost tmp]# tar zxvf test.se.tar.gz&./file4./file5[root@localhost tmp]# ls -Z &##验证file1、2、3丢失了原有的selinux属性,file4、5保留了“admin_home_t”的selinux属性;请思考:test开头的两压缩文件为什么是这样的selinux属性?-rw-r--r--. root root unconfined_u:object_r:user_tmp_t:s0 file1 & &-rw-r--r--. root root unconfined_u:object_r:user_tmp_t:s0 file2-rw-r--r--. root root unconfined_u:object_r:user_tmp_t:s0 file3-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 file4-rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 file5-rw-r--r--. root root unconfined_u:object_r:user_tmp_t:s0 test.se.tar.gz-rw-r--r--. root root unconfined_u:object_r:user_tmp_t:s0 test.tar.gz本文出自 “” 博客,请务必保留此出处
了这篇文章
类别:┆阅读(0)┆评论(0)
15:18:55 22:29:13快速拷贝文件经验及工具分享_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
快速拷贝文件经验及工具分享
阅读已结束,下载文档到电脑
想免费下载更多文档?
定制HR最喜欢的简历
下载文档到电脑,方便使用
还剩1页未读,继续阅读
定制HR最喜欢的简历
你可能喜欢无法将卷压缩到超出任何不可移动的文件所在点_百度经验
&&&&&&&&&笔记本电脑无法将卷压缩到超出任何不可移动的文件所在点<div class="audio-wp audio-wp-1" data-text='无法将卷压缩到超出任何不可移动的文件所在点今天在windows下的磁盘分区时,明明还有空间却无法压缩,提示说:“无法将卷压缩到超出任何不可移动的文件所在点”我在网上搜索了一下,结果就得到這样的答案:“磁盘(特别是系统盘)上有些文件时不可移动的,最典型的例子就是页面文件和休眠文件,这两个文件都是被系统锁定的,在当前系统中不能移动和删除这两个文件的!你的C盘是系统盘,页面文件就是储存在C盘上的,虽然这个分区(卷)前面有很大的空间,但是页面文件之前的区域是不能压缩的。假设页面文件恰好在分区的最末段的话,那么不管这个分区又多大的可用空间,还是不能压缩的。(因为页面文件时无法移动的,压缩卷的时候,最多只能压缩到页面文件的最末端。就如提示信息所说。)”对于我這样的小白根本就不懂,方法也挺复杂,要删啥东西或者第三方软件,感觉太复杂了,最后找到了一个很简单的方法,步骤如下:' data-for=''>听语音1234567
百度经验:今天在windows下的磁盘分区时,明明还有空间却无法压缩,提示说:“无法将卷压缩到超出任何不可移动的文件所在点”我在网上搜索了一下,结果就得到這样的答案:“磁盘(特别是系统盘)上有些文件时不可移动的,最典型的例子就是页面文件和休眠文件,这两个文件都是被系统锁定的,在当前系统中不能移动和删除这两个文件的!你的C盘是系统盘,页面文件就是储存在C盘上的,虽然这个分区(卷)前面有很大的空间,但是页面文件之前的区域是不能压缩的。假设页面文件恰好在分区的最末段的话,那么不管这个分区又多大的可用空间,还是不能压缩的。(因为页面文件时无法移动的,压缩卷的时候,最多只能压缩到页面文件的最末端。就如提示信息所说。)”对于我這样的小白根本就不懂,方法也挺复杂,要删啥东西或者第三方软件,感觉太复杂了,最后找到了一个很简单的方法,步骤如下:百度经验:windows系统百度经验:1右击“我的电脑”,选择”属性“2点击”更改设置“3点击“系统保护”4在“保护设置”中选择磁盘,并单击“配置”5选择“禁用系统保护”后,单击“确认”并退出这时进入“磁盘管理”就能看见磁盘能进行压缩了6额,本人是个小白,第一次发这,希望对大家有用^_^哦,还有就是记得压缩后再把“保护设置”改回来END经验内容仅供参考,如果您需解决具体问题(尤其法律、医学等领域),建议您详细咨询相关领域专业人士。投票(7)已投票(7)有得(0)我有疑问(0)◆◆说说为什么给这篇经验投票吧!我为什么投票...你还可以输入500字◆◆只有签约作者及以上等级才可发有得&你还可以输入1000字◆◆如对这篇经验有疑问,可反馈给作者,经验作者会尽力为您解决!你还可以输入500字相关经验9911607412热门杂志第1期你不知道的iPad技巧3617次分享第1期win7电脑那些事6336次分享第2期新人玩转百度经验1284次分享第1期Win8.1实用小技巧2588次分享第1期小白装大神1790次分享◆请扫描分享到朋友圈请完成以下验证码
查看: 10025|回复: 28
如何防止移动硬盘的文件被复制拷贝
如何防止移动硬盘的文件被复制和拷贝?谢谢
忧郁的迷糊酱
试试EFS吗?可以保证你的文件就算被拷贝走也无法打开。(请谨慎使用,一定要备份好你的私钥,建议你阅读相关说明后再使用)
忧郁的迷糊酱 发表于
试试EFS吗?可以保证你的文件就算被拷贝走也无法打开。(请谨慎使用,一定要备份好你的私钥,建议你阅读相关 ...
呵呵 这么神奇 有没有什么软件能用?
忧郁的迷糊酱
软件吗?加密类的话挺多,但是无法保证文件在可访问的情况下不被拷贝走,大型企业的管理软件应该有类似功能,但是我很少接触到,目前能想到的办法就是EFS。
首选是数据加密类软件
本帖最后由 HEMM 于
19:56 编辑
用压缩软件把文件加密压缩
HEMM 发表于
用压缩软件把文件加密压缩
我之前试过这样的方法哇 这样会不会很麻烦
忧郁的迷糊酱 发表于
软件吗?加密类的话挺多,但是无法保证文件在可访问的情况下不被拷贝走,大型企业的管理软件应该有类似功能 ...
恩 用EFS 在被人的电脑里能正常访问 就是拷贝不了呗??
nazisoft 发表于
首选是数据加密类软件
求推荐 ^_^
使用PGP或者TrueCrypt 吧
Copyright & KaFan & All Rights Reserved.
Powered by Discuz! X3.3( 苏ICP备号 ) GMT+8,}

我要回帖

更多关于 压缩后文件还是很大 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信