Two Linux operating command (mkdir, rm, mv, cp, cat, nl)

mkdir

mkdir命令:创建指定的目录,要求创建的用户在当前目录具有写权限,并且指定的目录名不能是当前目录中已有的目录
mkdir:make directory的缩写
命令格式:mkier 【选项】 目录

Common parameters

parameter description
-m --mode = mode Set permissions <mode>
-p --parents You can make a path name. If some of the directory path does not exist yet, after adding this option, the system will automatically build a good directory which does not yet exist, that one can create multiple directories
-v --verbose Each time you create a new directory will display information

Common examples
Example a: a plurality of recursively create directory, create file three
mkdir -pa / b / c
Example Two: Create directory permissions 777
mkdir -m 777 a
Example Two: Create a directory display information
mkdir -vp a / b

rm command

rm:删除一个目录中的一个或多个文件或目录,它也可以将某个目录及其下的所有文件及子目录均删除。对于链接文件,只会删除链接,原文件均保持不变
rm:remove的缩写
命令格式:rm 【选项】 文件或目录

Common parameters:

parameter description
-f --force Ignore nonexistent files, never prompt
-i --interactive Interactive deleted
-r --recursive Rm indicate all the parameters listed in directories and subdirectories are recursively deleted
-v --verbose Showing in detail step

Common examples
delete a file: rm test
forcibly remove the file, the system will not prompt: rm -f test

mv command

mv:用来移动文件或更改文件名
mv: move的缩写
命令格式: mv 【选项】 源文件或目录 目标文件或目录

Common parameters

parameter description
-b --back For overwrite the file, the front cover to back up
-f --force If the target file already exists, do not ask directly covered
-i --interactive If the target file already exists, it will ask whether to overwrite
-u --update If the target file already exists, and the relatively new source file is not updated
-t --target This option is applicable to a mobile multiple source files to a directory, in which case the former target directory, the source file after

Common examples
Example a: a file rename b: mv ab
Example Two: move the file to a directory test: a test Music Videos
Example Three: a.txt move to the file directory test1, if the file exists, covers the front asking to overwrite: mv -i a.txt test1

cp command

cp命令是用来复制文件或者目录 
cp:copy的缩写
命令格式:cp 【选项】 源文件 目录

Common parameters

parameter description
-t --target-dirctory Specified target directory
-i --interactive Ask before overwrite (the failure of the previous -n option)
-n --no-clobbe Do not overwrite an existing file (the front of the -i option failure)
-s --symbolic-link Create a symbolic link to the source file, rather than copying files
-f --force Forced copy a file or directory, regardless of the destination file already exists
-u --update After using this parameter, only the source file modification time than the destination file

Example One: Create a symbolic link to the file b a: cp -sab
Example Two: Copy all files in the directory to test1 test2 directory, Ask before overwrite: cp -i test1 / * test2
Example Three: The next test1 directory copy the file to the recently updated test2 directory, ask before overwrite: cp -ui test1 / * test2

The cat command

cat:将文件或标准输出到标准输出,用来显示文件内容,或将几个连接起来显示
cat :concatenate的缩写
命令格式
cat 【选项】 【文件】

Common parameters

parameter description
-n --number All numbers output numbered starting from a number of rows of all outputs
-s --squeeze-blank There are more than two consecutive lines blank, blank lines on the substitution line

Example 1: the contents of the file with a line number input a.txt b.txt this file:
CAT a.txt -n> b.txt
Example 2: the contents with a line number a.txt b.txt input to the file, multiple blank lines into one line of output:
CAT -NS a.txt> b.txt
Example three: the reverse display file contents a.txt
tac a.txt
This in turn write tac is cat

nl command

To view the contents of the file
format: nl [file]

Published 17 original articles · won praise 0 · Views 501

Guess you like

Origin blog.csdn.net/HexString/article/details/104692411