diff --git a/Linux/linux-users.md b/Linux/linux-users.md new file mode 100644 index 0000000..5130cf3 --- /dev/null +++ b/Linux/linux-users.md @@ -0,0 +1,36 @@ +# Linux 用户基础操作 + +## 查看用户 + +```bash +# 查看所有用户 +cat /etc/passwd + +# 查看当前在线用户 +who + +# 显示谁在登录 +w +``` + +## 切换用户 + +```bash +su - postgres # 切换到 postgres 用户(带登录 shell) +sudo su - postgres # 用 sudo 切换(需要 root 权限) +``` + +## PostgreSQL 进数据库 + +```bash +su - postgres # 先切到 postgres 用户 +psql # 直接进数据库 +``` + +或者不切换用户直接进: + +```bash +psql -U postgres -h 192.168.3.49 -p 5432 +``` + +输入密码后进入 SQL 操作界面,quit 用 `\q`。 \ No newline at end of file