Showing posts with label commandline. Show all posts
Showing posts with label commandline. Show all posts

Tuesday, October 22, 2024

How to Install PostgreSQL on Debian 12: A Step-by-Step Guide

PostgreSQL, commonly known as Postgres, is a powerful, open-source relational database management system renowned for its advanced features and reliability. In this comprehensive step-by-step tutorial, we will guide you through the process of installing PostgreSQL on a Debian 12 system

Step 1: Update the System

Start by ensuring your Debian 12 system is up to date.  Open a terminal and run the following commands:

sudo apt update
sudo apt upgrade

This command will update the package list and upgrade existing packages on your system

Step 2: Install PostgreSQL

To install PostgreSQL on Debian 12, use the following command:

sudo apt install postgresql postgresql-contrib

This command will install both the PostgreSQL server and additional contrib packages that provide useful extensions and utilities

Step 3: Start and Enable PostgreSQL

PostgreSQL should start automatically after installation

However, to ensure it starts at boot, use the following command:

sudo systemctl enable postgresql

To check the status of the PostgreSQL service, use:

sudo systemctl status postgresql

Step 4: Create a PostgreSQL User and Database

Let’s create a new PostgreSQL user and database

Replace your_user and your_database with your preferred values:

sudo -u postgres createuser your_user sudo -u postgres createdb -O your_user your_database

To access the PostgreSQL command-line tool, psql, use the following command:

sudo -u postgres psql -d your_database

Once in the psql prompt, execute the following SQL commands to create a basic table:

CREATE TABLE example ( id serial PRIMARY KEY, name VARCHAR (100), age INT );

Step 5: Managing the PostgreSQL Service

To manage the PostgreSQL service on Debian 12, you can use the following commands

  •     Start PostgreSQL service:
sudo systemctl start postgresql
  • Stop PostgreSQL service:
sudo systemctl stop postgresql
  • Restart PostgreSQL service:
sudo systemctl restart postgresql
  • Check PostgreSQL service status:
sudo systemctl status postgresql

Congratulations! You have successfully installed PostgreSQL on your Debian 12 server, created a database, and learned how to perform basic management tasks

PostgreSQL’s extensive feature set makes it a versatile choice for various data storage needs.

How to Install ifconfig on Debian

Do you see ifconfig command not found error in Debian? Here is my quick tutorial on how to install it on Debian.

 

I have made fresh install of Debian 12 server on my VM and  i wanted to check IP of VM and I have encountered the problem:

 The ifconfig package is not included by default in Debian since it is being phased out in favor of the ip command. The ip command now handles tasks such as modifying or displaying routing, network devices, interfaces, and tunnels."

 If we still want to use the good old ifconfig command, you'll have to install it explicitly.

 

Installing ifconfig command in Debian 

The ifconfig is not a package in its own. It is installed with net-tools package that has some additional networking tools. 

So to get ifconfig, you need to install net-tools package like this:

sudo apt install net-tools

After install you can use the command:


However, I strongly advise you should start using the IP command. Sooner or later, net-tools will be completely deprecated and you won't be able to install it.

Saturday, November 5, 2022

How to change default ssh login banner

To create a cool ASCII art banner for your server, first start off by going here:

ASCII art creator/

To change the message displayed before login, edit /etc/ssh/sshd_config :
sudo vim /etc/ssh/sshd_config
and add (or uncomment) the line:
Banner /etc/banner
/etc/banner can be whatever file you want. Then edit /etc/banner
sudo vim /etc/banner
You’ll probably need to restart sshd before your changes take effect:
sudo /etc/init.d/ssh restart
To change the message displayed after login, edit /etc/motd :
sudo vim /etc/motd
and enter the message you want to display.

Friday, November 4, 2022

Linux system and Hardware details via command line

Uname command

Basic information can be access with command uname. Which is short for unix name.
  1. Linux Kernel Name
  2. uname -s
  3. Linux Kernel Release
  4. uname -r
  5. Linux Kernel Version
  6. uname -v
  7. Network Node Hostname
  8. uname -n
  9. Machine Hardware Architecture
  10. uname --m
  11. Processor Type
  12. uname -p
  13. Hardware Platform
  14. uname -i
  15. Operating System information
  16. uname -o
  17. Displaying All Information of Uname Command
  18. uname -a

CPU Information with lscpu command:

lscpu

Block Device Information with lsblk

lsblk
More detailed information for all devices:
lsblk -a

USB Device Info with lsusb

lsusb
More detailed information on each device:
lsusb -v

TryHackMe - Shadow Trace Writeup

 Shadow Trace is premium room on TryHackMe.com part of the SOC Level 1 Path. We need to analyse a suspicious file, uncover hidden clues, an...