点击蓝字
关注我们


rm -rf *
复制
今天就继续从这个命令讲起,来讲与文件目录操作有关的命令。
rm其实就是remove ,-rf表示强制删除目录,而"/"则是根目录。在Windows上也许有C盘、D盘,但在Linux上一切都来源于"/",且一切都是文件。所以对文件与目录的操作也可谓重中之重。至于"*"则是通配符,这里略过。
[tom@csbebetter ~]$ pwd
/home/tom
复制
[tom@csbebetter ~]$ cd etc
[tom@csbebetter etc]$ cd -
/home/tom
复制
[tom@csbebetter ]$ ls -al
total 68
dr-xr-xr-x. 18 root root 4096 Jan 20 20:05 .
dr-xr-xr-x. 18 root root 4096 Jan 20 20:05 ..
-rw-r--r-- 1 root root 0 Dec 28 03:41 .autorelabel
lrwxrwxrwx. 1 root root 7 Dec 28 11:37 bin -> usr/bin
dr-xr-xr-x. 5 root root 4096 Dec 28 11:49 boot
drwxr-xr-x 19 root root 2960 Jan 20 20:05 dev
drwxr-xr-x. 76 root root 4096 Jan 20 20:44 etc
drwxr-xr-x. 3 root root 4096 Jan 20 20:38 home
lrwxrwxrwx. 1 root root 7 Dec 28 11:37 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 Dec 28 11:37 lib64 -> usr/lib64
drwx------. 2 root root 16384 Dec 28 11:37 lost+found
drwxr-xr-x. 2 root root 4096 Apr 11 2018 media
drwxr-xr-x. 2 root root 4096 Apr 11 2018 mnt
drwxr-xr-x. 2 root root 4096 Apr 11 2018 opt
dr-xr-xr-x 84 root root 0 Jan 20 20:05 proc
dr-xr-x---. 7 root root 4096 Jan 20 22:09 root
drwxr-xr-x 23 root root 620 Jan 20 22:08 run
lrwxrwxrwx. 1 root root 8 Dec 28 11:37 sbin -> usr/sbin
drwxr-xr-x. 2 root root 4096 Apr 11 2018 srv
dr-xr-xr-x 13 root root 0 Jan 21 04:05 sys
drwxrwxrwt. 9 root root 4096 Jan 21 03:13 tmp
drwxr-xr-x. 13 root root 4096 Dec 28 11:37 usr
drwxr-xr-x. 19 root root 4096 Dec 28 03:41 var
复制
cat命令:查看纯文本文件(内容较少)
more命令:查看纯文本文件(内容较多)
head命令:查看纯文本文件的前n行,下为查看该文件的前20行。
head -n 20 initial-setup-ks.cfg
复制
[tom@csbebetter ~]$ stat txt.txt
File: ‘txt.txt’
Size: 25 Blocks: 8 IO Block: 4096 regular file
Device: fd01h/64769d Inode: 1314827 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/ tom) Gid: ( 1000/ tom)
Access: 2021-01-21 10:25:00.498812018 +0800
Modify: 2021-01-21 10:25:00.498812018 +0800
Change: 2021-01-21 10:25:00.498812018 +0800
Birth: -
复制
[tom@csbebetter ~]$ diff -c txt.txt txt1.txt
*** txt.txt 2021-01-21 10:25:00.498812018 +0800
--- txt1.txt 2021-01-21 10:27:33.647650289 +0800
***************
*** 1,3 ****
hello world
tom
! hey guys
--- 1,3 ----
hello world
tom
! hey guys!
复制

[tom@csbebetter ~]$ touch -d "1999-02-08 11:11" txt1.txt
[tom@csbebetter ~]$ ls -l
total 8
-rw-rw-r-- 1 tom tom 26 Feb 8 1999 txt1.txt
-rw-rw-r-- 1 tom tom 25 Jan 21 10:25 txt.txt
复制
[tom@csbebetter ~]$ mkdir -p Music/netmusic
[tom@csbebetter ~]$ ls
Music txt1.txt txt.txt
[tom@csbebetter ~]$ cd Music/
[tom@csbebetter Music]$ ls
netmusic
复制
[tom@csbebetter ~]$ file txt.txt
txt.txt: ASCII text
复制
-t, --list 列出归档内容
-c, --create 创建一个新归档
-x, --extract, --get 从归档中解压出文件
-z, --gzip, --gunzip, --ungzip 通过 gzip 过滤归档
-v, --verbose 详细地列出处理的文件
-f, --file=ARCHIVE 使用归档文件或 ARCHIVE 设备
复制
说到查找命令,find命令肯定不能少。
就这么多了,感谢浏览。
谢谢大家。

扫码关注我们
微信号|赤子孤独
文章转载自赤子孤独,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。