Add Linux and PostgreSQL commands

This commit is contained in:
James Skemp 2022-06-19 00:31:08 -05:00
parent b63aacb5d7
commit 5d976fe81e
2 changed files with 51 additions and 1 deletions

View File

@ -1,4 +1,5 @@
# Linux
Specifically using Ubuntu.
## SSH
Type `exit` to exit out of a SSH session.
@ -24,6 +25,12 @@ sudo shutdown -r 5
# Shutdown
sudo poweroff
# Get machine and kernel information.
uname -mrs
# Get distribution-specific information.
lsb_release -a
```
### Updates
@ -91,8 +98,10 @@ rm file.txt
# Remove/delete an empty directory.
rmdir path/to/directory
# Remove/delete a directory, even if it has files.
# Remove/delete a directory, even if it has files. (Only macOS?)
rmdir -r path/to/directory
# Works on Ubuntu.
rm -r path/to/directory
```
### File viewing and creation
@ -174,6 +183,12 @@ passwd <user>
# List user information, including groups.
id <user>
# List all users.
cat /etc/passwd
# List all users across multiple sources.
getent passwd
```
## Permissions

View File

@ -2,10 +2,21 @@
Unless otherwise noted, non-SQL commands are running under Ubuntu.
```bash
# On Ubuntu, run psql as default postgres user.
sudo -u postgres psql
# List all databases.
sudo -u postgres psql -l
```
```sql
-- List all databases.
\l
-- Quit psql.
\q
```
## Configuration
```bash
@ -26,3 +37,27 @@ SHOW hba_file;
-- Or just query the file for rules.
select * from pg_hba_file_rules();
```
## User management
```sql
-- List all users.
\du
-- Create a new user.
CREATE USER <name>;
```
## Database management
```bash
# Create a new database.
sudo -u postgres createdb <name>
# Verify it was created.
sudo -u postgres psql -l
# Create a new database, echoing out the commands run.
sudo -u postgres createdb <name> -e
# Drop a database.
sudo -u postgres dropdb <name>
```