1 Linux pwd —— 打印当前工作目录名
pwd - print name of current/working directory
Linux pwd命令用于显示工作目录。
执行pwd指令可立刻得知目前所在的工作目录的绝对路径名称。
语法
1 | pwd: pwd [-LP] |
实例
1 | # pwd |
2 Linux cd —— 更改目录
Linux cd命令用于切换当前工作目录至 dirName(目录参数)。
其中 dirName 表示法可为绝对路径或相对路径。若目录名称省略,则变换至使用者的 home 目录 (也就是刚 login 时所在的目录)。
另外,”~” 也表示为 home 目录 的意思,”.” 则是表示目前所在的目录,”..” 则表示目前目录位置的上一层目录。
绝对路径:是以根目录(” / “)为起点的完整路径,以你所要到的目录为终点.
相对路径:是你当前的目录(” . “)为起点的路径,以你所要到的目录为终点.
语法
1 | cd [dirName] |
dirName:要切换的目标目录
实例
1 | 跳到/usr/bin目录: `cd /usr/bin` |
3 Linux ls —— 列出目录内容
Linux ls命令用于显示指定工作目录下之内容(列出目前工作目录所含之文件及子目录)。
语法
ls [-alrtAFR] [name...]
参数
1 | -a 显示所有文件及目录 (ls内定将文件名或目录名称开头为"."的视为隐藏档,不会列出) |
实例

ls -m1
_config.yml, db.json, debug.log, node_modules, package.json, picture, public,scaffolds, source,themes
ls -F1
2_config.yml debug.log package.json public/ source/
db.json node_modules/ picture/ scaffolds/ themes/
ls -i1
22103593 _config.yml 2103582 debug.log 2103588 package.json 3804283 public 3148925 source
2097664 db.json 3802635 node_modules 3803114 picture 3148921 scaffolds 3148929 themes
ls -lS , 列出文件详细信息,并按文件大小进行排序1
2
3
4
5
6
7
8
9
10
11总用量 960
-rw-r--r-- 1 hhs hhs 501668 5月 3 23:25 debug.log
-rw-r--r-- 1 hhs hhs 430262 7月 18 01:47 db.json
drwxr-xr-x 298 hhs hhs 12288 5月 3 15:18 node_modules
drwxr-xr-x 2 hhs hhs 4096 7月 18 01:33 picture
drwxr-xr-x 14 hhs hhs 4096 7月 18 2019 public
drwxr-xr-x 2 hhs hhs 4096 5月 3 15:18 scaffolds
drwxr-xr-x 8 hhs hhs 4096 5月 3 23:41 source
drwxr-xr-x 5 hhs hhs 4096 5月 3 22:51 themes
-rw-r--r-- 1 hhs hhs 2161 5月 4 13:00 _config.yml
-rw-r--r-- 1 hhs hhs 483 5月 3 15:18 package.json
ls -tlr , 列出文件详细信息,并按文件建立时间次序排序。1
2
3
4
5
6
7
8
9
10
11总用量 960
-rw-r--r-- 1 hhs hhs 483 5月 3 15:18 package.json
drwxr-xr-x 298 hhs hhs 12288 5月 3 15:18 node_modules
drwxr-xr-x 2 hhs hhs 4096 5月 3 15:18 scaffolds
drwxr-xr-x 5 hhs hhs 4096 5月 3 22:51 themes
-rw-r--r-- 1 hhs hhs 501668 5月 3 23:25 debug.log
drwxr-xr-x 8 hhs hhs 4096 5月 3 23:41 source
-rw-r--r-- 1 hhs hhs 2161 5月 4 13:00 _config.yml
drwxr-xr-x 2 hhs hhs 4096 7月 18 01:33 picture
-rw-r--r-- 1 hhs hhs 430262 7月 18 01:47 db.json
drwxr-xr-x 14 hhs hhs 4096 7月 18 2019 public