Change Group Ownership in Linux with the chgrp Command

#The chgrp command in Linux is a useful tool for changing the group ownership of files and directories. In this post, we'll cover what the chgrp command is, how to use it, and some examples of its usage.

What is the chgrp command?

In Linux, every file and directory has an owner and a group associated with it. The owner of the file is responsible for its contents, while the group ownership is used to control access to the file by other users. The chgrp command is used to change the group ownership of a file or directory.

How to use the chgrp command

The basic syntax of the chgrp command is as follows:

chgrp [OPTIONS] GROUP FILE

Where GROUP is the name of the group you want to change the ownership to, and FILE is the name of the file or directory you want to change the ownership of.

Some common options include:

-R: Changes the group ownership recursively for all files and subdirectories within the specified directory.
-v: Displays verbose output showing the changes made.

Examples of chgrp usage

Here are some examples of using the chgrp command:

1.Change the group ownership of a single file:

chgrp mygroup file.txt
2.Change the group ownership of multiple files:

chgrp mygroup file1.txt file2.txt
3.Change the group ownership of a directory and its contents:

chgrp -R mygroup /path/to/directory
4.Change the group ownership of a symbolic link:

chgrp mygroup symlink

Note: In all examples, mygroup is the name of the group you want to change the ownership to, and file.txt, /path/to/directory, etc. are the names of the files or directories you want to change the ownership of.

In conclusion

the chgrp command is a useful tool for changing the group ownership of files and directories in Linux. By understanding its basic syntax and usage, you can effectively control access to your files and directories by different groups of users.

How to Install Adminer on Ubuntu

 In this tutorial, we will Install Adminer on Ubuntu. 

Adminer is a database management tool that allows you to mangage multiple types of databases.  It is similar to other tools such as phpMyAdmin and offers features such as data browsing, editing, and SQL command execution. You can download the latest version of Adminer from the official website at https://www.adminer.org/.

How does Adminer work ?

Adminer works by providing a web-based interface for managing databases. When you access Adminer through a web browser, it connects to the specified database and displays a set of tools for managing the data and structure of the database.

Some of the main features of Adminer include:

  1. Data browsing: Adminer allows you to view and search through the data in the tables of your database, including the ability to sort and filter the data.
  2. Data editing: You can use Adminer to add, edit, and delete records in your database tables, as well as change the structure of the tables.
  3. SQL command execution: You can use Adminer to execute SQL commands directly against the database, which can be useful for more advanced tasks such as creating new tables, modifying indexes, and running reports.
  4. User management: You can use Adminer to create and manage users and assign permissions for different databases and tables.
  5. Multi-database support: Adminer supports multiple types of databases including MySQL, PostgreSQL, SQLite, and Oracle.

Overall, Adminer is a simple and user-friendly tool for managing and maintaining your databases. It is lightweight and does not require any additional configuration.

To install Adminer on Ubuntu, you can use the following steps:

Make sure Apache server installed and configured on Ubuntu

    sudo apt install apache2
    sudo systemctl is-enabled apache2.service
    sudo systemctl enable apache2.service
    sudo systemctl start apache2.service

Make sure Apache PHP required to run Adminer ( For example: php installed version 8.1 )

    sudo apt install php
    sudo a2query -m php8.1

1.Download the latest version of Adminer from the official website by using the command:

    wget https://www.adminer.org/latest.php -O adminer.php
 

2.Create a new directory for Adminer in the web server's document root, for example, /var/www/html/adminer, and move the downloaded file to this directory:

    sudo mkdir /var/www/html/adminer
    sudo mv adminer.php /var/www/html/adminer
3.Give the web server user ownership of the Adminer directory:
    sudo chown -R www-data:www-data /var/www/html/adminer
4.Create a new Apache virtual host configuration file for Adminer, for example /etc/apache2/sites-available/adminer.conf and add the following content:

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /var/www/html/adminer
    ServerName localhost
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

5.Enable the new virtual host and the rewrite module:
    sudo a2ensite adminer.conf
    sudo a2enmod rewrite
6.Restart Apache to apply the changes:
    sudo systemctl restart apache2
Finally, you can access Adminer by visiting http://localhost/adminer.php in your web browser.



 


How to check Disk is SSD or HDD on Linux

In this tutorial, How to check Disk is SSD or HDD on Linux. Solid-state drives (SSDs) are fast, silent, and less prone to failure than traditional hard disk drives (HDDs).

  • HDD store information on a rotating disk known as a platter
  • SSD use flash memory to store and persist data.

Using lsblk command to check HDD or SSD

lsblk -o name,rota | tail
If you get a 1 then the disk is an HDD. A 0 (zero) on the column rota is SSD.

The output terminal as below:
How to check Disk is SSD or HDD on Linux

Using the cat Command

cat /sys/block/sda/queue/rotational
If the result is 1, then the disk is an HDD. the output 0 ( zero) that disk is ssd.

The output terminal as below:

Check Disk is SSD or HDD on Linux
 

Install and use htop command in Linux

 

 In this tutorial, How to Install and use htop command in Linux.

Install htop command Linux in Linux

If your use Debian/Ubuntu, The following command line below:

sudo apt install htop

or, If your use Fedora/RHEL/CentOS

sudo dnf install htop

One your done with the installation, In the terminal the basic you use htop command

CPU usage bar

CPU usage bar 

 Memory bar

Memory bar

Green: Memory being utilized by system processes.
Blue: Memory used by buffer pages.
Orange: Memory allocated for cache pages.

Sort processes based on Resource Consumption

 Press F6 as the picture below:

Sort processes based on Resource Consumption

Search for a specific process

Press F3 and you a search prompt as show below:

Search for a specific process

Filter ongoing processes

Press F4 and you a search prompt as show below:

Filter ongoing processes

 Kill process

 Press F9 and you a search prompt as show below: