1 Linux directory Structure
- /bin: (binaries) The directory where the system commands are stored, which can be performed by all users.
- /sbin: (super User binaries) Save the commands associated with the system environment settings, only the superuser can use these commands, and some commands can be viewed by ordinary users.
- /usr/bin: The directory where the system commands are stored, which can be performed by all users. These commands are not related to system startup and cannot be performed in single-user mode
- /usr/sbin: Storage of root filesystem unnecessary system administration commands, super User can execute
- /root: The home directory of the root user thatholds the files of the root user . Host directory Super user
- /home: User default host directory Eg:/home/spark
- /tmp:(temporary) storing temporary files
- /etc:(Etcetera) system configuration file
- /usr: (unix software Resource) system software shared resource directory, storing all commands, libraries, manual pages, etc.
- /proc: Virtual file system, data stored in memory, storing current process information
- /boot: System startup directory
- /dev:(Devices) storing device files
- /sys: Virtual file system, data stored in memory, mainly stored in memory-related information
- /lib: Storage of shared libraries required for System program operation
- /lost+found: Store some system error check results.
- /var:(variable) Dynamic Data save location with frequently changed files, such as mail, log files, scheduled tasks, etc.
- /MNT:(Mount) Mount directory. Temporary file system mount point, default mount for CD-ROM and floppy drive directories
- /media: Mount directory. Mount media devices, such as floppy disks and discs
- /misc: Mount directory. Mount NFS Service
- /OPT: Third-party installed software save location. Get used to the /usr/local/directory .
- /SRV: Service Data Catalog
2 Common Linux commands
command format: commands [-options] [parameters]
such as: LS-LA/USR
Description
1. Most of the commands comply with this format;
2. When multiple options are available, you can write together. Eg:ls–l–a→ls–la
Simplified and complete options (note: Not all options are available with full options) Eg:ls–all→ls–a
2.1 su Command
Role: Switch User identities
Syntax: su [options] User name
-Indicates that the user's environment variable is switched together
-C executes only one command at a time without switching user identities
eg
$ su–root
$ su–root–c "Useradd longjing"
2.2 File Processing commands2.1.1CD
English: Change Directory command path: Internal command execution permissions: all Users
Role: Switch Directories
Syntax: CD [catalog]
/switch to the root directory
.. Back to the top level directory
. Current directory
-Display and open the directory to the last action
~ Current user's host directory (eg:# CD ~ User name enters a user's home directory)
2.1.2 Ls
English: List command path:/bin/ls Execute permissions: All Users
Role: Display directory files
Syntax: LS [-ALRRD] [file or directory]
- A All displays all files, note hidden files, special directories. and.
-L (long) Show details
-R (Recursive) recursively displays all directories in the current directory
-R (reverse) reverse order
- T (time) Sort by modified (descending)
ll is equivalent to Ls–l
2.1.3 Pwd
English: Print working directory command path:/BIN/PWD Execute permissions: All Users
function: Displays the current working directory
Syntax: pwd [-LP]
- L Show link path, current path, default
- p Physical path
eg:# CD/ETC/INIT.D
# pwd [-p]
2.1.4 Mkdir
English: Make directories command path:/bin/mkdir Execute permissions: All Users
role: Create a new directory
syntax: mkdir [-p] Directory name
-P Parent directory is not present in the case of Mr. Cheng-parent directory (parents)
eg:mkdir linux/test If directory Linux does not exist, an error is made, and the parent directory is created automatically using the parameter-P.
2.1.5 Touch
command path:/bin/touch Execute permissions: All users
action: Creates an empty file or updates the time that a file already exists
Syntax: Touch file name
Eg: Create multiple files at the same time
Touch A.txt b.txt Touch {a.txt,b.txt}
Create a file with spaces
Touch "Program Files" (double quotes must also be in Query and delete)
Note : In the production environment, the file name must not be added space
2.1.6 Cp
English: Copy command path:/BIN/CP Execute permissions: All users
role: Copying Files or directories
syntax: CP [–RP] source file or directory destination directory
-r-r (recursive) recursive processing, copying directories
-P reserved file attributes (the time of the original file is unchanged)
eg:
1, relative path cp–r/etc/*. Cp–r. /aaa. /.. /test/
2, Absolute path cp–r /ect/service/root/test/aa/bb
2.1.7 Mv
English: Move command path:/BIN/MV Execute permissions: All users
action: Move a file or directory, file, or directory rename
Syntax: MV source file or directory destination directory
2.1.8 Rm
English: Remove command path:/BIN/RM Execute permissions: All Users
Role: Deleting files
Syntax: RM [-RF] File or directory
-R (Recursive) delete directory while deleting all files in this directory
-F (Force) forcibly delete files or directories even if the original file attributes are set to read-only and are deleted directly without having to confirm them individually
Note : Use the RM–RF command sparingly at work.
extension Point : delete garbled files
Some files garbled after use RM-RF still cannot delete,
At this point, use Ll-i to find the Inode node for the file,
Then use Find. -inum Find the Inode number-exec rm {}-RF \;
will be able to remove the smooth.
2.1.9 Cat
English: Concatenate command path:/bin/cat Execute permissions: All Users
Function: Display file contents
Syntax: Cat [-n] [file name]
-a displays all content, including hidden characters
-N Display Line number
Eg:cat/etc/services
2.1.10 More
Command path:/bin/more Execute permissions: All Users
Role: Paging Displays the contents of a file
Syntax: more [filename]
Space or F to display the next page
Enter key to display the next line
Q or Q exit
2.1.11 Head
Command path:/usr/bin/head Execute permissions: All Users
Function: View the first few lines of the file (default 10 lines)
Syntax: head [filename]
-n Specifies the number of rows
Eg:head-20/etc/services Head–n 3/etc/services
2.1.12 Tail
Command path:/usr/bin/tail Execute permissions: All Users
Function: View the following lines of a file
Syntax: tail [file name]
-n Specifies the number of rows
-F (Follow) dynamic display of file contents
Get a partial file of a large file that can be used with the head or tail command
Head-n 100/etc/services >config.log
2.1.13 ln
English: Link command path:/BIN/LN Execute permissions: All Users
Role: Generate Linked files
Grammar:
ln-s [Source file] [destination file] Create soft link source file using absolute path
ln [source file] [destination file] Create a hard link
eg
Create a soft link to the file/etc/service Service.soft
Ln-s/etc/service./service.soft
Create a hard link to the file/etc/service/service.hard
/etc/service/service.hard
A soft connection is similar to a shortcut under Windows.
Soft Connect file format:
lrwxrwxrwx. 1 root root 07:50 service->/etc/services
1 hard links, if the file does not have a hard link, it is only a hard link of itself
13 Length of linked files
Format parsing (feature):
Soft Link Features
1, soft Connection file type is L (soft connection), soft connection file permissions are lrwxrwxrwx
2, arrow pointing to source file
The true permissions depend on the permissions on the source file, The time value is the time when the soft connection was created, soft connections can be generated across file systems.
Hard-Link Features
1, equivalent to CP-P + synchronous update
2, through the I node identification, and the source file has the same inode node
3, hard link cannot cross partition, Ln/home/test/issuels/boot/test (Error)
4. Ln/tmp/aa.hard cannot be used for the directory (unable to generate a hard link to the directory/TMP)
To delete a soft connection
RM-RF Symbolic_name
Linux common commands (i)