1.显示当前工作目录--pwd
pwd命令:printing working directory
选项:
-P 显示真实物理路径
-L 显示链接路径(默认)例:
[root@centos8 ~]#pwd
/root
[root@centos8 ~]#cd /data
[root@centos8 data]#pwd
/data
[root@centos8 sysconfig]#cd /bin
[root@centos8 bin]#pwd
/bin
[root@centos8 bin]#pwd -P
/usr/bin2.更改目录--cd
cd命令 : change directory 改变目录
选项:
-P 切换至物理路径,而非软链接目录可以使用绝对或相对路径:
切换至父目录: cd ..
切换至当前用户主目录: cd
切换至以前的工作目录: cd -例:
[root@centos8 ~]#cd /etc/sysconfig
[root@centos8 sysconfig]#pwd
/etc/sysconfig
[root@centos8 sysconfig]#cd ../../data
[root@centos8 data]#pwd
/data
[root@centos8 data]#cd /bin
[root@centos8 bin]#pwd
/bin
[root@centos8 bin]#cd -P /bin 
[root@centos8 bin]#pwd
/usr/bin3.列出目录内容--ls
ls 命令可以列出当前目录的内容或指定目录
用法:
ls [options] [files_or_dirs]常见选项(包含不限于以下选项):
-a  包含隐藏文件
-l  显示额外的信息
-R  目录递归
-ld 目录和符号链接信息
-1  文件分行显示
-S  按从大到小排序
-t  按mtime排序
-u  配合-t选项,显示并按atime从新到旧排序
-U  按目录存放顺序显示
-X  按文件后缀排序
-F  对不同类型文件显示时附加不同的符号:*/=>@|
-C  文件多时,以多列的方式显示文件,默认是一列(标准输出)注:
ls 查看不同后缀文件时的颜色由 /etc/DIR_COLORS 和@LS_COLORS变量定义
ls -l 看到文件的大小,不一定是实际文件真正占用空间的大小例:
[root@centos8 ~]# ls
anaconda-ks.cfg  Downloads             Music     Templates
Desktop          elsfk.sh              Pictures  Videos
Documents        initial-setup-ks.cfg  Public
[root@centos8 ~]# ls -a
.                .bashrc  Documents             .lesshst  Public
..               .cache   Downloads             .local    .tcshrc
anaconda-ks.cfg  .config  elsfk.sh              .mozilla  Templates
.bash_history    .cshrc   .esd_auth             Music     Videos
.bash_logout     .dbus    .ICEauthority         Pictures  .viminfo
.bash_profile    Desktop  initial-setup-ks.cfg  .pki      .Xauthority
[root@centos8 ~]# ls -l
total 28
-rw-------. 1 root root  1601 Nov 15 09:58 anaconda-ks.cfg
drwxr-xr-x. 2 root root     6 Nov 15 10:05 Desktop
drwxr-xr-x. 2 root root     6 Nov 15 10:05 Documents
drwxr-xr-x. 2 root root     6 Nov 15 10:05 Downloads
-rw-r--r--. 1 root root 18771 Sep  1  2021 elsfk.sh
-rw-r--r--. 1 root root  1711 Nov 15 10:05 initial-setup-ks.cfg
drwxr-xr-x. 2 root root     6 Nov 15 10:05 Music
drwxr-xr-x. 2 root root     6 Nov 15 10:05 Pictures
drwxr-xr-x. 2 root root     6 Nov 15 10:05 Public
drwxr-xr-x. 2 root root     6 Nov 15 10:05 Templates
drwxr-xr-x. 2 root root     6 Nov 15 10:05 Videos4.查看文件状态--stat
用法:
stat [files_or_dirs]每个文件有三个时间戳:
access time 访问时间,atime,读取文件内容
modify time 修改时间,mtime,改变文件内容(数据)
change time 改变时间,ctime,元数据发生改变例:
[root@centos8 ~]#stat /etc/passwd
 File: /etc/passwd
 Size: 1306     Blocks: 8         IO Block: 4096   regular file
Device: 802h/2050d Inode: 134792556   Links: 1
Access: (0644/-rw-r--r--) Uid: (    0/   root)   Gid: (    0/   root)
Access: 2019-12-09 20:37:12.830991350 +0800
Modify: 2019-12-09 20:37:12.826991351 +0800
Change: 2019-12-09 20:37:12.826991351 +0800
 Birth: -5.确定文件内容--file
文件可以包含多种类型的数据,使用file命令检查文件的类型,然后确定适当的打开命令或应用程序使
用
用法:
file [options] <filename>...选项:
-b 列出文件辨识结果时,不显示文件名称
-f filelist 列出文件filelist中文件名的文件类型
-F 使用指定分隔符号替换输出文件名后默认的”:”分隔符
-L 查看对应软链接对应文件的文件类型
--help 显示命令在线帮助例:
[root@centos8 data]#file win.txt linux.txt
win.txt:   ASCII text, with CRLF line terminators
linux.txt: ASCII text
[root@centos8 ~]#file -f list.txt
/etc/:     directory
/bin:       symbolic link to usr/bin
/etc/issue: ASCII text









