Linux directory and file manipulation commands basis

A, classification and format of the Linux command
Linux commands can be divided into two categories, one internal command, and the other is an external command.
Internal Command : means integration with a number of special instructions inside Shell interpreter program, also known as built-instruction. Shell internal command is part of, and there is no corresponding separate file system, as long as the Shell interpreter program is executed, the internal command will automatically be loaded into memory, the user can be used directly. Internal commands do not need to read files from the hard disk, so a higher efficiency.

External commands: refers to a Linux system or binary script file to complete a particular function, each external command corresponds to a file system, is part of the command interpreter program outside of the Shell, so called external command. Linux file system must know the location of external commands corresponding to be able to be loaded by Shell and complete.

Linux command line format of
the command word: That command word command name, is the most critical part of the entire command.
Options: Options that are specific functional regulation command, decide how to execute this command.
Parameters: command parameters command word is processed, the contents of the command parameter file name, directory name or user name, etc. In general.
Among them, between the command word, options, parameters, separated by spaces, extra spaces are ignored. Wherein the command line options and parameters in some cases may be omitted, i.e., you can only command word command, only the command word may be, option, or command word only, parameters.

Second, the basic operation of the command directory and file of
1, view or basic file attributes

ls command: ls command is mainly used to display the contents of the directory, including subdirectories and files related attribute information and so on. The parameters used can be a directory name, or file name, allowing use of multiple parameters in the same command.
Common options for the ls command
-l: Displays a list of directories and files, including permissions, the size of the long format, the final details last time update.
-a: Displays information about all subdirectories and files, including names beginning with a dot hide hidden files and directories. "."
-A: and -a similar, but there are two -A special hidden directory does not show up, that means the current directory and indicate the parent directory. "". "."
-d: Display Properties directory itself without displaying the content.
-h: displays a more humane way of a directory or file size, the default size in bytes, using this option will display KB, MB and other units. This option needs to be used together in conjunction with the -l option.
-R: display the specified directory and all subdirectories contents recursively.

For example, the following display all the contents of the directory and its subdirectories bdqn recursively.
Linux directory and file manipulation commands basis

du command: du command can be used for statistical purposes to specify the size of disk space occupied. Using the name of the directory or file as a parameter.
du command commonly used options
-a: All files include disk space occupied statistics, not just statistics directory.
-h: displays a more humane way out statistics, default in KB, but does not display the unit, use -h will show K, M and other units.
-s: only count the total size of each parameter space, rather than the statistics for each subdirectory, the file size.
Combined with options
if required statistical space all the files within a folder total occupied, can be combined -sh option, will be the statistical directory as a parameter.
If you need to, respectively, the statistics among flowers occupied by the size of multiple files, can be combined with -ah option, the directory as a parameter, the final list will occupy a total size of the directory.

Statistics / bdqn directory of all files, subdirectories size of each space.
Linux directory and file manipulation commands basis

2, create directories and files
touch command
touch command could have been used to update the time stamp of the file, but in actual use often used to create a new test file, use the file name as an argument, you can create multiple files simultaneously.

Create two empty folders in yjs, the file names are aaa.html, ccc.txt.
Linux directory and file manipulation commands basis

mkdir command
mkdir command creates a new empty directory, use the directory where you want to create as a parameter. If used with the -p option in conjunction with, you can create nested multi-time directory.

Create a / bdqn, and create a subdirectory under kgc / bdqn directory, create a subdirectory yjs again in the following subdirectory / bdqn / kgc directory.
Linux directory and file manipulation commands basis

3, copy, delete, move files and directories
cp command
cp command to copy a file or directory, the need to copy files or directories rebuild and save a new file or directory.
Common options cp command
does not overwrite the destination with the same name alert you when a file or directory, and direct force replication: -f.
-i: to remind the user to determine when covering the same name as the target file or directory.
to maintain the source file permissions when copying, owner and time stamp and other attributes unchanged: -p.
-r: You must use this option to replicate the directory represents a recursively copy all the files and subdirectories.

Copy the directory / fan / ji / xiang to the directory / bdqn / kgc inside.
Linux directory and file manipulation commands basis

rm command
rm command to delete the specified file or directory in the Linux command line interface, it is difficult to recover deleted files, so using the rm command needs to be extra careful when deleting files. rm command to delete a file or directory command reference.
rm command commonly used options
-f: not remind When you delete a file or directory, direct forced to delete.
-i: to remind the user to confirm when deleting files or directories.
-r: You must use this option to delete a directory, indicate recursively delete the entire directory tree.

Delete the directory tree xiang directory / bdqn / kgc in.
Linux directory and file manipulation commands basis

mv command
mv command for the specified file or directory transfer position, if the target position and the position of the same source, the effect is equivalent to the document name.

Mobile Directory bdqn / kgc / yjs YJS in the directory / fan / ji in.
Linux directory and file manipulation commands basis

4, find directories and files
which command
which command is used to find the Linux command program and displays the specific location of its main search PATH environment variable determined by the user, this range is also the default search Linux system when executing a command or program path .

Ls and mkdir command search path is located.
Linux directory and file manipulation commands basis

find command
find command is very powerful Linux system Find command, you can look fine, depending on the attribute name, type, size, and other targets. find command takes a while to find a recursive way, its use in the form of very flexible, can be quite complex.
Several common methods find command
Search by name: keyword "-name", according to find the name of the target file, and allows the use of "*" wildcard and "?."
Search by file size: The keyword is "-size", to find based on the size of the target file, usually with "+", "-" sign Setting Look condition. Common capacity units include kB (k note lowercase), MB, GB.
By file owner lookup: keyword "-user", according to find whether the files belonging to the target user.
By file type lookup: keyword "-type", to find the type of file, the type herein refers to a regular file (F), the directory (D), the block device file (B), the character file device (c) Wait.

Find a name in the current directory as "xiang" file.
Linux directory and file manipulation commands basis

Guess you like

Origin www.linuxidc.com/Linux/2019-08/160384.htm
Recommended