1 , described linux release system directory naming convention and use
/ Root directory, the starting point of all directories
/root root user's home directory
/etc The directory for storing configuration files, including the configuration of various services of the linux system, etc.
/dev The directory where the hardware files of the linux system are stored, that is, where the hardware files and special files are stored
/usr is the directory where system application programs are stored. Almost all programs that need to be used are stored in this directory, which is also the actual storage directory of directories such as /bin
/tmp Temporary file storage directory
/bin Soft link directory, the directory where all basic commands used by users are stored. Cannot be associated to a separate partition, the program will be used when os is started
/home The default home directory of ordinary users
/proc process file directory
/lib soft link directory, the storage directory of basic shared library files and kernel module files that the program depends on at startup
/var Cache, log and other file storage directory
/run System operation is required file
/boot The directory where the boot file is stored, the directory where the boot file is stored, the kernel file, and the boot loader are all stored in this directory
/sys Virtual file system storage directory for hardware device related information on the current system
/sbin soft link directory, basic management commands, can not be associated with independent partitions, os startup will use the program
/opt Installation location of third-party applications
/media portable mobile device mount point
/srv Data used by the system to run services
/mnt Temporary file system mount point
/lib64 soft link directory, dedicated to the storage location of auxiliary shared library files of x86_64 system
All directories start from the root directory and expand in a tree structure. The naming is case-sensitive . The files beginning with . Are hidden files and are separated by /. Special characters can be used for naming, but it is not recommended. Different colors correspond to different files, blue for directories, red for compressed files, green for executable files, light blue for linked files, and gray for other files.
2. What are the metadata information of the file, how to view it, and how to modify the timestamp
File file name
Size File size
Blocks of data used by the file
Io block data block size
File type such as regular file or directory
Device device number
The inode of the Inode file
Links Hard link times
Access permissions
Uid user id
Gid group id
Access time File access time The content of the file will be changed when the file is read.
Modify time File modification time, the content of the modified file will change
Change time file status time, the metadata will change when it changes
View method: stat file name
[root@localhost ~]# stat /etc/selinux/config
File: ‘/etc/selinux/config’
Size: 542 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 33562144 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2021-03-19 09:29:16.693567023 +0800
Modify: 2021-03-12 10:38:52.674977383 +0800
Change: 2021-03-12 10:38:52.675977383 +0800
Birth: -
怎么修改时间戳
Access time 文件访问时间 读取文件内容即会改变
Modify time 文件修改时间 ,修改文件内容即会改变
Change time 文件状态时间 ,元数据发生改变即会改变
3.软件接和硬链接
软连接是创造一个指向源文件的链接文件,就像快捷方式一样,删除软连接目录不会影响原文件目录
[root@localhost ~]# ln -s /etc/passwd /root/passwdsl
[root@localhost ~]# stat /root/passwdsl
File: ‘/root/passwdsl’ -> ‘/etc/passwd’
Size: 11 Blocks: 0 IO Block: 4096 symbolic link
Device: fd00h/64768d Inode: 100739780 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2021-03-19 10:42:58.357032529 +0800
Modify: 2021-03-19 10:42:50.052785699 +0800
Change: 2021-03-19 10:42:50.052785699 +0800
Birth: -
硬链接是为一个文件建立一个马甲,与源文件为同一文件,建立硬链接会使改文件的link数增加,软连接不会,link数为0时,该文件被删除。
[root@localhost ~]# ln /etc/passwd /root/passwdhl
[root@localhost ~]# stat /root/passwdhl
File: ‘/root/passwdhl’
Size: 889 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 67169144 Links: 2
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2021-03-19 09:52:42.322535553 +0800
Modify: 2021-03-19 09:52:42.319535553 +0800
Change: 2021-03-19 10:44:33.168850593 +0800
Birth: -
硬链接和软连接区别
1. 硬链接和源文件是同一文件的不同链接,软连接和源文件是不同文件
2. 硬链接支持跨设备,软连接不支持
3. 硬链接inode与源文件相同,软链接不同
4. 硬链接会使源文件的link增加,软连接不会
5. 硬链接不支持目录,软连接可以
6.源文件相对路径是相对于当前目录,软件接是连接文件的相对路径
7. 删除源文件对硬链接无影响,软连接则无法访问
4.文件管理类命令
1.Ls 显示目录下有哪些文件
使用方法 ls 选项 目录
[root@localhost ~]# ls /
bin dev home lib64 mnt proc run srv tmp var
boot etc lib media opt root sbin sys usr
[root@localhost ~]# ls -a /
. .autorelabel boot etc lib media opt root sbin sys usr
.. bin dev home lib64 mnt proc run srv tmp var
2.cd 切换当前目录
cd 目录名
[root@localhost ~]# cd /
[root@localhost /]# cd /root
[root@localhost ~]#
3.Pwd 显示当前目录
[root@localhost ~]# pwd
/root
4.Cp 复制文件
Cp 源文件 目标文件
Cp -r 源目录 目标目录
[root@localhost ~]# cp -r /root/mulu /root/mulu2
5.Rm 删除文件
Rm 文件
Rm -r 目录
[root@localhost ~]# rm -r mulu2/
rm: remove directory ‘mulu2/’? yes
[root@localhost ~]#
6.Mkdir 创建目录
Mkdir 目录
[root@localhost ~]# mkdir /root/mulu
7.Touch 创建文件
Touch 文件
[root@localhost ~]# touch mulu/test
8.Cat 查看文件
Cat 文件
[root@localhost ~]# cat mulu/test
this is a test
9.Vim 修改文件
Vim 文件
[root@localhost ~]# vim mulu/test
[root@localhost ~]# cat mulu/test
this is a test2
10.MV 移动文件或目录
Mv 源目录或文件 目标目录或文件
[root@localhost ~]# mv mulu/test ./
5. 复制/etc/profile至/tmp目录下,使用查找替换命令删除/tmp/profile中的行首空白字符
Cp /etc/profile /tmp/
Vim /tmp/profile
输入:进入扩展命令模式
输入%s/ //g 删除所有行首空格。
:%s/ //g
6.设置vim中tab缩进为4个字符
Vim /etc/vimrc
添加 set tabstop=4
set tabstop=4
保存退出即可