liunx常用命令

在liunx中可能有几百个命令,最常用的就10多个。

ls

功能

查看目录有哪些内容,全称list

使用说明

ls [待查看的目录] [参数]

待查看的目录:非必填的选项,一般情况下都是看当前目录,可省去;非当前目录时,需要指定要查看的目录。
参数:包含是否包含隐藏文件,是否显示文件的权限、大小、修改时间等,常用的有
-a表示包含隐藏文件
-lh表示查看文件的权限、修改时间、大小

案例

  • 查看当前目录
host@localhost getting-started % ls
Dockerfile		app			mkdocs.yml
Jenkinsfile		build.sh		requirements.txt
LICENSE			docker-compose.yml	yarn.lock
README.md		docs
  • 包含隐藏文件
host@localhost getting-started % ls -a
.			.gitignore		build.sh
..			Dockerfile		docker-compose.yml
.DS_Store		Jenkinsfile		docs
.dockerignore		LICENSE			mkdocs.yml
.git			README.md		requirements.txt
.github			app			yarn.lock
  • 显示文件权限、大小、修改时间
host@localhost getting-started % ls -lh
total 88
-rw-r--r--  1 host  staff   1.0K  8 28  2021 Dockerfile
-rw-r--r--  1 host  staff   535B  8 28  2021 Jenkinsfile
-rw-r--r--  1 host  staff    11K  8 28  2021 LICENSE
-rw-r--r--  1 host  staff   1.6K  8 28  2021 README.md
drwxr-xr-x  7 host  staff   224B  8  8 22:48 app
-rwxr-xr-x  1 host  staff   253B  8 28  2021 build.sh
-rw-r--r--  1 host  staff   167B  8 28  2021 docker-compose.yml
drwxr-xr-x  8 host  staff   256B  8  8 22:48 docs
-rw-r--r--  1 host  staff   1.9K  8 28  2021 mkdocs.yml
-rw-r--r--  1 host  staff   105B  8 28  2021 requirements.txt
-rw-r--r--  1 host  staff    86B  8 28  2021 yarn.lockpowershell

  • 显示隐藏文件和文献信息
host@localhost getting-started % ls -alh
total 120
drwxr-xr-x   18 host  staff   576B  2  6  2022 .
drwxr-xr-x+ 131 host  staff   4.1K  8 20 22:49 ..
-rw-r--r--@   1 host  staff   6.0K  8  8 22:48 .DS_Store
-rw-r--r--    1 host  staff    12B  8 28  2021 .dockerignore
drwxr-xr-x   13 host  staff   416B  8 28  2021 .git
drwxr-xr-x    3 host  staff    96B  8 28  2021 .github
-rw-r--r--    1 host  staff    13B  8 28  2021 .gitignore
-rw-r--r--    1 host  staff   1.0K  8 28  2021 Dockerfile
-rw-r--r--    1 host  staff   535B  8 28  2021 Jenkinsfile
-rw-r--r--    1 host  staff    11K  8 28  2021 LICENSE
-rw-r--r--    1 host  staff   1.6K  8 28  2021 README.md
drwxr-xr-x    7 host  staff   224B  8  8 22:48 app
-rwxr-xr-x    1 host  staff   253B  8 28  2021 build.sh
-rw-r--r--    1 host  staff   167B  8 28  2021 docker-compose.yml
drwxr-xr-x    8 host  staff   256B  8  8 22:48 docs
-rw-r--r--    1 host  staff   1.9K  8 28  2021 mkdocs.yml
-rw-r--r--    1 host  staff   105B  8 28  2021 requirements.txt
-rw-r--r--    1 host  staff    86B  8 28  2021 yarn.lock

pwd

功能

查看当前目录的结构,全称print work directory

使用说明

pwd 

案例

  • 查看当前的目录结构
host@localhost getting-started % pwd
/Users/host/getting-started

cd

功能

切换文件夹,全称change directory

使用说明

cd 待进入的目录

案例

host@localhost getting-started % pwd
/Users/host/getting-started
host@localhost getting-started % ls
Dockerfile		app			mkdocs.yml
Jenkinsfile		build.sh		requirements.txt
LICENSE			docker-compose.yml	yarn.lock
README.md		docs
host@localhost getting-started % cd app
host@localhost app % pwd
/Users/host/getting-started/app
host@localhost app % ls
package.json	spec		src		yarn.lock

mkdir

功能

创建目录

使用说明

mkdir [-p] dirName

-p 表示可迭代创建目录,确保目录名称存在,不存在的就建一个。对于创建多层目录,使用-p可一层层的判断目录是否存在,若不存在就创建。
dirName表示待创建的目录名称

案例

host@localhost app % ls
package.json	spec		src		yarn.lock
host@localhost app % 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值