Linux view command cd, ls, pwd

1. cd command

Function: enter the specified directory.

cd 目录名 # 进入目录,如:cd demo

other:

cd .. # 返回上一级目录
cd ../../ # 返回上两级目录
cd ~ # 进入用户目录 (Home)
cd - # 返回上一步的目录

2. ls command

Function: View file/folder content, support sorting, size, attribute, permission viewing.

ls # 查看目录及文件
ls -l # 输出详细信息
ls -a # 显示所有文件
ls -lh  # 输出详细信息,文件大小显示为 K, MB, GB
ls --help # 帮助

2.1, ls -l output detailed information

Function: output detailed information -l (short for long)

        This command will print out the permissions of the file (-rw-rw-r-- we will elaborate on this later), user name, file size, modification date, and file name.

~/Documents$ ls -l
total 4
-rw-rw-r-- 1 morvan morvan    0 Oct 12 07:38 file1
drwxrwxr-x 2 morvan morvan 4096 Oct 12 07:26 folder1

2.2, ls -a (short for all) displays all files

Function: Display all files, including hidden files (beginning with .)

$ ls -a
.  ..  file1  folder1  .hidden_file

2.3, ls -lh (human) display for people

Function: The file size here uses K, MB, GB and other generalizations

$ ls -lh
total 4.0K
-rw-rw-r-- 1 morvan morvan    0 Oct 12 07:38 file1
drwxrwxr-x 2 morvan morvan 4.0K Oct 12 07:26 folder1

2.4, ls --help help

-a :全部的文件,连同隐藏文件(开头为.的文件)一起列出来
-A :全部的文件,连同隐藏文件,但是不包括.和…这两个目录
-d :仅列出目录本身,而不是列出目录内的文件数据
-f :直接列出结果,而不进行排序(ls默认会以文件名排序)
-F:根据文件、目录等信息,给予附件数据结构,例如:*:代表可执行文件;/:代表目录;=:代表socket文件;|:代表FIFO文件
-h:将文件容量以人类较易读的方式(如GB,KB等)列出来
-i:列出inode号码
-l:详细信息显示,包含文件的属性和权限等数据
-n:列出UID和GID而非使用者与用户组的名称
-r:将排序结果反向输出,例如:原本文件名由小到大,反向则由大到小
-R:连同子目录内容一起列出来,等于该目录下的所有文件都会显示出来
-S:以文件容量大小排序,而不是用文件名排序
-t:依时间排序,而不是用文件名排序

3. pwd command

Function: View the absolute path of the current directory.

Guess you like

Origin blog.csdn.net/weixin_34910922/article/details/130665478
Recommended