linux基本命令
命令 | 描述 | 示例 |
---|---|---|
ls | 列出当前目录中的文件和子目录 | ls |
cd | 更改当前目录 | cd directory_path |
mkdir | 创建新目录 | mkdir directory_name |
rm | 删除文件或目录 | rm file_name 或 rm -r directory_name |
cp | 复制文件或目录 | cp source_file destination_file 或 cp -r source_directory destination_directory |
mv | 移动或重命名文件或目录 | mv source_file destination_file 或 mv source_directory destination_directory |
cat | 查看文件内容 | cat file_name |
grep | 在文件中查找指定字符串 | grep "string" file_name |
head | 查看文件开头部分内容 | head file_name |
tail | 查看文件结尾部分内容 | tail file_name |
chmod | 更改文件或目录的权限 | chmod permissions file_name 或 chmod permissions directory_name |
chown | 更改文件或目录的所有者 | chown user_name file_name 或 chown user_name directory_name |
ps | 查看进程状态 | ps |
top | 查看系统资源使用情况和进程状态 | top |
kill | 终止进程 | kill process_id |
wget | 下载文件 | wget file_url |
tar | 打包和压缩文件 | tar options archive_name file_name |
ssh | 远程登录到另一台计算机 | ssh username@remote_host |
linux进阶命令
命令 | 描述 | Markdown 源代码 |
---|---|---|
find | 在文件系统中查找文件 | find directory_path -name "file_name" |
locate | 快速查找文件 | locate file_name |
du | 显示目录占用磁盘空间的大小 | du directory_path |
df | 显示文件系统磁盘空间使用情况 | df |
scp | 在本地计算机和远程计算机之间复制文件 | scp source_file username@remote_host:destination_directory 或 scp username@remote_host:source_file destination_directory |
rsync | 在本地计算机和远程计算机之间同步文件 | rsync source_directory username@remote_host:destination_directory 或 rsync username@remote_host:source_directory destination_directory |
curl | 通过 URL 下载数据 | curl url |
ping | 测试与另一台计算机的网络连接 | ping remote_host |
traceroute | 追踪网络数据包的路径 | traceroute remote_host |
lsof | 显示系统中打开的文件和进程 | lsof |
netstat | 显示网络连接和端口状态 | netstat |
ifconfig | 显示和配置网络接口 | ifconfig |
route | 显示和配置网络路由表 | route |
iptables | 配置 Linux 防火墙 | iptables options |
grep | 在文件中查找指定字符串 | grep "string" file_name |
sed | 在文件中进行文本替换 | sed 's/old_string/new_string/g' file_name |
awk | 在文件中处理文本 | awk 'pattern {action}' file_name |
sort | 对文件内容进行排序 | sort file_name |
uniq | 去除文件中的重复行 | uniq file_name |