放心~被指到的人一定能学会的~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
其他命令使用场景分类: https://www.bilibili.com/read/cv22241446
find
在指定位置查找文件目录
which
定位应用程序
cp
复制文件和目录
mv
移动和重命名文件目录
scp
在两个主机之间基于SSH进行文件安全复制
1. find
Find files or directories under the given directory tree, recursively.
在指定位置查找文件目录
• Find files by extension(指定目录模糊匹配文件名):
find {{root_path}} -name '{{*.ext}}'
• Find files by matching multiple patterns(多条件匹配, 逻辑关系):
find {{root_path}} -name '{{*pattern_1*}}' -or -name '{{*pattern_2*}}'
• Find directories matching a given name, in case-insensitive mode(忽略大小写查找目录):
find {{root_path}} -type d -iname '{{*lib*}}'
• Find files matching a given size range(搜索指定大小范围的文件):
find {{root_path}} -size {{+500k}} -size {{-10M}}
• Find files modified in the last 7 days, and delete them(找到最近7天修改的文件删除):
find {{root_path}} -mtime {{-7}} -delete
• Run a command for each file (use {} within the command to access the filename)(对每个找到的文件执行命令, 后面的{}用于获取文件名-exec 命令 \;):
find {{root_path}} -name '{{*.ext}}' -exec {{wc -l {} }} \;
• Find files matching a given pattern, excluding specific paths(查找文件,排除指定目录路径):
find {{root_path}} -name '{{*.py}}' -not -path '{{*/site-packages/*}}'
2. which
Locate a program in the user's path.
定位应用程序
• If there are multiple executables which match, display all(显示所有):
which -a {{executable}}
3. cp
Copy files and directories.
复制文件和目录
• Copy a file to another location(复制文件到其他位置,可重命名):
cp {{path/to/file.ext}} {{path/to/copy.ext}}
• Copy a file into another directory, keeping the filename(复制文件到其他目录, 不重命名):
cp {{path/to/file.ext}} {{path/to/target_parent_directory}}
• Recursively copy a directory's contents to another location (if the destination exists, the directory is copied inside it)(复制目录内容到另一个位置,如果目标位置存在复制到中):
cp -r {{path/to/directory}} {{path/to/copy}}
• Copy a directory recursively, in verbose mode (shows files as they are copied)(复制目录显示复制过程):
cp -vr {{path/to/directory}} {{path/to/copy}}
• Copy text files to another location, in interactive mode (prompts user before overwriting)(复制文件到其他位置,如果发生覆盖会提示):
cp -i {{*.txt}} {{path/to/target_directory}}
• Dereference symbolic links before copying(间接引用软连接(软连接复制为新文件)):
cp -L {{link}} {{path/to/copy}}
4. mv
Move or rename files and directories.
移动和重命名文件目录
• Move files in arbitrary locations(移动文件到任意路径):
mv {{source}} {{target}}
• Do not prompt for confirmation before overwriting existing files(忽略覆盖提示信息):
mv -f {{source}} {{target}}
• Prompt for confirmation before overwriting existing files, regardless of file permissions(覆盖提示):
mv -i {{source}} {{target}}
• Do not overwrite existing files at the target(移动不覆盖):
mv -n {{source}} {{target}}
• Move files in verbose mode, showing files after they are moved(显示移动过程):
mv -v {{source}} {{target}}
5. scp
Secure copy.
Copy files between hosts using Secure Copy Protocol over SSH.
在两个主机之间基于SSH进行文件安全复制
• Copy a local file to a remote host(复制本地文件到远程主机位置):
scp {{path/to/local_file}} {{remote_host}}:{{path/to/remote_file}}
• Copy a file from a remote host to a local directory:(复制远程主机文件到本地)
scp {{remote_host}}:{{path/to/remote_file}} {{path/to/local_directory}}
• Recursively copy the contents of a directory from a remote host to a local directory(复制远程主机目录到本地):
scp -r {{remote_host}}:{{path/to/remote_directory}} {{path/to/local_directory}}
• Copy a file between two remote hosts transferring through the local host([通过本地主机]在两个远程主机之间拷贝文件):
scp [-3] {{host1}}:{{path/to/remote_file}} {{host2}}:{{path/to/remote_directory}}
• Use a specific username when connecting to the remote host(连接远程服务器时指定用户名):
scp {{path/to/local_file}} {{remote_username}}@{{remote_host}}:{{path/to/remote_directory}}
• Use a specific ssh private key for authentication with the remote host(通过私钥进行远程连接):
scp -i {{~/.ssh/private_key}} {{local_file}} {{remote_host}}:{{/path/remote_file}}

自学笔记~
如果有错~
期待大佬指出~
感谢帮助提升~