A new chapter in life, Linux The second study

1, Linux release naming system directory name and purpose

A system directory name naming rules:
A. System directory is also a directory, so first of all it has to conform to the naming rules of general directories, but also because the directory file (Linux philosophy: everything is a file), so it is to comply with the file naming rules:

  1. In the same path, two files with the same name can not
  2. File names up to 255 bytes
  3. Including the file name including the path up to 4095 bytes
  4. In addition to the slash "/" and NUL, all the characters are valid. (However, the use of special characters in directory names and file is not recommended, some characters need to refer to them in quotation marks)
  5. Letters case sensitive (this is the type of file system, such as the standard Linux file system, ext4, but if you use the FAT32 type, then it is not case-sensitive letters)
    B. If the system directory, but also in line with the official Linux standard library: LSB linux Standard Base. The file system hierarchy: FHS: (Filesystem Hierarchy Standard)
    two root directory, directory system uses brief:
    Contents Description
    bin binary basic commands
    boot boot boot loader static file
    dev device files
    etc host-specific system configuration
    lib basic shared libraries and kernel modules
    media removable media mount points
    mnt mount point to temporarily mount a file system
    package opt additional application
    process run processes running in the data
    base system binaries sbin
    SRV service system to provide the data
    tmp temporary files
    usr two hierarchical
    var variable data
    home user's home directory (optional)
    lib <Qual> substantially shared libraries another format (optional)
    the root directory of the root user's home (optional)

2, the metadata description file which, respectively, what is the meaning, what to see? How to modify the timestamp information file?
View file metadata

[root @ centos7 the Data] # STAT wang.txt
File: 'wang.txt' File Name
Size: 0 Size Blocks: 0 Number of disk blocks occupied by the IO Block: 4096 disk block size regular empty file file types
Device: 803h / 2051d is located equipment Inode: 67 file node number Links: 1 number of hard links
access: (0644 / -rw-r - r--) access Uid: (0 / root) Gid which the user belongs: (0 / root) belong to which group
access: 2020-03-01 20: 55: 49.464027136 +0800 files were last accessed time
modify: 2020-03-01 20: 55: 49.464027136 +0800 file modification time of
Change: 2020-03-01 20: 55: 49.464027136 +0800 file to change the time of
Birth: -

Change file timestamps method
basic format touch command is as follows: touch [options] filename

Options:
-a: only modify the file's access time;
-c: modify only the time parameter file (three time parameters are changed), if the file does not exist, no new files created.
-d: can be revised later date with desire, instead of the current date, that is atime and mtime time the file was changed to the specified time.
-m: Modify only the data file modification time.
-t: command may be followed by time to be revised, rather than the current time, the time of writing format YYMMDDhhmm.

举例:
[root@centos7 data]# touch -c wang.txt
[root@centos7 data]# stat wang.txt
File: ‘wang.txt’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 803h/2051d Inode: 67 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2020-03-01 21:07:55.100052676 +0800
Modify: 2020-03-01 21:07:55.100052676 +0800
Change: 2020-03-01 21:07:55.100052676 +0800
Birth: -
[root@centos7 data]#

3 summarizes the difference between hard-wired connections and soft, with examples and instructions.
Hard links Soft links to
the same file multiple names essentially different file, soft links only point to the appropriate file, similar to the windows shortcuts
can cross disk partitions can not
can not can link directories
relationship equal to each other, relatively independent of the main min followed by
file type with the same source file linked file
number of links is increased without increasing the number of links is the link number of links link

硬链接实例:
[root@centos7 data]# ll -i
total 8
68 drwxr-xr-x 2 root root 6 Feb 29 16:05 d1
69 -rw-r--r-- 2 root root 0 Feb 29 16:07 f1
69 -rw-r--r-- 2 root root 0 Feb 29 16:07 f1.link
71 -rw-r--r-- 1 root root 2285 Feb 29 16:31 passed.old
72 -rw-r--r-- 1 root root 2304 Feb 29 18:33 passwd
67 -rw-r--r-- 1 root root 0 Mar 1 21:07 wang.txt
[root@centos7 data]# ln wang.txt wang1.txt
[root@centos7 data]# ll -i
total 8
68 drwxr-xr-x 2 root root 6 Feb 29 16:05 d1
69 -rw-r--r-- 2 root root 0 Feb 29 16:07 f1
69 -rw-r--r-- 2 root root 0 Feb 29 16:07 f1.link
71 -rw-r--r-- 1 root root 2285 Feb 29 16:31 passed.old
72 -rw-r--r-- 1 root root 2304 Feb 29 18:33 passwd
67 -rw-r--r-- 2 root root 0 Mar 1 21:07 wang1.txt
67 -rw-r--r-- 2 root root 0 Mar 1 21:07 wang.txt
[root@centos7 data]# rm wang1.txt
rm: remove regular empty file ‘wang1.txt’? y
[root@centos7 data]# ll i
ls: cannot access i: No such file or directory
[root@centos7 data]# ll -i
total 8
68 drwxr-xr-x 2 root root 6 Feb 29 16:05 d1
69 -rw-r--r-- 2 root root 0 Feb 29 16:07 f1
69 -rw-r--r-- 2 root root 0 Feb 29 16:07 f1.link
71 -rw-r--r-- 1 root root 2285 Feb 29 16:31 passed.old
72 -rw-r--r-- 1 root root 2304 Feb 29 18:33 passwd
67 -rw-r--r-- 1 root root 0 Mar 1 21:07 wang.txt
[root@centos7 data]#

软链接实例:
[root@centos7 data]# ll -i
total 0
67 -rw-r--r-- 1 root root 0 Mar 1 21:07 wang.txt
[root@centos7 data]# ln -s wang.txt wang.txt.link
[root@centos7 data]# ll -i
total 0
67 -rw-r--r-- 1 root root 0 Mar 1 21:07 wang.txt
68 lrwxrwxrwx 1 root root 8 Mar 1 21:21 wang.txt.link -> wang.txt
[root@centos7 data]# rm wang.txt
rm: remove regular empty file ‘wang.txt’? y
[root@centos7 data]# ll -i
total 0
68 lrwxrwxrwx 1 root root 8 Mar 1 21:21 wang.txt.link -> wang.txt
[root@centos7 data]# touch wang.txt
[root@centos7 data]# ll -i
total 0
67 -rw-r--r-- 1 root root 0 Mar 1 21:22 wang.txt
68 lrwxrwxrwx 1 root root 8 Mar 1 21:21 wang.txt.link -> wang.txt
[root@centos7 data]#

4, file management class command on Linux what are its common usage and its associated example demonstrates.
pwd displays the absolute path of the current shell CWD
Syntax:
pwd (option)
Options:
-P show the real physical path
-L display link path (default)
example:
[root @ centos7 ~] # pwd
/ root
[root @ centos7 ~] # cd / Data
[@ centos7 the root Data] # pwd
/ Data
[@ centos7 the root Data] #
CD change directory
syntax:
CD (option) (parameter)
options:
-p to switch to the target directory is a symbolic link, directly to the switch symbolic link points to the target directory
-L if you want to switch the destination directory is a symbolic link, switch directly connected to the characters in directory names on behalf of, rather than the symbolic link points to the target directory.
When the only practical "-" is an option, the current working directory will be switched to the directory environment variable "OLDPWD" it represents.
cd into the user's home directory;
cd ~ into the home directory;
cd - returns the directory where prior to entering the directory;
cd .. return to parent directory (if the current directory is "/", is also performed after the "/"; " .. "for the parent directory of the meaning);
cd ../ .. return to the two directories;
cd $ parameters on the command cd is used as a parameter!.
Example:
[root@centos7 ~]# cd /data
[root@centos7 data]# pwd
/data
[root@centos7 data]# cd /home
[root@centos7 home]# cd ~
[root@centos7 ~]# cd -
/home
[root@centos7 home]# cd ..
[root@centos7 /]# cd ../..
[root@centos7 /]# cd !$
cd ../..
[root@centos7 /]#

ls lists the contents of the current directory or specified directory
Syntax:
ls (Option) (parameters)
ls -a contain hidden files
ls -l to display additional information
ls -R recursive directory
ls -ld directory and symbolic link information
ls -1 file Branch display
ls -S Sort by descending
ls -t Sort by mtime
ls -u with the -t option to display and press atime new to old Sort
ls -U directory stored in the order shown by
ls -X sort by file extension
example:
[ @ centos7 the root /] # LS
bin dev etc Data Boot Media Home the lib64 lib mnt opt proc SRV the root RUN SYS sbin tmp usr var
[@ centos7 the root /] LS # -a
. .. .autorelabel bin dev etc Home Data Boot lib the lib64 the root RUN mnt opt proc Media SRV SYS sbin tmp usr var
[@ centos7 the root /] -L LS #
bin dev etc Data Boot Media Home the lib64 lib mnt opt proc SRV the root RUN SYS sbin tmp usr var
[@ centos7 the root /] LS # the -l
Total 24-
lrwxrwxrwx. 1 root root 7 Feb 22 20:58 bin -> usr/bin
dr-xr-xr-x. 5 root root 4096 Feb 24 21:41 boot
drwxr-xr-x. 2 root root 43 Mar 1 21:22 data
drwxr-xr-x 19 root root 3320 Mar 8 15:30 dev
drwxr-xr-x. 140 root root 8192 Mar 8 15:30 etc
drwxr-xr-x. 3 root root 19 Feb 22 21:12 home
lrwxrwxrwx. 1 root root 7 Feb 22 20:58 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 Feb 22 20:58 lib64 -> usr/lib64
drwxr-xr-x. 2 root root 6 Apr 11 2018 media
drwxr-xr-x. 3 root root 18 Feb 24 21:38 mnt
drwxr-xr-x. 3 root root 16 Feb 22 21:05 opt
dr-xr-xr-x 196 root root 0 Mar 8 15:30 proc
dr-xr-x---. 16 root root 4096 Mar 8 15:30 root
drwxr-xr-x 40 root root 1260 Mar 8 15:30 run
lrwxrwxrwx. 1 root root 8 Feb 22 20:58 sbin -> usr/sbin
drwxr-xr-x. 2 root root 6 Apr 11 2018 srv
dr-xr-xr-x 13 root root 0 Mar 8 15:30 sys
drwxrwxrwt. 24 root root 4096 Mar 8 15:31 tmp
drwxr-xr-x. 13 root root 155 Feb 22 20:58 usr
drwxr-xr-x. 20 root root 282 Feb 22 21:22 var
[root@centos7 data]# ls -R
.:
wangtest wang.txt wang.txt.link

./wangtest:
1 2

./wangtest/1:

./wangtest/2:
[@ centos7 the root Data] LS # -ld
... 3 drwxr the root-XR X-59-Mar the root. 8 15:36
[@ centos7 the root Data] -1 LS #
wangtest
wang.txt
wang.txt. Link
[@ centos7 the root Data] LS # -S
wangtest wang.txt.link wang.txt
[@ centos7 the root Data] LS # -t
wangtest wang.txt wang.txt.link
[@ centos7 the root Data] # LS -ut
wangtest wang.txt wang.txt.link
[@ centos7 the root Data] LS # -U
wang.txt.link wang.txt wangtest
[@ centos7 the root Data] the -X-LS #
wangtest wang.txt.link wang.txt
[the root @ centos7 data] # stat files for displaying status information.
Syntax:
STAT (Options) (parameters)
Option:
-L: support symbolic links;
-f: display file system status instead of file status;
-t: output information in a concise manner;
--help: display help information instruction;
--version:显示指令的版本信息。
实例:
[root@centos7 data]# stat wang.txt
File: ‘wang.txt’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 803h/2051d Inode: 67 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2020-03-01 21:22:31.105083509 +0800
Modify: 2020-03-01 21:22:31.105083509 +0800
Change: 2020-03-01 21:22:31.105083509 +0800
Birth: -
[root@centos7 data]# stat -f wang.txt
File: "wang.txt"
ID: 80300000000 Namelen: 255 Type: xfs
Block size: 4096 Fundamental block size: 4096
Blocks: Total: 13100800 Free: 13092536 Available: 13092536
Inodes: Total: 26214400 Free: 26214392
[root@centos7 data]# stat -t wang.txt
0 0 0 0 81a4 wang.txt 803 67 0 1 0 0 1,583,068,951 1,583,068,951 1,583,068,951 4096
[root @ centos7 the Data] #
Touch create an empty file and refresh
syntax:
Touch [OPTION] ... FILE ...
Options:
-a only change atime and ctime
-m change only the mtime and ctime
-t [[CC] YY] MMDDhhmm [.SS] timestamp specifies atime and mtime of
-c If the file does not exist, not create
instance:
[root @ centos7 the Data] Touch -t 03,081,544 wang.txt #
[@ centos7 the root Data] # STAT wang.txt
File: 'wang.txt'
Size: 0 Blocks: the IO Block 0: 4096 Regular empty File
Device: 803H / 2051d Inode: 67 Links:. 1
Access: (0644 / R & lt -rw-- r--) Uid: (0 / the root) Gid: (0 / the root)
Access: 2020-03-08 15: 44 is: 00.000000000 +0800
the Modify: 2020-03-08 15:44: 00.000000000 +0800
Change: 2020-03-08 15: 49: 20.931053407 +0800
Birth: -
[root @ centos7 the Data] #
cp copy files and directories
Syntax:
cp [OPTION] ... [-T] the SOURCE DEST
cp [OPTION] .. . the SOURCE ... DIRECTORY
CP [the oPTION] ... ... -t DIRECTORY the SOURCE
CP the SRC DEST
options:
-a: effect of this parameter and specify "-dpR" same parameters;
-d: when copying symbolic links , the target file or directory is also established as a symbolic link, and link to the original file or directory connected to a source file or directory;
-f: force to copy a file or directory, regardless of whether the target file or directory already exists;
-i: covering both before asking the user first file;
-l: hard links to the source file, rather than copy the file;
-p: reserved source file or directory attribute;
/ R & lt -R & lt: recursive processing of all files and subdirectories the directory specified in the be dealt with;
-s: Creates a symbolic link to the source file, rather than copying files;
-u: only updated over time to change the target file in the source file after using this parameter or the name of the target file does not correspond to each other when there is only copy files;
-S: when you back up files with Specifies the suffix "SUFFIX" instead of the default file extension;
-b: before the target file will overwrite the existing file backup target;
-v: Operation command shown in detail.
Example:
[@ centos7 the root wangtest] # LS
. 3
[@ centos7 the root wangtest] # CD ..
[@ centos7 the root Data] the -if CP # [1-3] wangtest
CP:? Overwrite 'wangtest /. 3' Y
Music Videos move and rename file
syntax:
mv [oPTION] ... [-T] the SOURCE DEST
mv [oPTION] ... the SOURCE ... DIRECTORY
mv [oPTION] ... -t DIRECTORY the SOURCE ...
options:
-i interactive
-f forced
-b target exists, front cover to back
example:
[@ centos7 the root Data] LS # -a
.. 2. 3 10. 4. 9 T1 T2 wangtest wang.txt wang.txt.link.
[@ centos7 the root Data] # LS - L
Total 0
-rw-R & lt - r-- the root the root. 1 0 10-Mar. 8 16:10
-rw-R & lt - r--. 1 the root the root-Mar. 8 15:41 2 0
-rw-R & lt - r-- the root-Mar. 8 the root 0. 1 16:03. 3
-rw-R & lt - r-- the root. 1 15:41. 4. 8 the root-Mar 0
-R & lt -rw - r-- the root the root. 1 0-Mar. 8. 9 16:10
drwxr the root-XR-2 X-Mar the root. 6. 8 16:10 T1
drwxr XR-2 X-24-Mar the root the root. 8 16:09 T2
drwxr the root the root-X. 3 -XR 45-Mar. 8 16:06 wangtest
-rw-R & lt - r-- the root. 1 0-Mar. 8 15:44 wang.txt the root
lrwxrwxrwx the root the root. 8. 1. 1-Mar 21:21 wang.txt.link -> wang.txt
[@ centos7 the root Data] # Music Videos / Data / T1 / / Data / T2
[@ centos7 the root Data] LS # T2
. 7. 8 T1
[@ centos7 the root Data] #
RM remove
syntax:
RM [the OPTION]. .. FILE ...
options:
-i interactive
-f Force delete
-r recursive
--no-preserve-root delete /
example:
[root @ centos7 T2] -r # T1 RM
RM: the Remove Directory 'T1' the y-?
[centos7 the root @ T2] # CD ..
[@ centos7 the root Data] LS # T2
. 7. 8
[root@centos7 data]# rm -rf t2
[root@centos7 data]# ls
10 2 3 4 9 wangtest wang.txt wang.txt.link
[root@centos7 data]#

5, copy / etc / profile to the / tmp / directory, delete whitespace characters of the / tmp / profile file with the Find and Replace command
cp / etc / profile / tmp copy / etc / profile to the / tmp / directory
vim / tmp / profile / file opened with vim Profile
A new chapter in life, Linux The second study
extended command mode input
:% s / ^ \ s * // g
A new chapter in life, Linux The second study
after completion:
A new chapter in life, Linux The second study
6, tab disposed indent to 4 characters in vim
open .vimrc vim user's home directory, such as then be diverted to modify global variables / etc / vimrc file:
Vim ~ / .vimrc

Add the following fields:
the SET the TabStop = 4
then: wq save and exit, press the tab key again vim editor has indented 4 characters

A new chapter in life, Linux The second study

Guess you like

Origin blog.51cto.com/14697765/2476387