File directory
/represents the root directory the entire system is all in the root directory
/boot Store Boot configuration file recommendations, separate into a partition
/dev Device file directory such as: CD, HDD
/etc store all the configuration files
Home directory file for a normal user
Home directory where/root management is located
/run Store dynamic files (non-persistent application data), shut down to empty files
/TMP holds temporary files and may not be there after one weeks
/var store dynamic Data files such as:/var/log/messages log file
/usr storage of installed software programs and library files
/usr/bin commands to store ordinary users
/usr/sbin to store administrator commands
/usr/local Storage of custom software
which mkdir
/usr/bin/mkdir
Which Usesradd
/usr/sbin/mkdir
/proc Store kernel parameters and hardware parameters such as: CPU, memory-related information
Cat/proc/cupinfo Viewing CPU information
Cat/proc/meminfo Viewing CPU information
2.pwd View your directory
CD/switch to the root directory
How to view the directory path in which you are located
PWD View Directory
Whatis pwd
3.CD Switch Directory
CD Catalog
Relative path: The path is the starting point of the current path
. Represents the current directory
.. Represents the previous level of the directory
~ means to return to your home directory equivalent to the input CD
Absolute path: Always take root as the starting point of the path
For example: Cd/home/student takes root as the starting point, which is an absolute path
Cd.. /home/student relative path
Cd./student Enter the/student directory under the current directory "./" can be omitted, enter directly into the student
LS Lists all the contents of the current directory
-l display in long format
-a displays all files including hidden files and. And.. Including. /. ./.bash Hidden files
-a show all files including hidden files
-D Displays all catalog files, used in conjunction with-l
LS-LD displays the long file format of the current directory
-h Displays information in K/m/g General and-L combined use
-R Recursive display
Touch creates an empty file (the timestamp of the file can be refreshed)
Touch file1 Create a file1 file
echo 123 echo Hello World > File1
Cat file1 viewing content in File1
Ls-l File1 can see time stamp modification
Touch file1 timestamp will be modified, the contents of the file will not be modified
Touch file1 file2 file3 Create multiple files
Touch file{5..9}
- mkdir Creating an empty directory
-P Create a multilevel directory if you do not have a directory before you can create
Mkdir Dir1 Dir2 Dir3
Mkdir dir{5..9}
Mkdir-p a/b/c Create a C directory, and if you do not have B, first create B,
Ls-r a ls recursive view
- MV move file, directory/rename (same path move)
(When you move a file, the original file's permissions are retained by default)
Mv file1 dir1/
Mv.. /file2. /dir2
Mv File5 File5.old
Mv File9 Dir9/file99
MV a dir1/
- CP Replication
-I overwrite replication with prompt information
-F forced Override
-R Recursive replication
-P Retain original property
CP can also be renamed, duplicated under the same target, can be renamed
Files and multilevel directories exist in Dir1
Cp Dir1 dir2/cannot be copied
Cp-r Dir1 dir2/Recursive replication
The Cp command adds the-I option by default in the system, so it automatically alerts you if the original file is overwritten
Alias view command aliases in the system
CP-RFP Dir1 dir2/
- Rm/rmdir Delete directory, file RM must be used with caution
Rmdir Delete Empty Directory
Rm Delete a file or directory
-I overwrite replication with prompt information
-F forced Override
-R Recursive replication
Rm dir1
Rm file4
Rm-f File6 does not need to ask whether to delete
Rm-f-R dir1 Force recursive removal of files and directories
Rm-r Dir2 Tip whether to delete
Rm-rf/root/dir2
- File wildcard: path name extension
Mkdir Dira
Dir1,dir2,dir3,dir4,dir5,file7,file8
You need to display the folders that dir1,dir2,dir3 these numbers
Special Character Categories:
Metacharacters (introduced later)
redirect > >>
Pipe symbol |
Wildcard characters
Match 0 or more characters
? Match any one character
[List] matches any one of the characters in the list
[!list] matches any character except List
{String1,string2,string3,...} Match character creation
[[:d Igit:]] outside means match a character, which means match a number
[[: Lower:]] means matching lowercase letters
[[: Upper:]] means matching uppercase letters
[[: Alum:]] Indicates a matching number or underscore
[[: Space:]] indicates matching spaces
[[:p UNCT:]] means "."
Ls-ld dir matches the Dir folder
Mkdir Diraa
Ls-ld dir? A folder that matches one character after Dir
Ls-ld dir[0-9] 0-9 matches one of the characters
Mkdir dir{b. F} Create a b-f folder
Ls-ld Dir[a-z] A A-Z character matches
Ls-ld dir[! A-z] in addition to a A-Z character match
Touch FILE{AA,BB,CC,DD,EE,FF}
Ll file {AA,BB,CC,FF}
Ls-ld dir[[:d igit:]] Display digital LS-LD dir[0-9]
Touch File{a. E
Ls-ld Dir[a-z]
Ls-ld Dir[a-z]
(3) Escape character:
' Hard escape '
"" Soft escape
\ Escape
Touch xx yy
Touch "xx yy"
Touch ' xx yy '
A=1 Defining variables
echo a output a
Echo $a output variable a
Echo "$a" 1 "" If a special symbol appears, output as a special character
Echo ' $a ' $a ' if a special symbol appears, as normal character output
Echo "\ $a" $a as normal character output
Echo ' \ $a ' \ $a
Linux 124 Lesson 2, managing files from the command line