Linux常用命令(一)

显示所有文档及目录(ls内定将文档名或目录名称为“.”的视为隐,不会列出)

[root@localhostvictory1210]# ls –a  /

.   bin  dev  home  lib64      media  opt   root sbin  sys  usr

..  boot etc  lib   lost+found mnt    proc  run  srv   tmp  var

 

#ls  / 查看根目录

#ls  –a /或者在/后加入具体文件夹,显示所有文件,包括隐藏文件

#ls  –l /显示详细信息

#ls -d /显示目录属性,可与-l一起用

#ls  –ld /

 

[root@localhostvictory1210]# ls -l /

总用量 60

lrwxrwxrwx.   1 root root     7 5月  17 04:06 bin -> usr/bin

dr-xr-xr-x.   4 root root 4096 5月  17 09:01 boot

drwxr-xr-x.  19 root root 3160 5月  17 09:00 dev

drwxr-xr-x.  77 root root 4096 5月  17 09:01 etc

drwxr-xr-x.   3 root root 4096 5月  16 20:09 home

lrwxrwxrwx.   1 root root     7 5月  17 04:06 lib -> usr/lib

lrwxrwxrwx.   1 root root     9 5月  17 04:06 lib64 ->usr/lib64

drwx------.   2 root root 16384 5月  1704:06 lost+found

drwxr-xr-x.   2 root root 4096 11月  5 2016 media

drwxr-xr-x.   2 root root 4096 11月  5 2016 mnt

drwxr-xr-x.   2 root root 4096 11月  5 2016 opt

dr-xr-xr-x. 106 rootroot     0 5月  1709:00 proc

dr-xr-x---.   2 root root 4096 5月  16 20:29 root

drwxr-xr-x.  22 root root  620 5月  17 09:01 run

lrwxrwxrwx.   1 root root     8 5月  17 04:06 sbin -> usr/sbin

drwxr-xr-x.   2 root root 4096 11月  5 2016 srv

dr-xr-xr-x.  13 root root     0 5月  17 09:00 sys

drwxrwxrwt.  10 root root 4096 5月  17 10:26 tmp

drwxr-xr-x.  13 root root 4096 5月  17 04:06 usr

drwxr-xr-x.  19 root root 4096 5月  17 09:00 var

 

[root@localhostvictory1210]# ls -ld /

dr-xr-xr-x. 18 root root4096 5月  16 20:09 /

 

在Linux回到父目录下为cd ..,cd后面必须有空格

 

cd(切换目录)

范例:$cd /

   $cd ..

[root@localhostvictory1210]# cd /

[root@localhost /]# cd ..

[root@localhost /]#

 

pwd(查看所在目录)

范例:$pwd

[root@localhostvictory1210]# pwd

/home/victory1210

 

mkdir(创建新目录)

范例:$mkdir newdir

[root@localhost /]# mkdir test

[root@localhost /]# cd test

[root@localhost test]#pwd

/test

 

touch(创建新文件)

范例:$touch newfile

[root@localhost test]#touch testfile

[root@localhost test]# ls  -l  testfile

-rw-r--r--. 1 root root 05月  17 10:58 testfile

[root@localhost test]# ls  -a   /test

.  .. testfile

 

cp(复制)

范例:$cp file1 file2 dir1将文件file1、file2复制到目录dir1

   $cp -R dir1 dir2 将dir1下所有文件及子目录复制到dir2

[root@localhost test]# cp  /etc/inittab  /test

[root@localhost test]# ls  /test

inittab  testfile

如果复制文件,则需要在cp后加-R

 

mv(剪切、更名)

范例:$mv file1 file3 将当前目录下文件file1更名为file3

     $MVfile2 dir2  将文件file2移动到目录dir2下

[root@localhostvictory1210]# cd  /test

[root@localhost test]# mv  testfile  testfiles          //更名

[root@localhost test]# ls /test

inittab  testfiles

 

[root@localhost test]#mkdir  /test/test1

[root@localhost test]# ls  /test

inittab  test1 testfiles

[root@localhost test]# mv  /test/testfiles   test1

[root@localhost test]# ls  /test

inittab  test1

[root@localhost test]# ls  /test/test1

Testfiles

 

[root@localhost test]# mv  /test/test1/testfiles  /test/testfile1  //移动并改名文件

[root@localhost test]# ls /test

inittab  test1 testfile1

 

rm(删除)

删除文件

范例:$rm  file1 将文件file1删除

   $rm  -r  dir1 将目录dir1 删除(需要确认删除)

   $rm  -f  dir1 将目录dir1 删除(不需要确认删除)

   $rm  -rf  dir1 将目录dir1 删除(如果dir1下有很多子目录,一并删除,不需重复确认删除)

[root@localhost test]# rm  testfile1

rm:是否删除普通空文件 "testfile1"?y

[root@localhost test]# ls

inittab  test1

 

删除目录

[root@localhost test]# ls

inittab  test1

[root@localhost test]# rm  -r  test1

rm:是否删除目录 "test1"?y

[root@localhost test]# ls

Inittab

 

不确认删除(-f)

[root@localhost test]#touch testfile2

[root@localhost test]# rm  -f  testfile2

 

如果文件夹下很多子文件夹,可以直接-rf可一并删除

[root@localhost test]# ls

inittab  wenjianjia

[root@localhost test]# rm  -rf  wenjianjia

[root@localhost test]# ls

inittab

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值