尝试 “实验楼” 文件夹及文件操作 (2)

创建目录:-mkdir

<span style="font-size:18px;">tc@box:~$ mkdir testdir
# 创建testdir目录
tc@box:~$ ls
# ls命令能够看到你所创建的目录</span>

删除目录:-rmdir

<span style="font-size:18px;">tc@box:~$ rmdir testdir
# 删除testdir目录,该命令仅仅能删除空目录
tc@box:~$ ls
# ls命令看不到testdir目录</span>

创建文件:-touch

<span style="font-size:18px;">tc@box:~$ mkdir testdir
tc@box:~$ cd testdir
tc@box:~/testdir$ touch testfile
# 使用touch命令创建文件testfile
tc@box:~/testdir$ cat testfile
# 查看文件内容为空</span>

拷贝文件及目录:-cp

tc@box:~/testdir$ echo "000" > testfile
# 加入内容到文件testfile
tc@box:~/testdir$ cp testfile testfilecopy
# 拷贝文件testfile到testfilecopy
tc@box:~/testdir$ diff testfile testfilecopy
# 查看文件testfile和testfilecopy
tc@box:~/testdir$ cd ..
# 到上层目录
tc@box:~$ cp -r testdir testdircopy
# 拷贝目录及目录内容

更改文件属性:-chmod
tc@box:~$ cd testdir
tc@box:~/testdir$ ls -l
# 查看目录下文件具体的属性,r表示读,w表示写。x表示运行
tc@box:~/testdir$ chmod a+w testfile
# 为全部用户加入写属性
tc@box:~/testdir$ ls -l
# 再次查看确认写属性已经加入到文件testfile

更改全部者:-chown

tc@box:~/testdir$ sudo chown root testfile
# 改动文件全部者为root
tc@box:~/testdir$ ls -l
# 再次查看确认全部者已经改动

建立文件链接:-ln
tc@box:~/testdir$ ln -s testfile testfilelink
# 为文件testfile创建软链接testfilelink
tc@box:~/testdir$ ls -l
# 再次查看确认软链接已经创建

移动文件:-mv

tc@box:~/testdir$ mv testfile newtestfile
# 将testfile文件改名为newtestfile
tc@box:~/testdir$ ls -l
# 查看确认文件已改名

删除文件:-rm

tc@box:~/testdir$ rm newtestfile 
# 删除newtestfile
tc@box:~/testdir$ ls -l
# 查看确认文件已被删除

试验效果图:
(1)


(2)


(3)

猜你喜欢

转载自www.cnblogs.com/ldxsuanfa/p/10856075.html
今日推荐