zoukankan      html  css  js  c++  java
  • Linux常用基本命令( tree, pwd, cd )

    pwd与cd命令

    >pwd命令是“print working directory”中每个单词的首字母缩写,其功能是显示当前工作目录的绝对路径。在实际工作中,我们在命令行操作命令时,经常会在各个目录路径之间进行切换,此时可使用pwd命令快速查看当前我们所在的目录路径。

    还有一个 $PWD 环境变量,可以显示当前工作目录的绝对路径

    ghostwu@dev:~$ echo $PWD
    /home/ghostwu
    ghostwu@dev:~$ cd ./php
    ghostwu@dev:~/php$ echo $PWD
    /home/ghostwu/php
    ghostwu@dev:~/php$ pwd
    /home/ghostwu/php
    ghostwu@dev:~/php$ 
    ghostwu@dev:~$ pwd
    /home/ghostwu
    ghostwu@dev:~$ cd /
    ghostwu@dev:/$ pwd
    /
    ghostwu@dev:/$ ls
    bin    dev   initrd.img  lost+found  opt   run   srv  usr
    boot   etc   lib         media       proc  sbin  sys  var
    cdrom  home  lib64       mnt         root  snap  tmp  vmlinuz
    ghostwu@dev:/$ cd /etc/
    ghostwu@dev:/etc$ cd
    ghostwu@dev:~$ cd -
    /etc
    ghostwu@dev:/etc$ cd ~
    ghostwu@dev:~$ cd -
    /etc
    ghostwu@dev:/etc$ cd ../home/ghostwu/
    ghostwu@dev:~$ 

    cd命令是“change directory”中每个单词的首字母缩写,其功能是从当前工作目录切换到指定的工作目录。

    >切换到当前目录的上一级目录(cd..)。

    >切换到当前目录( cd . )。

    >切换到家目录( cd ~ ) ,cd不带参数 也是切换到家目录

    >切换到刚才的目录( cd - )

    tree命令,查看目录与文件的组织结构,默认ubuntu没有安装tree

    ghostwu@dev:~$ tree
    The program 'tree' is currently not installed. You can install it by typing:
    sudo apt install tree
    ghostwu@dev:~$ sudo apt install tree
    ghostwu@dev:~$ tree
    .
    ├── Desktop
    ├── Documents
    ├── Downloads
    │   ├── 1.rar
    │   ├── 1 - 副本.pptx
    │   ├── 2.rar
    │   ├── 2 - 副本.pptx
    │   ├── 3.rar
    ...............

    tree -d: 只显示目录

    tree -dL 2: L参数指定显示的层级  2表示2层

    tree -df:显示完整路径

    tree -dfi: 不显示树状层级结构

    tree -L 1 -F: F参数会在目录后面加个 /,作用:用来跟文件区分

    ghostwu@dev:~$ tree -L 1
    .
    ├── Desktop
    ├── Documents
    ├── Downloads
    ├── examples.desktop
    ├── git_test
    ├── info
    ├── Music
    ├── php
    ├── Pictures
    ├── project
    ├── Public
    ├── python
    ├── software
    ├── Templates
    └── Videos
    
    14 directories, 1 file
    ghostwu@dev:~$ tree -L 1 -F
    .
    ├── Desktop/
    ├── Documents/
    ├── Downloads/
    ├── examples.desktop
    ├── git_test/
    ├── info/
    ├── Music/
    ├── php/
    ├── Pictures/
    ├── project/
    ├── Public/
    ├── python/
    ├── software/
    ├── Templates/
    └── Videos/
    
    14 directories, 1 file
    ghostwu@dev:~$ 
  • 相关阅读:
    微型三维图像传感器采用飞行时间技术
    利用反射计芯片进行非接触式液位测量
    嵌入式传感器是智能移动增长的关键
    传感器融合带来多重好处
    参与机器人技术开发
    管理多供应商物联网项目的10个关键步骤
    基于ARMv8的固件系统体系结构
    嵌入式Linux设备驱动程序:在运行时读取驱动程序状态
    Elasticsearch之配置详解
    Spring Data Elasticsearch 和 x-pack 用户名/密码验证连接
  • 原文地址:https://www.cnblogs.com/ghostwu/p/8969710.html
Copyright © 2011-2022 走看看