Showing posts with label GNU/Linux. Show all posts
Showing posts with label GNU/Linux. 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.

Sunday, August 11, 2024

File Permissions in Linux

 

File Permissions in Linux

1. chmod (Change Mode)

The chmod command allows you to modify file permissions. These permissions control read, write, and execute access for the owner, group, and others. Here are two ways to use chmod:

  • Symbolic Mode:

    • Syntax: chmod [ugoa] [[+-=] [mode]] file
    • Example: To add write permission for the user, group, and others to a file named file1, use:
      chmod ugo+w file1
      
  • Numeric Mode:

    • The mode is a combination of three digits:
      • First digit: User permissions
      • Second digit: Group permissions
      • Third digit: Others’ permissions
    • Example: To give read/write/execute permission to the user, read/execute permission to the group, and execute permission to others, use:
      chmod 751 file1
      

2. chown (Change Ownership)

The chown command changes the ownership of a file. Only the current owner can change ownership. Syntax:

chown [owner] [file]

Example: To change the owner of file1 to user2, assuming it’s currently owned by the current user:

chown user2 file1

3. chgrp (Change Group Ownership)

The chgrp command changes the group ownership of a file. Like chown, only the owner can perform this action. Syntax:

chgrp [group] [file]

Example: To change the group of file1 to group2, assuming it’s currently owned by the current user:

chgrp group2 file1
Understanding these commands will empower you to manage permissions effectively. Happy learning!

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...