The content of this article is a summary (detailed) of commonly used commands in Linux. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
ls -alrtAFR
-a Display all files and directories (ls defaults to file names or directory names starting with "." as hidden files and will not be listed)
-l In addition to the file name, the file type, permissions, owner, file size and other information are also listed in detail
-r Display the files in reverse order (originally in English alphabetical order)
-t List the files in order of creation time
-A Same as -a, but do not list "." (current directory) and ".." (parent directory)
-F in the listed Add a symbol after the file name; for example, add "*" for executable files, and add "/" for directories
-R. If there are files in the directory, the following files will also be listed in sequence
touch -acfm-r
is used to modify the time attributes of the file or directory, including access time and change time. If the file does not exist, the system will create a new file.
mkdir [-p] dirName
-p Make sure the directory name exists. If it does not exist, create one.
mkdir -p BBB/Test Create a subdirectory named Test in the BBB directory under the working directory. If the BBB directory does not exist originally, create one. (Note: If -p is not added in this example, and the original BBB directory does not exist, an error will occur.)
rm [options] name...
-i Ask for confirmation one by one before deleting .
-f Even if the original file attribute is set to read-only, it will be deleted directly without confirming one by one.
-r Delete the files in the directory and below one by one.
mv [options] source dest
-i: If there is already a file with the same name in the specified directory, first ask whether to overwrite the old file;
-f: To overwrite an existing file in the mv operation No instructions are given when there are some target files;
mv file name file name changes the source file name to the target file name
mv file name directory name moves the file to the target directory
mv directory name directory name the target directory has been If exists, move the source directory to the target directory; if the target directory does not exist, rename it
mv Directory name file name error
cp [options] source dest
-a: This option is usually in Used when copying a directory, it preserves links, file attributes, and copies all contents under the directory. Its effect is equivalent to the dpR parameter combination.
-d: Keep the link when copying. The links mentioned here are equivalent to shortcuts in Windows systems.
-f: Overwrite an existing target file without giving a prompt.
-i: Contrary to the -f option, a prompt is given before overwriting the target file, asking the user to confirm whether to overwrite. The target file will be overwritten when answering "y".
-p: In addition to copying the contents of the file, the modification time and access permissions are also copied to the new file.
-r: If the given source file is a directory file, all subdirectories and files in the directory will be copied.
-l: Do not copy files, just generate link files.
cat -AbeEnstTuv [--version] fileName
-n or --number: Number all output lines starting from 1.
-b or --number-nonblank: Similar to -n, except that blank lines are not numbered.
-s or --squeeze-blank: When encountering two or more consecutive blank lines, replace them with one blank line.
scp [optional parameter] file_source file_target
-r: Recursively copy the entire directory.
-P port: Note the capital P, port is the port number used to specify the data transmission
1. Copy from local to remote
scp local_file remote_username@remote_ip:remote_folder
or
scp local_file remote_username@remote_ip:remote_file
or
scp local_file remote_ip:remote_folder
or
scp local_file remote_ip:remote_file
The 1st and 2nd ones specify the user name. After the command is executed, you need to enter the password again. The 1st one Only the remote directory is specified, and the file name remains unchanged. The second one specifies the file name;
The third and fourth ones do not specify a user name. You need to enter the user name and password after the command is executed. The third one only specifies the remote directory. Directory, the file name remains unchanged, the 4th one specifies the file name;
Application example:
scp /home/space/music/1.mp3 root@www.runoob.com:/home/root/others/music scp /home/space/music/1.mp3 root@www.runoob.com:/home/root/others/music/001.mp3 scp /home/space/music/1.mp3 www.runoob.com:/home/root/others/music scp /home/space/music/1.mp3 www.runoob.com:/home/root/others/music/001.mp3
Copy directory command format:
scp -r local_folder remote_username@remote_ip:remote_folder
or
scp -r local_folder remote_ip:remote_folder
The first one specifies the user name, and you need to enter the password after the command is executed;
The second one does not specify the user name, and you need to enter the user name and password after the command is executed;
Application Example:
scp -r /home/space/music/ root@www.runoob.com:/home/root/others/ scp -r /home/space/music/ www.runoob.com:/home/root/others/
The above command copies the local music directory to the remote others directory.
2. Copy from remote to local
To copy from remote to local, just change the order of the last two parameters of the command to copy from local to remote, as shown in the following example
Application example:
scp root@www.runoob.com:/home/root/others/music /home/space/music/1.mp3 scp -r www.runoob.com:/home/root/others/ /home/space/music/
Instructions
1. If the remote server firewall has set a specified port for the scp command, we need to use the -P parameter to set the command The port number, the command format is as follows:
scp -P 4588 remote@www.runoob.com:/usr/local/sin.sh /home/administrator #scp command uses port number 4588. When using the scp command, ensure that the user used Have permission to read the corresponding files on the remote server, otherwise the scp command will not work.
rcp
rcp -pr[target file or directory]
rcp -pr[目标文件]
-p 保留源文件或目录的属性,包括拥有者,所属群组,权限与时间。
-r 递归处理,将指定目录下的文件与子目录一并处理。
rcp root@218.6.132.5:./testfile testfile #复制远程文件到本地 rcp root@218.6.132.5:home/rootlocal/testfile testfile #要求当前登录账户 cmd 登录到远程主机 rcp 218.6.132.5:./testfile testfile
ftp -dignv
tftp [主机名称或 IP 地址]
tar
-c 或--create 建立新的备份文件。
-t 或--list 列出备份文件的内容。
-x 或--extract 或--get 从备份文件中还原文件。
-z 或--gzip 或--ungzip 通过 gzip 指令处理备份文件。
-f<备份文件>或--file=<备份文件> 指定备份文件。
-v 或--verbose 显示指令执行过程。
# touch a.c # tar -czvf test.tar.gz a.c //压缩 a.c文件为test.tar.gz
a.c
列出压缩文件内容
# tar -tzvf test.tar.gz -rw-r--r-- root/root 0 2010-05-24 16:51:59 a.c
解压文件
# tar -xzvf test.tar.gz a.c
gzip
-c 或--stdout 或--to-stdout 把压缩后的文件输出到标准输出设备,不去更动原始文件。
-d 或--decompress 或----uncompress 解开压缩文件。
-f 或--force 强行压缩文件。不理会文件名称或硬连接是否存在以及该文件是否为符号连接。
-l 或--list 列出压缩文件的相关信息。
-r 或--recursive 递归处理,将指定目录下的所有文件及子目录一并处理。
-v 或--verbose 显示指令执行过程。
压缩文件
[root@w3cschool.cc a] # ls //显示当前目录文件 a.c b.h d.cpp [root@w3cschool.cc a] # gzip * //压缩目录下的所有文件 [root@w3cschool.cc a] # ls //显示当前目录文件 a.c.gz b.h.gz d.cpp.gz [root@w3cschool.cc a]#
列出详细的信息
[root@w3cschool.cc a] # gzip -dv * //解压文件,并列出详细信息 a.c.gz: 0.0% -- replaced with a.c b.h.gz: 0.0% -- replaced with b.h d.cpp.gz: 0.0% -- replaced with d.cpp [root@w3cschool.cc a]#
显示压缩文件的信息
[root@w3cschool.cc a] # gzip -l * compressed uncompressed ratio uncompressed_name 24 0 0.0% a.c 24 0 0.0% b.h 26 0 0.0% d.cpp
zip
将 /home/html/ 这个目录下所有文件和文件夹打包为当前目录下的 html.zip:zip -q -r html.zip /home/html
如果在我们在 /home/html 目录下,可以执行以下命令:
zip -q -r html.zip *
从压缩文件 cp.zip 中删除文件 a.c
zip -dv cp.zip a.c
unzip
查看压缩文件中包含的文件:# unzip -l abc.zip
-v 参数用于查看压缩文件目录信息,但是不解压该文件。
# unzip -v abc.zip
kill
kill 12345 杀死进程
其他
环境变量 cmd:sysdm.cpl
The above is the detailed content of Summary of commonly used commands in Linux (detailed). For more information, please follow other related articles on the PHP Chinese website!