Skip to main content

Linux常用命令

命令描述用法示例
ls列出文件和目录lsls -lls -a
cd切换当前工作目录cd /home/usercd ..
pwd显示当前工作目录的路径pwd
mkdir创建目录mkdir new_dir
rm删除文件或目录rm file.txtrm -r directory
cp复制文件或目录cp file.txt new_file.txtcp -a directory new_directory
mv移动文件或重命名文件mv file.txt new_file.txtmv file.txt new_directory/
touch创建新文件或更新时间戳touch file.txt
cat查看文件内容cat file.txt
less分页查看文件内容less file.txt
head查看文件前几行内容head file.txt
tail查看文件后几行内容tail file.txt
grep搜索匹配的文本grep "search_text" file.txt
find查找文件find / -name file.txt
ps列出进程ps
kill终止进程kill 1234
top查看系统资源使用情况top
du显示目录或文件的磁盘使用情况du -sh directory
df显示磁盘分区的空间使用情况df -h
tar打包和解包文件tar -cvf file.tar filestar -xvf file.tar
gzip压缩文件gzip file.txt
gunzip解压缩文件gunzip file.txt.gz
ping检测网络连接ping google.com
ssh远程连接到另一台计算机ssh user@host
scp在计算机之间传输文件scp file.txt user@host:/remote/dir
wget下载文件wget http://example.com/file.txt
curl向URL发送请求curl http://example.com
ifconfig显示和配置网络接口ifconfig
netstat显示网络连接和路由表netstat
iptables配置网络防火墙iptables -I INPUT -p tcp --dport 80 -j ACCEPT
useradd添加用户账户useradd new_user
passwd更改用户的密码passwd user