《linux 文件目录》- touch/rm/mv/cat/head/tail/cp/mkdir/chmod/chown/find/locate/which/whereis
一:基本
- / 根目录下目录结构定义
/bin 常见的用户指令 ls/echo ...... 等
/boot 内核和启动文件
/dev 设备文件
/etc 系统和服务配置文件
/home 用户家目录
/lib 系统函数库目录
/lost+fond ext3文件需要目录,用于磁盘检查
/mnt 系统加载文件常用挂载点
/opt 第三方软件安装目录
/proc 虚拟文件系统
/root root用户家目录
/sbin 存放系统管理命令
/tmp 临时文件目录存放
/usr 存放直接与用户相关文件
/media 临时文件系统挂载点
二:文件操作
- touch (创建文件)
- 如果文件存在,则刷新 创建/修改 时间。
- rm (删除文件)
- -r 删除目录
- -f 删除时不需要询问
- mv (移动或重命名)
- -i 重名文件询问是否覆盖
- -f 重名文件直接覆盖
- head (查看文件头)
- -n 指定行数
- tail (查看文件尾)
- -f 实时监控文件末尾
三:目录操作
- mkdir (创建目录)
- -p 逐级创建目录
- cp (复制文件)
- -r 复制目录
四:文件/目录权限
- 文件权限
ls -al drwxr----- homework homework 11月 : apollo
文件权限/类别 连接数 所有者 所有组 文件大小(K) 创建/修改时间 文件名
- chmod (改变文件权限)
- chmod -r 权限 文件
- r(读) = 4;w(写) = 2;x(执行) = 1;
- chown (改变文件所有者)
- chown -R 所有者:所有组 文件
- file (查看文件类型)
[@:~]$ file smarty.conf
smarty.conf: ASCII text
四:文件查找
- find (一般查找)
- 根据文件名查找
- find /home -name xxx.jpg (/home 目录下递归查找所有文件名字为 xxx.jpg 的文件)
- 根据文件大小查找
- find /home -size +512k (/home 目录下递归查找大于512k的文件)
- find /home -size -512k (/home 目录下递归查找小于512k的文件)
- 指定深度范围查找
- find /home/lihong1/www/ka/public -maxdepth 1 -size +3k (/home 目录下查找一层大于3k的文件)
- 根据时间查找
- find /home -cmin 10 (查找 /home 中十分钟左右修改的)
- find /home -cmin +10 (查找 /home 中十分钟以上修改的)
- find /home -cmin -10 (查找 /home 中十分钟以内修改的)
- find /home -ctime 10 (查找 /home 中十天左右修改的)
- find /home -ctime +10 (查找 /home 中十天以上修改的)
- find /home -ctime -10 (查找 /home 中十天以内修改的)
- 根据文件权限查找
- find /home -perm 777 (查找 /home 文件权限为 777 的文件) (必须是 rwxrwxrwx)
- find /home -perm -007 (查找 /home other 有读写权限的文件) (******rwx 满足任意即可)
- 权限不足直接可以过滤
- find /home -name xxx.jpg 2 > /dev/null
- locate (数据库查找)
- 原理
- 与 find 不同,locate 命令依赖于一个数据库文件
- Linux 每天会检索下系统中的文件,记录到数据库中。
- 所以, locate 比 find 更为迅速
- 使用
- 在使用命令之前,需先使用 updatedb 刷新文件,因为可能新加入的文件并没有被记录
homework@1 ~ $ locate npm-debug.log
/home/homework/xxx.log
五:查找可执行文件
- which (查找二进制执行文件绝对路径)
homework@1 $ which echo
/bin/echo
- whereis (除了能找到二进制执行文件,还能找到 man 文件)
homework@1 $ whereis echo
echo: /bin/echo /usr/share/man/man1p/echo.1p.gz /usr/share/man/man1/echo..gz
六:压缩/解压
- 压缩
- tar -cvf /tmp/etc.tar /etc 仅打包,不压缩!
- tar -zcvf /tmp/etc.tar.gz /etc 打包后,以 gzip 压缩
- tar -jcvf /tmp/etc.tar.bz2 /etc 打包后,以 bzip2 压缩
- 解压
- *.tar 用 tar -xvf 解压 [ -C 可以指定解压目录位置]
- *.gz 用 gzip -d/gunzip 解压
- *.tar.gz 用 tar -xzf 解压
- *.tgz 用 tar -xzf 解压
- *.bz2 用 bzip2 -d/bunzip2 解压
- *.tar.bz2 用 tar -xjf 解压
- *.Z 用 uncompress 解压
- *.tar.Z 用 tar -xZf 解压
- *.rar 用 unrar e 解压
- *.zip 用 unzip 解压
-
《linux 文件目录》- touch/rm/mv/cat/head/tail/cp/mkdir/chmod/chown/find/locate/which/whereis的更多相关文章
- linux系统命令学习系列8-文件相关操作touch,rm,mv,cat,head,tail命令
上节内容: 系统和目录管理 Pwd命令 .和..目录 相对路径和绝对路径 作业:进入opt路径,分别使用相对路径方法和绝对路径方法进入到其实任意一个子目录 cd /opt 相对路径 cd rh 绝对路 ...
- 第四节 mount /who / mkdir /rmdir /rm /cp /mv /touch /cat /tac/head /tail /more /less / chmod /chown /umask /chattr /lsattr /history /echo
***Linux下的文件类型如下: 9 8 7 6 5 4 3 2 1 0- r w x r - x r - x 第9位表示文件类型,可以为p.d.l.s.c.b和-:p表示命名管道文件 -pipe ...
- mkdir,rmdir,cp,rm,mv,cat,touch用法
一.mkdir新建目录 1.进入tmp目录,查看该目录下面的子目录 [root@localhost ~]# cd /tmp[root@localhost tmp]# lshsperfdata_root ...
- ubuntu,day1基础命令,shutdown,man,touch,rm,mv,cp,stat,locale,apt,date,tzselect,cal,快捷方式,echo,查看文件
基本设置命令 1,shutdown 命令, shutdown -r now # 现在立即重启 shutdown -r + # 三分钟后重启 shutdown -r : #在12:12时将重启计算机 s ...
- 再说linux中的rm mv 遍历执行多个文件的操作: find + xagrs
参考文章: http://cfqtyaogang.blog.163.com/blog/static/218051022011812111342203/, 这篇文章讲得很全面很详细... 包括不好理解的 ...
- 常用命令su ls cp cd mv cat touch mkdir rm head less more pwd tac 等
1.用户切换 su:switch user su kevin //半切换,切换到kevin用户,但是不读取kevin用户的配置文件 su - kevin //完全切换,执行这个命令的时候表示切 ...
- linux中ugo权限管理(chmod/chown)
查看ugo权限: ll [root@localhost test]# ll total 12 -rwxr-xr-x 2 root root 4 Oct 3 11:44 a lrwxrwxrwx 1 ...
- Linux学习--第三天--linux文件目录、ls、mkdir、mv、rm、touch、cat、tac、more、less、head、tail、ln、chmod、chown、chgrp、umask
文件目录 目录名 备注 bin 下面的命令所有人都可以运行 sbin 只有root才能运行,s代表super /mnt,/media,/misc 都是挂载目录,但一般只用mnt /opt 第三方软件安 ...
- centos 目录文件管理 mkdir,rm,touch,误删文件extundelete,cp,mv,cat,more,less ,head,tail,chown,chmod ,umask 第四节课
centos 目录文件管理 mkdir,rm,touch,误删文件extundelete,cp,mv,cat,more,less ,head,tail,chown,chmod ,umask 第四节课 ...
随机推荐
- 【iCore1S 双核心板_FPGA】例程六:状态机实验——状态机使用
核心代码: module FSM( input CLK_12M, input FPGA_KEY, output FPGA_LEDR, output FPGA_LEDG, output FPGA_LED ...
- Numpy 定义矩阵的方法
import numpy as np #https://www.cnblogs.com/xzcfightingup/p/7598293.html a = np.zeros((2,3),dtype=in ...
- python中的selectors模块
它的功能与linux的epoll,还是select模块,poll等类似:实现高效的I/O multiplexing, 常用于非阻塞的socket的编程中: 简单介绍一下这个模块,更多内容查看 pyt ...
- MongoDB 基本操作
//恢复备份数据到本地 mongorestore -d coolfen -drop <path>
- Springboot学习笔记(三)-常用注入组件方式
包扫描@ComponentScan+组件标注注解(@Controller.@Service.@Repository.@Component) 包扫描不是必须的,指定包名后以指定的包名为准,比如指定包名为 ...
- Python 字符串转JSON; 先装字典在转JSON; json.dumps(d)
#-*- coding:UTF-8 -*- import os; import json class MysqlUtil(): def __init__(self): pass if __name__ ...
- python -u 启动python文件的作用,PYTHONUNBUFFERED环境变量的作用
python -u 启动python文件的作用是不缓存,直接把输出重定向到文件,比如nohup启动什么的,如果不使用-u启动,那么程序中的print和日志什么的,可能不会非常及时的重定向到out文件, ...
- [Laravel] 01 - Love beautiful code? We do too.
前言 一.良心资料 英文 Laravel 框架:https://laravel.com/ 教程:https://laracasts.com/series/ laravel-from-scratch-2 ...
- [Node.js] 03 - Buffer, Stream and File IO
fs 模块,视频教学 os 模块,视频教学,api doc Buffer类 创建 Buffer 类 // 创建一个长度为 10.且用 0 填充的 Buffer. const buf1 = Buffer ...
- Java性能分析神器-JProfiler详解(一)(转)
前段时间在给公司项目做性能分析,从简单的分析Log(GC log, postgrep log, hibernate statitistic),到通过AOP搜集软件运行数据,再到PET测试,感觉时间花了 ...