今天练了练linux文件的操作。
文档的建立:touch a
文件夹的创建: mkdir A
文档的删除:rm a
查看文件夹文件:ls
进入文件夹(新的目录):cd A
返回上一层目录:cd ..
将t文件复制到文件夹A中:cp t A
删除文件: rm t
暴力删除:rm t -fr
剪切文件t到A:mv t A
进入根目录:cd /(查看磁盘)
查看文档内容:cat a
向文档写新的内容(增添):echo "whatever"> a
向文档写新的内容(覆盖):echo "whatever">> a
文档清空内容:echo ""> a
或者:echo > a
[root@edemon Desktop]# mkdir qq
[root@edemon Desktop]# cd qq
[root@edemon qq]# touch a1 a2 a3
[root@edemon qq]# ls
a1 a2 a3
[root@edemon Desktop]# ls
aa
[root@edemon Desktop]# cd aa
[root@edemon aa]# touch a1 a2 a3
[root@edemon aa]# ls
a1 a2 a3
[root@edemon aa]# cd ..
[root@edemon Desktop]# mkdir bb
[root@edemon Desktop]# cd aa
[root@edemon aa]# cp a1 a2 a3 bb
[root@edemon aa]# cd ..
[root@edemon Desktop]# touch temp
[root@edemon Desktop]# cp temp bb
[root@edemon Desktop]# cd bb
[root@edemon bb]# ls
temp
[root@edemon Desktop]# touch temp
[root@edemon Desktop]# rm temp -fr
[root@edemon Desktop]# touch r
[root@edemon Desktop]# mv r bb
[root@edemon Desktop]# ls bb
r temp
[root@edemon Desktop]# cd /
[root@edemon /]# ls
bin cgroup etc lib lost+found misc net proc sbin srv tmp var
boot dev home lib64 media mnt opt root selinux sys usr
[root@edemon /]# cd root
[root@edemon ~]# ls
anaconda-ks.cfg Documents install.log Music Public Videos
Desktop Downloads install.log.syslog Pictures Templates
[root@edemon ~]# cd Documents
[root@edemon Documents]# ls
red1 red2 red3
[root@edemon Documents]# cd ..
[root@edemon ~]# cd Desktop
[root@edemon Desktop]# cat tt
this is my document
[root@edemon Desktop]# echo ""> tt
[root@edemon Desktop]# echo "this is my document" >> tt
[root@edemon Desktop]# echo ""> tt
[root@edemon Desktop]# echo "this is my document"> tt
[root@edemon Desktop]# echo >tt
[root@edemon Desktop]#