首页 > 系统相关 >Linux的文件查找吉计划任务练习题

Linux的文件查找吉计划任务练习题

时间:2024-07-15 19:25:21浏览次数:16  
标签:练习题 opt test0 gym 练习 查找 Linux test root

#练习1   使用ls查看/etc/目录下的所有文件信息
[root@gym ~]# ls /etc/

#练习2   使用ls查看/etc/⽬录下名包含“a”字⺟的⽂件或者⽬录信息
[root@gym ~]# ls /etc/ | grep 'a'

#练习3   使用ls查看/etc/目录下以“.conf”结尾的文件信息
[root@gym ~]# ls /etc/*.conf

#练习4   使用ls查看/etc/目录中以“y”字母开头的文件信息
[root@gym ~]# ls /etc/y*

#练习5   find查找/var/目录中以“.log”文件
[root@gym ~]# find /var/ -name "*.log" -type f

#练习6   在opt目录下创建test目录
[root@gym ~]# mkdir /opt/test

#练习7   在test目录中创建abc.txt,def.txt,ghi.txt,xxx.txt,yyy.txt五个文件
[root@gym ~]# touch /opt/test/abc.txt
[root@gym ~]# touch /opt/test/def.txt
[root@gym ~]# touch /opt/test/ghi.txt
[root@gym ~]# touch /opt/test/xxx.txt
[root@gym ~]# touch /opt/test/yyy.txt

#练习8   修改以上5个文件的最后修改时间分别为15,14,13,12,11,10日
[root@gym ~]# touch /opt/test/abc.txt -m -d "2024-7-15"
[root@gym ~]# touch /opt/test/def.txt -m -d "2024-7-14"
[root@gym ~]# touch /opt/test/ghi.txt -m -d "2024-7-13"
[root@gym ~]# touch /opt/test/xxx.txt -m -d "2024-7-12"
[root@gym ~]# touch /opt/test/yyy.txt -m -d "2024-7-11"

#练习9   在test目录下创建a目录
[root@gym ~]# mkdir /opt/test/a

#练习10   将以上5个文件复制一份到a目录中
[root@gym ~]# cp /opt/test/*txt /opt/test/a

#练习11   将a目录文件做成bak.tar.gz文件保存到家目录中
[root@gym ~]# tar -zcvf /home/bak.tar.gz /opt/test/a

#练习12   使用find删除test目录下3天前的文件
[root@gym ~]# find /opt/test -mtime +3 |xargs rm -rf

#练习13   find 删除opt目录下3天内的文件
[root@gym ~]# find /opt -mtime -3 -exec rm -rf {} \;

#练习14   find删除正好第三天的文件
[root@gym ~]# find /opt -mtime 3 -exec rm -rf {} \;

#练习15   将/opt/test/a目录中的文件复制一份到/opt/test/目录下
[root@gym ~]# cp /opt/test/a/* /opt/test/

#练习16   创建目录/opt/test0
[root@gym ~]# mkdir /opt/test0

#练习17   在/opt/test0/目录中创建三个文件 a.mp4(5M),b.mp4(20M),c.mp4(80M)
[root@gym ~]# dd if=/dev/zero of=/opt/test0/a.mp4 bs=1M count=5
[root@gym ~]# dd if=/dev/zero of=/opt/test0/b.mp4 bs=1M count=20
[root@gym ~]# dd if=/dev/zero of=/opt/test0/c.mp4 bs=1M count=80

#练习18   创建目录/opt/test0/b/
[root@gym ~]# mkdir /opt/test0/b/

#练习19   将/opt/test0/中的文件复制一份到/opt/test0/b目录中
[root@gym ~]# cp /opt/test0/ /opt/test0/b/

#练习20   find查询/opt/test0/目录中文件大于20M的,并删除
[root@gym ~]# find /opt/test0/ -type f -size +20M -exec rm -rf {} \;

#练习21   find查询/opt/test0/目录中文件小于20M的,并删除
[root@gym ~]# find /opt/test0/ -size -20M -type f -exec rm -rf {} \;

#练习22   find查询/opt/test0/目录中文件为20M的,并删除
[root@gym ~]# find /opt/test0/ -size 20M -type f -exec rm -rf {} \;

#练习23   /opt/test0/b中的文件复制一份到/opt/test0目录中
[root@gym ~]# cp /opt/test0/b/ /opt/test0/

#练习24   打开新的虚拟主机
打开vm,克隆一台主机并打开

#练习25   将家目录中的bak.tar.gz文件上传到新主机的/opt目录中
[root@gym ~]# scp /home/bak.tar.gz [email protected]:/opt/
[email protected]'s password: 
bak.tar.gz                                                                                     100%  181   207.6KB/s   00:00    
新主机:
[root@localhost ~]# ls /opt/
bak.tar.gz

#练习26   将新主机的/etc/skel/目录下载到当前主机的/opt目录中
[root@gym ~]# scp -r [email protected]:/etc/skel /opt
[email protected]'s password: 
.bash_logout                                                                                   100%   18     9.9KB/s   00:00    
.bash_profile                                                                                  100%  193   133.1KB/s   00:00    
.bashrc                                                                                        100%  231   358.4KB/s   00:00    
[root@gym ~]# ls /opt/
skel  test  test0

#练习27   设置计划任务,每周3将/etc/yum.repos.d/目录下的.repo文件压缩保存到tmp,在文件命中添加时间戳
[root@gym ~]# crontab -e
0 0 * * 3 tar -cvzf /tmp/yum.repos.d_$(date "+\%Y\%m\%d\%H\%M\%S").tar.gz /etc/yum.repos.d/*.repo
[root@gym ~]# crontab -l
 

标签:练习题,opt,test0,gym,练习,查找,Linux,test,root
From: https://blog.csdn.net/2301_77803738/article/details/140447067

相关文章

  • Linux——添加默认路由(能ping通本网段,但是ping不通其他网段)
    2024/07/151.问题描述2.问题处理3.其他问题1.问题描述昨天服务器突然断电,今天重启后,网络出了些问题,具体情况如下:能ping通本机IPping不通网关ping不通本网段其他IP地址ping不通其他网段地址2.问题处理vi/etc/sysconfig/network-scripts/ifcfg-ens32检查了网卡配置文......
  • Structure of Linux Kernel Device Driver(Part I)
    StructureofLinuxKernelDeviceDriverref.https://www.youtube.com/watch?v=XoYkHUnmpQo&list=LL&index=1&t=272sDeviceDriversDef.:设备驱动(DeviceDrivers),实际上就是硬件设备对应的抽象,用户能够通过这样的一个抽象与对应的硬件进行交互设备驱动与固件的区别:设备驱......
  • 【Linux网络编程-6】IO复用
    select模型//selectServer.cpp#include<stdio.h>#include<stdlib.h>#include<string.h>#include<unistd.h>#include<arpa/inet.h>#include<sys/socket.h>#include<errno.h>#include<sys/select.h>#include&......
  • Linux获取进程cpu使用情况
    相关:{%post_linkshell/'Linux获取线程CPU使用情况'%}CPU使用率pidstat(推荐)pidstat-p进程PID-H-u间隔秒数|awk'{if(NR>3){print$1,$8}}'-H:Displaytimestampinsecondssincetheepoch.-u:ReportCPUutilization.NR>3:第四行开始才是有效输出。awk......
  • ArchLinux微信
    flatpak原生微信。flatpakinstallcom.tencent.WeChatflatpakruncom.tencent.WeChat也可以从系统的启动器里启动。{%post_linkApp/'flatpak教程'%}deepin-wine-wechatyay-Sdeepin-wine-wechat我尝试的版本:3.9.0.28-3如果是KDE的话,大概会报这个错:/opt/apps/com......
  • python-查找算法
    查找算法1.线性查找2.二分查找3.插值查找4.斐波那契查找1.线性查找"""线性查找:对于被查找的序列没有顺序要求,可以是有序的,也可以是无序的,查找时从线性表的起始位置按照顺序匹配,找到元素时,返回该元素在原始字符串的下标若匹配完整个序列......
  • 二分查找模板
    二分查找主要难点在于边界判定,逻辑相对简单,下文以力扣704.二分查找为例分析二分查找的代码模板。题目描述给定一个 n 个元素有序的(升序)整型数组 nums和一个目标值 target ,写一个函数搜索 nums 中的target,如果目标值存在返回下标,否则返回-1。来源:力扣(LeetCode)原......
  • Linux 报错INFO: task blocked for more than 120 seconds
     一般情况下,Linux会把可用内存的40%的空间作为文件系统的缓存。 当缓存快满时,文件系统将缓存中的数据整体同步到磁盘中。但是系统对同步时间有最大120秒的限制。 如果文件系统不能在时间限制之内完成数据同步,则会发生上述的错误。 这通常发生在内存很大的系统上。系统......
  • linux 审核策略
    审计范围应覆盖到服务器和重要客户端上的每个操作系统用户和数据库用户;开启审核策略,若日后系统出现故障、安全事故则可以查看系统日志文件,排除故障、追查入侵者的信息等。查看rsyslog与auditd服务是否开启应保护审计记录,避免受到未预期的删除、修改或覆盖等。防止重要日志信息......
  • Day33.元类下的属性查找
    1.元类下的属性查找_对象.方法和类名.方法的查找经过#todo属性查找的原则:对象->类->父类#todo切记:父类不是元类classMymeta(type):n=444def__call__(self,*args,**kwargs):#self=<class'__main__.StanfordTeacher'>obj=self.__new......