linux 进入目录代码,Linux目录管理命令(示例代码)

1、打开文件夹命令:cd

cd /DIR

示例:打开etc目录

cd /etc/

2、查看当前目录命令:pwd

示例:当前所在位置/tmp下

tmp]# pwd

/tmp

3、查看当前路径下所有文件及文件夹:ls

示例:当前在/etc/sysconfig/network-sprits目录下

network-scripts]# ls

ifcfg-eth0   ifdown-isdn    ifup-aliases

ifup-plusb     init.ipv6-global

ifcfg-lo     ifdown-post    ifup-bnep

ifup-post      net.hotplug

ifdown       ifdown-ppp     ifup-eth

ifup-ppp       network-functions

ifdown-bnep  ifdown-routes  ifup-ippp

ifup-routes    network-functions-ipv6

ifdown-eth   ifdown-sit

ifup-ipv6     ifup-sit

ifdown-ippp  ifdown-tunnel  ifup-isdn

ifup-tunnel

ifdown-ipv6  ifup           ifup-plip     ifup-wireless

使用参数al:显示当前路径下全部文件,文件夹及相关属性

ls -al

总用量 212

drwxr-xr-x. 2 root root  4096 3月   9 22:20

.

drwxr-xr-x. 7 root root  4096 3月  24 07:41 ..

-rw-r--r--. 1 root root

205 3月   9 22:20 ifcfg-eth0

-rw-r--r--. 1 root root   254 7月  22 2014

ifcfg-lo

lrwxrwxrwx. 1 root root    20 3月   9 22:10 ifdown ->

../../../sbin/ifdown

-rwxr-xr-x. 1 root root   627 7月  22 2014

ifdown-bnep

-rwxr-xr-x. 1 root root  5511 7月  22 2014

ifdown-eth

-rwxr-xr-x. 1 root root   781 7月  22 2014

ifdown-ippp

-rwxr-xr-x. 1 root root  4168 7月  22 2014

ifdown-ipv6

lrwxrwxrwx. 1 root root    11 3月   9 22:10 ifdown-isdn ->

ifdown-ippp

-rwxr-xr-x. 1 root root  1481 7月  22 2014

ifdown-post

-rwxr-xr-x. 1 root root  1064 7月  22 2014

ifdown-ppp

-rwxr-xr-x. 1 root root   835 7月  22 2014

ifdown-routes

-rwxr-xr-x. 1 root root  1465 7月  22 2014

ifdown-sit

-rwxr-xr-x. 1 root root  1434 7月  22 2014

ifdown-tunnel

lrwxrwxrwx. 1 root root    18 3月   9 22:10 ifup ->

../../../sbin/ifup

-rwxr-xr-x. 1 root root 12532 7月  22 2014

ifup-aliases

-rwxr-xr-x. 1 root root   859 7月  22 2014

ifup-bnep

-rwxr-xr-x. 1 root root 10913 7月  22 2014 ifup-eth

-rwxr-xr-x. 1

root root 11971 7月  22 2014 ifup-ippp

-rwxr-xr-x. 1 root root 10490 7月  22

2014 ifup-ipv6

lrwxrwxrwx. 1 root root     9 3月   9 22:10 ifup-isdn ->

ifup-ippp

-rwxr-xr-x. 1 root root   727 7月  22 2014 ifup-plip

-rwxr-xr-x.

1 root root   954 7月  22 2014 ifup-plusb

-rwxr-xr-x. 1 root root  2364 7月  22

2014 ifup-post

-rwxr-xr-x. 1 root root  4154 7月  22 2014

ifup-ppp

-rwxr-xr-x. 1 root root  1925 7月  22 2014 ifup-routes

-rwxr-xr-x.

1 root root  3289 7月  22 2014 ifup-sit

-rwxr-xr-x. 1 root root  2563 7月  22

2014 ifup-tunnel

-rwxr-xr-x. 1 root root  3951 7月  22 2014

ifup-wireless

-rwxr-xr-x. 1 root root  4623 7月  22 2014

init.ipv6-global

-rwxr-xr-x. 1 root root  1219 7月  22 2014

net.hotplug

-rw-r--r--. 1 root root 14426 7月  22 2014

network-functions

-rw-r--r--. 1 root root 29853 7月  22 2014

network-functions-ipv6

4、创建文件夹命令:mkdir

示例:mkdir  test

当前目录下创建test目录;

参数:-p,存在时不报错,且可自动创建所需的各目录

若指定在tmp/haole/目录下创建test目录,-p命令强制创建haole/test命令

示例:

mkdir -p /tmp/haole/test

参数-v,显示创建的详细信息

参数:-m MODE,指定创建目录权限

5、删除目录命令,rmdir;rmdir命令只删除空文件夹

示例:删除/tmp/hsole/test目录

rmdir test

6、以树状图显示目录结构,tree

├── custom-background.php

├── custom-header.php

├──

customize.php

├── edit-comments.php

├── edit-form-advanced.php

├──

edit-form-comment.php

├── edit-link-form.php

├── edit.php

├──

edit-tag-form.php

├── edit-tags.php

├── export.php

├──

freedoms.php

├── images

│   ├── align-center-2x.png

│   ├──

align-center.png

│   ├── align-left-2x.png

│   ├── align-left.png

├── align-none-2x.png

│   ├── align-none.png

│   ├──

align-right-2x.png

│   ├── align-right.png

│   ├── arrows-2x.png

├── arrows.png

│   ├── browser.png

│   ├── browser-rtl.png

│   ├──

bubble_bg-2x.gif

│   ├── bubble_bg.gif

│   ├──

comment-grey-bubble-2x.png

│   ├── comment-grey-bubble.png

│   ├──

date-button-2x.gif

│   ├── date-button.gif

│   ├── generic.png

│   ├──

icons32-2x.png

│   ├── icons32.png

│   ├── icons32-vs-2x.png

│   ├──

icons32-vs.png

│   ├── imgedit-icons-2x.png

│   ├──

imgedit-icons.png

│   ├── list-2x.png

│   ├── list.png

│   ├──

loading.gif

│   ├── marker.png

│   ├── mask.png

│   ├──

media-button-2x.png

│   ├── media-button-image.gif

│   ├──

media-button-music.gif

│   ├── media-button-other.gif

│   ├──

media-button.png

│   ├── media-button-video.gif

│   ├── menu-2x.png

├── menu.png

│   ├── menu-vs-2x.png

│   ├── menu-vs.png

│   ├──

no.png

参数:

-d:只显示目录

-L level:指定目录的层级数目

-P

pattern:只显示由指定pattern匹配到的路径

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值