Everything in the Linux system is a file. /become the root directory in Linux, is the root directory of all files. (Touch, mkdir, CP, MV, MV, less, more, head, tail, rmdir)
1. Linux
system directory structure, relative/absolute path.
2. Create/view/copy/delete files and folders
1.1 Linux System directory structure
use LS/view directory structure
//home/root/dev/usr/etc/boot/lib/var/tmp/proc/bin/sbin
/ commonly referred to as the root partition. The starting point for all files and directories. Only the root user has write access to this directory.
/ etc The configuration file contains the configuration files for all applications, and also contains scripts to start and close a particular program.
For example: /etc/passwd ,/etc/init.d/network and so on.
/ Boot store files that need to be loaded when the Linux system starts. Kernel, grub and other files are stored here.
/ var is an extensible directory that contains very often variable files.
For example,/var/log (System log),/var/lib (Pack documentation pieces)
/root Admin all data. Root user's home directory
/ tmp Temporary file storage location cannot hold important data
/ usr usr represents the UNIX software source/usr/src source code directory
/bin command This directory contains a binary executable file.
/sbin system commands, commands in this directory are primarily intended for use by system administrators for system maintenance.
/ Dev contains device files.
in Linux, everything is considered a file. Terminal devices, disks, and so on are all considered files. such as/DEV/SDA.
/Home Normal user all data is stored in this directory
/proc This directory is a virtual directory, it is the mapping of system memory, we can access this directory directly to obtain system information.
For example: View our memory information, CPU information
Cat/proc/meminfo | grep Mem
Cat/proc/cpuinfo
/lib repository file for system storage
lib***.a is a static library
Lib***.so is a dynamic library.
Static libraries are loaded into binary files at compile time
Dynamic libraries are loaded into the process's memory space at run time
Simply put, these libraries are meant to allow your program to compile and run properly.
It acts like a. dll file in Windows. These shared libraries are required for almost all applications.
Later on I will specialize in creating dynamic libraries and static libraries with programs.
Summary:
· In most cases, the local administrator installs additional software under the/usr/local directory and signs the main execution program that is connected under/usr/local/bin.
· All settings of the system are in/etc directory.
• Do not modify any content in the root directory ("/") or/usr directory,
· Catalogs are best aligned with Linux publishing.
• Most tools and applications are installed in the directory:/bin,/usr/sbin,/sbin,
• All files are under a single directory tree. There is no so-called "driver".
1.2 Absolute path and relative path
Path : In our usual use of the computer to find the required files must know the location of the file, and the way to indicate the location of the file is the path.
Absolute path:
In Linux, absolute paths start with "/", such as/usr,/etc/passwd. If a path is from/to start, it must be an absolute path.
PWD Judging Location
[email protected] ~]# pwd Note: Determine the current location of the user, that is, where is he located?
The user is currently located in/root;
[Email protected] ~]# cd/etc/sysconfig/network-scripts
[Email protected] network-scripts]# pwd
/etc/sysconfig/network-scripts
Note : We enter/directory in absolute path;
Relative path:
the relative path is started with. Or: In the path to put. and. Look at it as a catalog.
. indicates where the user's current operation is located
.. indicates a parent directory
Example experiment: Experiment 1
/root
Note : The directory is in the/root directory;
[[email protected]Xiaolyu ~]# CD.
Note : we enter.
[Email protected]Xiaolyu ~]# pwd
Note : Determines where the current user is located;
/root
Note : Obtained in the/root directory;
Example experiment: Experiment 2
Determine the current location is/root
[Email protected]Xiaolyu ~]# CD.
Note : We cut into/root's parent directory
[Email protected]Xiaolyu /]# pwd
Note : Determines where the current user is located.
/
Note : The user is currently located in/(root directory);
2. Create/view/copy/delete files and folders
2.1
creating files and folders
Touch
Function: Often used to create empty files
Syntax: Touch file name
[Email protected]xiaolyu ~]# Touch a.txt
Mkdir
Role: Create a directory
Syntax: mkdir directory Name
[Email protected]xiaolyu ~]# mkdir test
[Email protected]xiaolyu ~]# mkdir-p test/a/b/c
- P Create a link to the parent directory when it is created
2.2 Viewing FilesCat
Function: View the contents of a file
Syntax: Cat file name
Paging view: More, less, head, tail
More + file name
Cases:
more/etc/passwd
Press ENTER to refresh a row, press the space to refresh one screen
Q Exit
Less view file names
Q Exit
Use the cursor keys to page UP
Linux The difference between the more and less
More : backward is not supported, but there is little need to add parameters, the space bar is the page down, the ENTER key is down the line, in the case of no need to reverse the situation is more convenient.
Less : Support rollover, either up (pageup button) or PAGE Down (pagedown button). The SPACEBAR is a page down, and the ENTER key is flipped down one line. And less can look down n rows. Just enter the number of rows n in the place:.
Head
- N numbers show how many rows
[Email protected]xiaolyu ~]# head-3/etc/passwd
Root:x:0:0:root:/root:/bin/bash
Bin:x:1:1:bin:/bin:/sbin/nologin
Daemon:x:2:2:daemon:/sbin:/sbin/nologin
Tail
Starting from the last line, from the back, to view the file, the last 10 lines are displayed by default
- N How many rows are displayed
[Email protected]xiaolyu ~]# useradd nginx
[Email protected]xiaolyu ~]# tail-1/etc/passwd
Nginx:x:1002:1002::/home/nginx:/bin/bash
[Email protected]Xiaolyu ~]#
- F Dynamic display of data (not closed) is often used to view logs
Cp
Role: Copying files
Syntax: CP source file Destination file
- R contains subdirectories and files.
[Email protected]xiaolyu ~]# cp-r/boot/grub2//root/
Rename:
Mv
Syntax: MV Source: File or directory name destination: file or directory name
[Email protected]Xiaolyu ~]# mv Rm.txt mk.txt
2.3 Deleting files and folders
Rm
Action: Delete a file or directory
Syntax: RM-RF file or directory name
- R recursive deletion (you can delete things in directories and directories)
- F forcibly Delete
RmDir
Role: Delete the empty folder. (This command has little meaning).
Syntax: rmdir the empty folder name.
[Email protected] ~]# RM x
Rm:cannot remove ' x ': is a directory
[Email protected] ~]# rmdir x
rmdir:failed to remove ' x ': Directory not empty
[Email protected] ~]# RM lvjj.txt
Rm:remove regular file ' Lvjj.txt '? N
[[Email protected] ~]# CD x
[[email protected] x]# ls
Test.txt
[Email protected] x]# CD.
[Email protected] ~]# RM-FR x
[[email protected] ~]# ls
Anaconda-ks.cfg Downloads mimz~ Redhat.txt
A.out Err.log MKD Templates
Lvjj.txt Hello Music test.txt
[Email protected] ~]#
Linux topic one file management (directory structure, create, view, delete, move)