Files
knowledge-base/Linux/linux-users.md
2026-05-30 15:40:35 +00:00

36 lines
599 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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`