跳到主要内容

CheetSheat

小知识

/usr:系统级的目录,可以理解为 C:/Windows//usr/lib 理解为 C:/Windows/System32

/usr/local:用户级的程序目录,可以理解为 C:/Progrem Files/

  • 用户自己编译的软件默认会安装到这个目录下。
  • 每个用户都能使用其中的软件
  • 系统管理员可以使用它来为所有用户安装本地或第三方程序包。

~/.local 仅针对单个用户

查看系统版本信息

cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

查看 cpu

cat /proc/cpuinfo
processor       : 0
vendor_id : GenuineIntel
cpu family : 6
model : 94
model name : Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz
stepping : 3
microcode : 0x1
cpu MHz : 2399.998
cache size : 28160 KB
physical id : 0
...

查看内存

cat /proc/meminfo
# or
free
# free
total used free shared buff/cache available
Mem: 4030004 2560208 131120 1060 1338676 1207444
Swap: 0 0 0

查看文件或目录大小

查看当前目录各个文件大小(看不了文件夹加上其内部文件的总大小)

ls -lh
total 0
drwxrwxrwx 1 melon melon 4.0K Jul 1 22:31 data
drwxrwxrwx 1 melon melon 4.0K Jun 28 12:03 gocyber_repo
drwxrwxrwx 1 melon melon 4.0K Jun 30 17:32 other_repo
drwxrwxrwx 1 melon melon 4.0K Jul 1 23:18 repo
drwxrwxrwx 1 melon melon 4.0K Jul 1 22:51 temp

查看当前文件目录各个文件夹大小

du -h --max-depth=1 .
  • “.”代表当前目录下。也可以换成一个明确的路径
  • -h 表示用 K、M、G 的人性化形式显示

解压

tar -zxvf XXX

查看端口占用情况

lsof -i:<port_name>

关闭 redis

sudo service redis-server stop

Windows 查看端口占用 / 关闭进程

netstat -ano | findstr <port> # 查看端口占用
# 最右边就是进程id
taskkill /PID <id> /F # 关闭进程