Linux 系统中有许多常用命令,每个命令都有其特定的功能。以下是一些最常用的 Linux 命令及其主要功能:
ls
-l
:详细列表(权限、所有者、大小等)-a
:显示隐藏文件-h
:人类可读的文件大小(如 KB、MB)cd
cd /home
进入 /home
目录cd ..
返回上一级目录pwd
mkdir
mkdir new_folder
rmdir
rm
-r
:递归删除(用于删除目录)-f
:强制删除(不提示)cp
cp file1.txt /backup/
mv
mv old.txt new.txt
(重命名)mv file1 /tmp/
(移动)touch
cat
cat file.txt
less
/ more
head
head -n 5 file.log
tail
tail -f /var/log/syslog
(实时跟踪日志)find
find / -name "*.conf"
grep
grep "error" /var/log/syslog
uname
-a
:显示所有信息(内核版本、主机名等)df
-h
(人类可读格式)du
du -sh /home
free
-h
(人类可读格式)top
/ htop
ps
aux
(显示所有进程)kill
kill -9 PID
(强制终止)systemctl
systemctl start nginx
systemctl enable nginx
journalctl
journalctl -u nginx
ping
ping google.com
ifconfig
/ ip
ip a
netstat
/ ss
netstat -tulnp
curl
/ wget
curl -O http://example.com/file.zip
ssh
ssh user@192.168.1.100
scp
scp file.txt user@remote:/path/
tar
tar -cvf archive.tar files/
(打包)tar -xvf archive.tar
(解压)gzip
/ gunzip
.gz
文件zip
/ unzip
.zip
文件chmod
chmod 755 script.sh
chown
chown user:group file.txt
history
alias
alias ll='ls -la'
crontab
crontab -e
which
which python
man
man ls
这些命令涵盖了 Linux 日常管理、文件操作、网络配置、进程管理等核心功能,掌握它们可以高效地进行系统管理和故障排查。