ls |
列出当前目录的内容 |
ls |
cd |
切换当前工作目录 |
cd /path/to/directory |
pwd |
显示当前工作目录的路径 |
pwd |
mkdir |
创建新目录 |
mkdir new_directory |
rmdir |
删除空目录 |
rmdir empty_directory |
cp |
复制文件或目录 |
cp source_file destination_file |
mv |
移动文件或目录,或者重命名文件 |
mv old_file new_file |
rm |
删除文件或目录 |
rm file_to_delete |
touch |
创建新文件或更新文件的时间戳 |
touch new_file |
cat |
查看文件内容 |
cat file_to_view |
more |
分页查看文件内容 |
more large_file |
less |
分页查看文件内容(类似more,支持向上滚动) |
less large_file |
head |
查看文件开头部分 |
head file_to_view |
tail |
查看文件结尾部分 |
tail log_file |
grep |
在文件中搜索指定的文本模式 |
grep "pattern" file_to_search |
find |
根据条件查找文件 |
find /path/to/search -name "filename" |
locate |
快速查找文件 |
locate file_to_find |
ps |
查看当前运行的进程 |
ps |
top |
实时查看系统资源使用情况和运行中的进程 |
top |
htop |
交互式的类似top的进程查看器 |
htop |
free |
查看内存使用情况 |
free |
df |
查看磁盘空间使用情况 |
df |
du |
估算文件或目录的磁盘使用情况 |
du -sh /path/to/directory |
uname |
显示系统信息 |
uname -a |
ifconfig |
查看和配置网络接口信息(已被弃用,使用ip) |
ifconfig |
ip |
查看和配置网络接口信息 |
ip address show |
shutdown |
关闭系统 |
sudo shutdown now |
reboot |
重启系统 |
sudo reboot |
useradd |
创建新用户 |
sudo useradd new_user |
userdel |
删除用户 |
sudo userdel existing_user |
passwd |
更改用户密码 |
passwd username |
su |
切换用户 |
su username |
sudo |
以超级用户权限执行命令 |
sudo command_to_execute |
chown |
更改文件或目录的所有者 |
sudo chown new_owner file_or_directory |
chmod |
更改文件或目录的权限 |
chmod permissions file_or_directory |
chgrp |
更改文件或目录的所属组 |
sudo chgrp new_group file_or_directory |
tar |
打包和解包文件 |
tar -cvf archive.tar files_to_archive |
gzip |
压缩和解压缩文件(gzip格式) |
gzip file_to_compress |
bzip2 |
压缩和解压缩文件(bzip2格式) |
bzip2 file_to_compress |
xz |
压缩和解压缩文件(xz格式) |
xz file_to_compress |
zip |
压缩和解压缩ZIP格式文件 |
zip archive.zip files_to_compress |
unzip |
解压缩ZIP格式文件 |
unzip archive.zip |
ping |
检测主机的连通性 |
ping example.com |
curl |
从终端发送HTTP请求 |
curl http://example.com |
wget |
下载文件 |
wget http://example.com/file |
ssh |
安全登录远程主机 |
ssh username@remote_host |
scp |
在本地主机和远程主机之间复制文件 |
scp /path/to/local_file username@remote_host:/path/to/remote_directory |
rsync |
文件同步工具 |
rsync -avz /path/to/source username@remote_host:/path/to/destination |