Skip to content

4. Helpful Commands

Gabe edited this page Oct 17, 2024 · 2 revisions

The following is a list of helpful linux commands for anyone with root access to the server.

misc

  • cat /etc/passwd - list all users
  • cat /etc/group - list all groups
  • apt autoremove - remove unused packages
  • su - csss-site - change to the csss-site user
  • sudo systemctl start reboot.target reboot machine

systemd

  • systemctl status csss-site - check if csss-site is running
  • systemctl restart csss-site
  • systemctl --type=service --state=running
  • journalctl - see logs from any systemd service
  • systemctl restart nginx

deploy the backend manually

ssh [email protected]
su - csss-site
./csss-site-backend/deploy.sh

postgres

  • \du - list users in the database
  • \list - list databases
  • \c db - change to a database
  • \dt or \dt+ - see a list of tables
  • \d table or \d+ table - view details of table
  • SELECT * FROM table_name
  • \q to quit
  • psql table_name -h localhost -p port -U username to connect to a remote database via command line

docker

  • docker ps -a - list all docker containers that are running or stopped
  • docker start container-name
  • docker exec -it container-name bash

alembic

  • alembic upgrade head perform all outstanding migrations
  • alembic downgrade -1 remove last revision
  • alembic show head to see the head revision
Clone this wiki locally