Take you through the basic commands Linux (Linux for learning a small partner wants)

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.
Take you through the basic commands Linux (Linux for learning a small partner wants)

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.
Take you through the basic commands Linux (Linux for learning a small partner wants)

2、创建目录和文件
touch命令
touch命令本来用于更新文件的时间标记,但在实际使用中常用于创建新的测试文件,使用文件名作为参数,可以同时创建多个文件。

在yjs中创造两个空文件夹,文件名分别为aaa.html、ccc.txt。
Take you through the basic commands Linux (Linux for learning a small partner wants)

mkdir命令
mkdir命令用于创建新的空目录,使用要创建的目录位置作为参数。如果与选项-p结合一起使用,就可以一次性创建嵌套的多层目录。

创建一个/bdqn,并在/bdqn目录下创建子目录kgc,再在子目录/bdqn/kgc目录下面创建子目录yjs。
Take you through the basic commands Linux (Linux for learning a small partner wants)

3、复制、删除、移动目录和文件
cp命令
cp命令用于复制文件或目录,将所需要复制的文件或目录重建一份并保存为新的文件或目录。
cp命令的常用选项
-f:覆盖目标同名文件或目录时不进行提醒,而直接强制复制。
-i:覆盖目标同名文件或目录时提醒用户确定。
-p:复制时保持源文件的权限、属主及时间标记等属性不变。
-r:复制目录时必须使用此选项,表示递归复制所有文件及子目录。

把目录/fan/ji/xiang复制到目录/bdqn/kgc里面。
Take you through the basic commands Linux (Linux for learning a small partner wants)

rm命令
rm命令用于删除指定的文件或目录,在Linux命令行界面中,删除的文件是难以恢复的,因此使用rm命令删除文件时需要格外的小心。rm命令使用要删除的的文件或目录命作为参考。
rm命令常用选项
-f:删除文件或目录时不进行提醒,而直接强制删除。
-i:删除文件或目录时提醒用户确认。
-r:删除目录时必须使用此选项,表示递归删除整个目录树。

删除目录/bdqn/kgc中的目录树xiang.
Take you through the basic commands Linux (Linux for learning a small partner wants)

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.
Take you through the basic commands Linux (Linux for learning a small partner wants)

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.
Take you through the basic commands Linux (Linux for learning a small partner wants)

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.
Take you through the basic commands Linux (Linux for learning a small partner wants)

Guess you like

Origin blog.51cto.com/14449528/2428990