学点Linux命令没坏处(文件)

简介: 最近复习了下Linux的文件处理相关命令,做了一些记录在此分享一下。

最近复习了下Linux的文件处理相关命令,做了一些记录在此分享一下。

网络异常,图片无法展示
|

文件和目录增加、删除、查看(搜索)操作


  • 目录显示:文件有关显示操作的有各种查看文件、目录的方式主要命令有pwd ls ll cat tree,最常用的ls中包含了我们常用的一些场景。
//pwd: 其功能是显示当前工作目录的绝对路径 其相关的全局变量$PWD
[root@VM-12-5-centos workspace]# pwd
/home/workspace
[root@VM-12-5-centos workspace]# echo $PWD
/home/workspace
//dirname:用于显示文件或目录路径(命令用于获取给定路径的路径部分。)
[root@localhost demo]# pwd
/tmp/demo
[root@localhost demo]# dirname /tmp/demo/demo2.txt 
/tmp/demo
// ls: 查询当前目录下文件 -a查询所有包括隐藏的.***类文件  -l显示详细信息(相当于ll命令)  -R递归查看目录
[root@localhost demo]# ls
demo.txt  test  test2  test3
[root@localhost demo]# ls -a
.  ..  demo.txt  .ignore  test  test2  test3
[root@localhost demo]# ls -al
total 4
drwxr-xr-x.  5 root root   75 Jul  6 09:14 .
drwxrwxrwt. 11 root root 4096 Jul  6 09:13 ..
-rw-r--r--.  1 root root    0 Jul  6 09:14 .ignore
...
[root@localhost demo]# ls -R test
test:
demo2.txt  demo.txt  log
test/log:
//排序 -S文件大小 -t最后修改时间
[root@localhost demo]# ls -lhS --time-style=full-iso
total 8.0K
drwxr-xr-x. 3 root root 50 2022-07-06 09:20:19.842043397 +0800 test
-rw-r--r--. 1 root root 26 2022-07-07 08:43:52.746533057 +0800 demo.txt
drwxr-xr-x. 2 root root  6 2022-07-06 09:13:10.912578643 +0800 test2
...
[root@localhost demo]# ls -lht --time-style=full-iso
total 8.0K
-rw-r--r--. 1 root root  5 2022-07-07 08:44:19.544308928 +0800 demo2.txt
...
// tree: 以树形结构显示目录下的内容
[root@localhost demo]# tree
.
├── demo.txt
├── test
│   └── demo.txt
├── test2
└── test3
// 显示文件(或系统)状态stat -f(显示文件所在分区的文件系统状态而非文件)
[root@localhost demo]# stat demo2.txt  
  File: ‘demo2.txt’
  Size: 46              Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 67160922    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Context: unconfined_u:object_r:user_tmp_t:s0
Access: 2022-07-14 09:00:09.631828661 +0800
Modify: 2022-07-14 09:00:02.178613564 +0800
Change: 2022-07-14 09:00:02.178613564 +0800
 Birth: -
 [root@localhost demo]# stat -f demo2.txt 
  File: "demo2.txt"
    ID: fd0000000000 Namelen: 255     Type: xfs
Block size: 4096       Fundamental block size: 4096
Blocks: Total: 13100800   Free: 11174980   Available: 11174980
Inodes: Total: 26214400   Free: 26073060
//file(determine file type)  
[root@localhost demo]# file demo2.txt 
demo2.txt: ASCII text
//basename(令用于显示去除路径和文件后缀部分的文件名或目录名) basename + options + file + [后缀/前缀]
[root@localhost demo]# basename demo2.txt ".txt" 
demo2

size:文件大小 Blocks:占用block数量 regular file:文件类型为普通文件 inode 索引节点 Device:设备编号(十六进制数)Links:文件的硬连接数

  • 文件查看合并cat,命令常用来显示单个文件内容,或者将几个文件内容连接起来一起显示,还可以从标准输入中读取内容并显示,生产环境中它常与重定向或追加符号配合使用。也是我们工作中常用的命令之一,五大常用功能:1.查看文件内容 2.多个文件合并成一个 3.创建编辑新文件 4.非交互的编辑或追加内容到文件尾部 5.清空文件内容
//查看文件
[root@localhost demo]# cat demo2.txt -n #<=== -n显示行号
     1  ieee
     2  oo
     3  oo
[root@localhost demo]# cat demo2.txt -E #<=== -E显示行尾的$符号
this is a test txt! hahaha$
see you Tommorrow!$
[root@localhost demo]# cat demo1.txt demo2.txt  #<=== 合并显示多个文件
this is a demo 1 file
this is a test txt! hahaha
see you Tommorrow!
//写入文件cat和“>”重定向将标准输出定向到文件的,需要注意:
#1.结束编辑可以用快捷键Ctrl+d或Ctrl+c退出,但是必须要先执行回车,将光标定位到新的未输入的行才行。
#2.使用此种方式输入时,会发现如果输入错了,只按退格键(Backspace)将会无法删除,需要按住“Ctrl+退格键”才能删除
#3.此操作为特殊编辑方法,作为扩展知识点提及,实际生产环境中使用得很少。
[root@localhost demo]# cat >demo3.txt 
this is a demo3 file@ iooo
eeee^C
[root@localhost demo]# cat demo3.txt 
this is a demo3 file@ iooo
[root@localhost demo]# cat >demo2.txt<<EOF #<=== 写入文件
> this is a test txt! hahaha
> see you Tommorrow!
> EOF
[root@localhost demo]# ls
@  demo2.txt  demo3.txt  employee.txt  empty.txt  log.log  test2  test3
[root@localhost demo]# cat demo2.txt 
this is a test txt! hahaha
see you Tommorrow!
  • 文件显示:日常查看文件是常用的有以下几个命令,head tail tailf more less,另外tail是服务器故障排查中经常可以用到的。下面详细了解下这几个命令的使用
//tail命令用于显示文件尾部内容,默认输出文件最后10行 -n(行数) -f(实时显示文件追加数据) --retry(不停尝试打开直到打开为止) -F(相当于-f --retry)-s(监控文件变化的间隔秒数)
[root@localhost demo]# tail log.log #<=== 默认显示尾部10行
nohup: ignoring input
2022-07-12 20:43:05,028 - linkkit - INFO - start connect
2022-07-12 20:43:05,032 - linkkit - INFO - start connect
2022-07-12 20:43:05,035 - device_connector.ali_connect - ERROR - sensor6-1[sensors] - 'NoneType' object has no attribute 'status'
...
[root@localhost demo]# tail log.log -n 15
2022-07-12 20:43:06,180 - linkkit - INFO - __on_internal_connect enter
2022-07-12 20:43:06,180 - device_connector.ali_connect - INFO - camera6-1[cameras] - camera6-1 on_connect:0,rc:0,userdata:
2022-07-12 20:43:06,203 - linkkit - INFO - __on_internal_connect
2022-07-12 20:43:06,204 - linkkit - INFO - __on_internal_connect enter
pi@swift-hub-006:/var/log$ head swift.log #<=== -n指定显示行数
nohup: ignoring input
2022-07-12 20:43:05,028 - linkkit - INFO - start connect
2022-07-12 20:43:05,032 - linkkit - INFO - start connect
....
[root@localhost demo]# tail -f log.log  #<=== 实时监控文件变化,可以加上-s表示监控间隔秒数
nohup: ignoring input
2022-07-12 20:43:05,028 - linkkit - INFO - start connect
2022-07-12 20:43:05,032 - linkkit - INFO - start connect
...
//head命令用于显示文件头部内容,默认输入文件开头10行
[root@localhost demo]# ls
@  demo1.txt  demo2.txt  demo3.txt  employee.txt  empty.txt  log.log  test2  test3
[root@localhost demo]# head log.log #<=== 默认显示前10行
eeeeeeeeeee:
eeeeeeeee
log.....
pi@swift-hub-006:/var/log$ head swift.log 
nohup: ignoring input
2022-07-12 20:43:05,028 - linkkit - INFO - start connect
...
[root@localhost demo]# head log.log -n 20 #<=== -n指定显示行数
eeeeeeeeeee:
eeeeeeeee
log.....
钉钉
nohup: ignoring input
2022-07-12 20:43:05,028 - linkkit - INFO - start connect
...
[root@localhost demo]# head log.log -n 20 -c 100  #<=== -c指定显示字节数
eeeeeeeeeee:
eeeeeeeee
log.....
pi@swift-hub-006:/var/log$ head swift.log 
nohup: ignoring input
[root@localhost demo]# head -v demo2.txt #<=== -v指定显示文件头
==> demo2.txt <==
this is a test txt! hahaha
see you Tommorrow!
  • 新增: linux的文件处理中新增文件,目录也是我们常用的命令之一mkdir touch
//touch touch命令有两个功能:一是创建新的空文件;二是改变已有文件的时间戳属性。
[root@localhost demo]# ls
demo3.txt  demo.txt  employee.txt  test  test2  test3
[root@localhost demo]# touch empty.txt
[root@localhost demo]# ls
 demo3.txt  demo.txt  employee.txt  empty.txt  test  test2  test3
//mkdir:创建文件夹
[root@localhost demo]# mkdir demodir1
[root@localhost demo]# ls
demo3.txt  demodir1  employee.txt  empty.txt  log.log  test2  test3
//可以同时创建多个文件夹
[root@localhost demo]# mkdir demodir2 demodir3
[root@localhost demo]# ll
total 24
-rw-r--r--. 1 root root  229 Jul  7 09:34 @
-rw-r--r--. 1 root root   22 Jul 14 09:08 demo1.txt
...
//-p 递归创建多级目录
[root@localhost demo]# mkdir demodir4/child1
mkdir: cannot create directory ‘demodir4/child1’: No such file or directory
[root@localhost demo]# mkdir -p demodir4/child1
[root@localhost demo]# tree demo*
...
demodir3
demodir4
└── child1
...
  • 删除
//rm: 其功能是删除一个或多个文件或目录 -f(强制删除) -r(递归删除目录及内容)
[root@localhost demo]# ls
@  demo2.txt  demo3.txt  demo.txt  employee.txt  empty.txt  test  test2  test3
[root@localhost demo]# rm de
rm: cannot remove ‘de’: No such file or directory
[root@localhost demo]# rm demo.txt 
rm: remove regular file ‘demo.txt’? y
//rm删除目录
[root@localhost demo]# ls
@  demo2.txt  demo3.txt  employee.txt  empty.txt  test  test2  test3
[root@localhost demo]# rm test
rm: cannot remove ‘test’: Is a directory
[root@localhost demo]# rm -r test
rm: descend into directory ‘test’? y
rm: remove regular empty file ‘test/demo.txt’? y
rm: remove regular empty file ‘test/demo2.txt’? y
rm: remove directory ‘test/log’? y
rm: remove directory ‘test’? y
[root@localhost demo]# ls
//rmdir: rmdir命令用于删除空目录(remove empty directories),当目录不为空时,命令不起作用。
[root@localhost demo]# tree
.
├── @
├── demo2.txt
├── demo3.txt
├── employee.txt
├── empty
├── empty.txt
├── test2
│   └── demo.txt
└── test3
3 directories, 6 files
[root@localhost demo]# rmdir test2
rmdir: failed to remove ‘test2’: Directory not empty
[root@localhost demo]# rmdir empty
[root@localhost demo]# ls
@  demo2.txt  demo3.txt  employee.txt  empty.txt  test2  test3

以下在linux中的文件操作请谨记:

1)勿删:用mv替代rm,不要急着删除,而是先移动到回收站/tmp。

2)备份:删除前务必备份,最好是异机备份,若出现问题随时可以还原。

3)如果非要删除,那么请用find替代rm,包括通过系统定时任务等清理文件方法。下面是在生产环境中删除文件或目录的较安全方法:

4)勿用rm -f::如果非要通过rm命令删除,那么请先切换目录再删除,能不用通配符的就不用通配符。对文件的删除禁止使用“rm-rf文件名”,因为“rm-rf”误删目录时并不会有提示,非常危险。最多使用“rm-f文件名”,推荐用“rm文件名”。

  • 文件查找:查找文件是我在日常工作中比较常用的,对于window而言我们只用在搜索栏中输入想要查找的文件名即可查找到,但对于linux我们需要掌握find命令才能高效的找到我们想要的文件

·-4表示文件更改时间距现在4天以内。·+4表示文件更改时间距现在4天以前。·4表示距现在第4天。

// find 查找目录下的文件,使用方式find pathname options
[root@localhost tmp]# find /tmp/demo 
/tmp/demo
/tmp/demo/test2
...
// 常用参数-atime按时间 find pathname -atime +number|-number|number(天数),文件访问时间,及在number天内被访问过的文件
[root@localhost tmp]# find /tmp/demo  -atime -1
/tmp/demo
/tmp/demo/test2
/tmp/demo/test2/demo.txt
/tmp/demo/test3
/tmp/demo/empty.txt
/tmp/demo/log.log
[root@localhost tmp]# stat /var/lib/jenkins/%C/jenkins/war/WEB-INF/update-center-rootCAs
  File: ‘/var/lib/jenkins/%C/jenkins/war/WEB-INF/update-center-rootCAs’
  Size: 166             Blocks: 0          IO Block: 4096   directory
Device: fd00h/64768d    Inode: 67810373    Links: 2
Access: (0755/drwxr-xr-x)  Uid: (  997/ jenkins)   Gid: (  993/ jenkins)
Context: system_u:object_r:var_lib_t:s0
Access: 2022-07-11 09:04:01.549586692 +0800
Modify: 2022-05-15 18:13:35.664005312 +0800
Change: 2022-05-15 18:13:35.664005312 +0800
 Birth: -
 [root@localhost tmp]# find /var  -atime 1
/var/lib/jenkins/%C/jenkins/war/WEB-INF/update-center-rootCAs
// 常用参数-name按名称,支持通配符*匹配
[root@localhost tmp]# find . -name "demo"
./demo
[root@localhost tmp]# find . -name "demo.txt"
./demo/test2/demo.txt
[root@localhost tmp]# find . -name "demo*"
./demo
./demo/test2/demo.txt
./demo/demo2.txt
./demo/demo3.txt
// 常用参数 !反向  -a取交集 -o取并集
[root@localhost demo]# ls
@  demo2.txt  demo3.txt  employee.txt  empty.txt  log.log  test2  test3
[root@localhost demo]# find . ! -name "*.log"
.
./test2
./test2/demo.txt
./test3
./.ignore
./demo2.txt
./demo3.txt
./employee.txt
./@
./empty.txt
// 常用参数-size 按大小
[root@localhost demo]# find . -size +10c #<== 查找文件大于10字节的文件
.
./test2
./demo2.txt
./employee.txt
./@
./log.log
[root@localhost demo]#  find . -size -10c #<== 查找文件小于10字节的文件
./test2/demo.txt
./test3
./.ignore
./demo3.txt
./empty.txt
[root@localhost demo]#  find . -size 10c #<== 查找文件等于10字节的文件
// 常用参数-prune 忽略指定目录与 -path -o一起使用
[root@localhost demo]# find ./ -path './test2' -o -name "*.txt"
./test2
./test2/demo.txt
./demo2.txt
./demo3.txt
./employee.txt
./empty.txt
// 常用的查找并进行的一些操作:-delete(查找出的文件删除) -exec(对匹配到的文件执行改参数给出的shell命令) -ok(与exec相同功能,只是会确认) -prune(不在当前指定目录查找)
// 删除-delete
[root@localhost demo]# ls
@  del.txt  demo2.txt  demo3.txt  employee.txt  empty.txt  log.log  test2  test3
[root@localhost demo]# find . -name "del.*"
./del.txt
[root@localhost demo]# find . -name "del.*" --delete
find: unknown predicate `--delete'
[root@localhost demo]# find . -name "del.*" -delete
// 执行其他参数 -exec
[root@localhost demo]# find . -name "*.txt" -exec ls -l {} \;
-rw-r--r--. 1 root root 0 Jul 10 21:06 ./test2/demo.txt
...

文件过滤和编辑操作


  • 编辑文件vi/vim:vi是Linux命令行界面下的文字编辑器,几乎所有的Linux系统都安装了vi,只要学会了vi这个编辑工具,就可以在任何Linux系统上使用它。而vim是vi命令的增强版(Vi IMproved),与vi编辑器完全兼容,此外还有很多增强功能,例如用不同颜色高亮显示代码。因此,如果系统有vim命令,那么建议大家就使用vim编辑文本。
//vi/vim普通模式vi + 文件名,一些快捷操作:dd删除当前光标行 ndd删除从光标开始向下至n行 gg将光标移动至第一行 
[root@localhost demo]# vi demo1.txt 
this is add  dsdsathis is add  dsdsa
this is add  dsdsathis is add  dsdsa
this is add  dsdsathis is add  dsdsathis is add  dsdsa
this is add  dsdsathis is add  dsdsa
this is add  dsdsa
this is a demo 1 file
//编辑模式,在普通模式下按“i,I,o,O,a,A,r,R,s,S”键进入编辑模式,此时左下角要有插入的标记
this is add  dsdsathis is add  dsdsa
this is add  dsdsathis is add  dsdsa
...                                                                                             
-- INSERT --
//命令行模式:在普通模式下,输入“:”或“/”或“?”时,光标会自动定位在那一行,在这个模式中,可以执行保存、退出、搜索、替换、显示行号等相关操作。
this is add  dsdsathis is add  dsdsa
...                                                                                                                                                                                                                                                                                                      
:
//命令模式常用命令:w(保存) q(退出) !(强制) 
  • 分割文件,split(-l指定分割后文件的最大行数)
//split + 选项 + 输入文件名 + 输出文件名前缀
//按行数分割
[root@localhost demo]# split -l 10 log.log new_
[root@localhost demo]# ls
@          demo2.txt  demodir1  demodir3  employee.txt  log.log  new_ab  new_ad  new_af  test3
demo1.txt  demo3.txt  demodir2  demodir4  empty.txt     new_aa   new_ac  new_ae  test2
[root@localhost demo]# cat new_aa 
eeeeeeeeeee:
eeeeeeeee
log.....
pi@swift-hub-006:/var/log$ head swift.log 
nohup: ignoring input
2022-07-12 20:43:05,028 - linkkit - INFO - start connect
2022-07-12 20:43:05,032 - linkkit - INFO - start connect
2022-07-12 20:43:05,035 - device_connector.ali_connect - ERROR - sensor6-1[sensors] - 'NoneType' object has no attribute 'status'
2022-07-12 20:43:05,037 - linkkit - INFO - start connect
2022-07-12 20:43:06,178 - linkkit - INFO - __on_internal_connect
//按大小分割
[root@localhost demo]# split -b 2k log.log size_
[root@localhost demo]# ls
@          demo2.txt  demodir1  demodir3  employee.txt  log.log  new_ab  new_ad  new_af   size_ab  test3
demo1.txt  demo3.txt  demodir2  demodir4  empty.txt     new_aa   new_ac  new_ae  size_aa  test2
  • 合并文件,paste,join
//paste命令能将文件按照行与行进行合并,中间使用tab隔开。-d(指定分隔符) -s(每个文件占用一行)
[root@localhost demo]# cat a.txt 
a01
a02
a03
a04
a05
a06
a07
a08
a09
[root@localhost demo]# cat password.txt 
p1
p2
p3
p4
p5
p6
p7
[root@localhost demo]# paste -d: a.txt password.txt  > aInfo.txt
[root@localhost demo]# ls
@                a.txt  demo2.txt  demodir1  demodir3  employee.txt  log.log  new_ab  new_ad  new_af        size_aa  test2
aInfo.txt  demo1.txt    demo3.txt  demodir2  demodir4  empty.txt     new_aa   new_ac  new_ae  password.txt  size_ab  test3
[root@localhost demo]# cat aInfo.txt 
a01:p1
a02:p2
a03:p3
a04:p4
a05:p5
a06:p6
a07:p7
a08:
a09:
//join命令针对每一对具有相同内容的输入行,整合为一行输出到标准输出,默认情况下是把输入的第一个字段作为连接字段,字段之间用空格隔开。join命令可以处理具有相关性的文件。
[root@localhost join]# cat a.txt 
s1 87
s2 83
s3 82
...
[root@localhost join]# cat b.txt 
s1 男
s2 女
s3 男
...
[root@localhost join]# join a.txt b.txt 
s1 87 男
s2 83 女
s3 82 男
...
  • 去重,uniq命令可以输出或忽略文件中的重复行。在工作中,我们常用的场景是使用sort命令对文件排序,然后使用uniq命令去重并计数。-c去除重复行 -d只显示重复行 -u只显示唯一行
// uniq + 文件 -c(显示重复的数量)
[root@localhost uniq]# cat multi1.txt 
line
line
line 2
line 2
line 2
line 2
line 2
line 2
line 2
line 23
[root@localhost uniq]# uniq multi1.txt 
line
line 2
line 23
[root@localhost uniq]# uniq -c multi1.txt 
      7 line
      7 line 2
      1 line 23
//当重复行没有连续时候,去除重复行仍然有重复的此时需要结合sort一起来使用
[root@localhost uniq]# cat multi.txt 
line
line
line2
line2
line
line3
line
line4
line3
line4
[root@localhost uniq]# uniq multi.txt 
line
line2
line
line3
line
line4
line3
line4
[root@localhost uniq]# sort multi.txt | uniq -c
      4 line
      2 line2
      2 line3
      2 line4
  • 三剑客:grep sed awk这三个命令基本能处理大部分文件情况这里不再说明,后续单独详细记录下。

文件权限


  • 查看权限lsattr
//lsattr(命令用于查看文件的扩展属性。)
[root@localhost demo]# lsattr -a log.log 
--------------- log.log
  • 设置文件权限,chown,chmod(改变目录或文件权限),chattr(改变文件扩展属性),chgrp
//chmod:改变文件或目录权限,只有文件的拥有者和root用户才能执行使用方式: chmod 【option】 【mode】 【file】
[root@localhost chmod]# chmod a= demo.txt #<===设置所有权限为空
[root@localhost chmod]# ll
total 0
----------. 1 root root 0 Jul 19 09:14 demo.txt
[root@localhost chmod]# chmod -R 7 demo.txt #<===设置文件权限可读可写可执行
[root@localhost chmod]# ll
total 0
-------rwx. 1 root root 0 Jul 19 09:14 demo.txt
//chown:改变文件或目录的用户和用户组,使用方式: chown 【选项】 【用户:用户组】 【文件或目录】
[root@localhost chown]# ll
total 0
-rw-r--r--. 1 root root 0 Jul 19 09:29 demo.txt
[root@localhost chown]# chown aaa demo.txt #<=== 不存在的用户会报错
chown: invalid user: ‘aaa’
[root@localhost chown]# chown test demo.txt 
[root@localhost chown]# ll
total 0
-rw-r--r--. 1 test root 0 Jul 19 09:29 demo.txt
[root@localhost chown]# chown zz demo.txt 
[root@localhost chown]# ll
total 0
-rw-r--r--. 1 zz root 0 Jul 19 09:29 demo.txt
//chattr:用于改变文件扩展属性,与chmod相比chmod只是改变文件的读、写、执行权限,更底层,使用方式:chmod 【options】 【mode】 【file】
[root@localhost chattr]# touch demo.txt
[root@localhost chattr]# lsattr demo.txt 
---------------- demo.txt
[root@localhost chattr]# chattr +a demo.txt  #<===改变文件权限使其只能追加内容不能删除
[root@localhost chattr]# lsattr demo.txt 
-----a---------- demo.txt
[root@localhost chattr]# echo 222 >>demo.txt 
[root@localhost chattr]# lsattr demo.txt 
-----a---------- demo.txt
[root@localhost chattr]# cat demo.txt 
222
[root@localhost chattr]# sudo rm demo.txt  #<===删除失败
rm: cannot remove ‘demo.txt’: Operation not permitted
[root@localhost chattr]# chattr +i demo.txt #<===文件加锁使其只能只读
[root@localhost chattr]# lsattr demo.txt 
----ia---------- demo.txt
[root@localhost chattr]# rm demo.txt 
rm: remove regular file ‘demo.txt’? y
rm: cannot remove ‘demo.txt’: Operation not permitted

注:已知r权限对应的数字为4,w权限对应的数字为2,x权限对应的数字为1,“-”权限对应的数字为0。因此rwx权限换成数字一一对应于421,然后做个加法:4+2+1=7。同理r-x的数字权限总和为5,-wx的数字权限总和为3

总结


以上是对linux文件操作命令的整理,在复习每个命令的意义是都会在系统中操作一下,这样更能加深对该命令的了解。个人认为想要学习好Linux那了解他常用的命令是第一步也是最关键的一步,先掌握了才能使用好。


相关文章
|
3天前
|
安全 Linux
Linux系统之lsof命令的基本使用
【10月更文挑战第14天】Linux系统之lsof命令的基本使用
24 2
Linux系统之lsof命令的基本使用
|
4天前
|
Linux
Linux 系统五种帮助命令的使用
Linux 系统五种帮助命令的使用
30 14
|
1天前
|
运维 网络协议 Linux
linux系统命令 losf详解
**lsof命令**(List Open Files)是Linux系统中一个非常实用的工具,用于列出当前系统上所有打开的文件以及与之关联的进程。以下是对lsof命令的详细介绍: ### 一、基本功能 lsof命令可以显示系统中被进程打开的文件,这些文件可以是普通文件、目录、网络套接字、设备文件等。通过lsof命令,用户可以方便地查看哪些文件被哪些进程打开,以及这些文件的状态信息。 ### 二、基本语法 lsof命令的基本语法为:`lsof [选项] [文件]`。其中,选项用于指定lsof命令的行为,文件则是可选的,用于指定要查询的文件。 ### 三、常用选项 * `-a` 或 `-
|
1天前
|
Linux Perl
Linux awk命令使用技巧
【10月更文挑战第16天】Linux awk命令使用技巧
9 4
|
6天前
|
Linux
Linux经常使用命令汇总和总结
Linux经常使用命令汇总和总结
25 1
|
6天前
|
安全 Linux Shell
Linux | Rsync 命令:16 个实际示例(上)
Linux | Rsync 命令:16 个实际示例(上)
19 0
Linux | Rsync 命令:16 个实际示例(上)
|
5天前
|
Unix Linux 开发工具
Linux Vim的 命令大全
Linux Vim的 命令大全
12 0
|
5月前
|
Linux
百度搜索:蓝易云【Linux中如何对文件进行压缩和解压缩?】
这些是在Linux中进行文件压缩和解压缩的常见方法。根据您的需求和具体情况,可能会使用其他压缩工具和选项。您可以通过查阅相应命令的帮助文档来获取更多详细信息。
81 1
|
5月前
|
NoSQL Java Linux
Linux常用命令(文件目录操作、拷贝移动、打包压缩、文本编辑、查找)
Linux常用命令(文件目录操作、拷贝移动、打包压缩、文本编辑、查找)
|
5月前
|
算法 Java Linux
Linux下文件增删改查定位压缩操作与权限所属用户
Linux下文件增删改查定位压缩操作与权限所属用户
68 0