General Articles – TecAdmin https://tecadmin.net How to guide for System Administrator's and Developers Fri, 13 Jan 2023 17:57:19 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.1 How to Install and Use Flask in Fedora 37/36 https://tecadmin.net/how-to-install-flask-in-fedora/ https://tecadmin.net/how-to-install-flask-in-fedora/#respond Fri, 13 Jan 2023 17:57:19 +0000 https://tecadmin.net/?p=33630 Flask is a popular microweb framework written in Python. It is lightweight and easy to use, making it a good choice for developing small web applications. It is designed to enable developers to create and scale web apps quickly and easily. It has a small and easy-to-extend core, with sensible defaults to get started quickly. [...]

The post How to Install and Use Flask in Fedora 37/36 appeared first on TecAdmin.

]]>
Flask is a popular microweb framework written in Python. It is lightweight and easy to use, making it a good choice for developing small web applications. It is designed to enable developers to create and scale web apps quickly and easily. It has a small and easy-to-extend core, with sensible defaults to get started quickly.

In this article, we will show you how to install and use Flask on a Fedora system.

Prerequisites

Before you start, make sure that you have the following installed on your system:

  • Python 3: Flask is a Python web framework, so you will need to have Python installed on your system. You can check if you have Python installed by running the following command:
    python3 -V 
    

    If Python is not installed, you can install it by running the following command:

    sudo dnf install python3 
    
  • Pip: pip is the package manager for Python. It is used to install Python packages, such as Flask. You can check if you have pip installed by running the following command:
    pip3 -V 
    

    If pip is not installed, you can install it by running the following command:

    sudo dnf install python3-pip 
    

Installing Flask on Fedora

Once you have Python and pip installed, you can use pip to install Flask. To install Flask, run the following command:

pip3 install Flask 

This will install Flask and all of its dependencies.

Creating a Flask App

Now that you have Flask installed, you can create a simple Flask app. Create a file called app.py and add the following code:

from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello():
    return 'Hello, World!'

if __name__ == '__main__':
    app.run()

This code creates a simple Flask app that displays a message when you visit the root URL.

Run Your Flask Application

To run the Flask app, open a terminal and navigate to the directory where you saved app.py. Then, run the following command:

python3 app.py 

This will start the Flask development server, and you should see the following output:

Output
* Serving Flask app 'app' * Debug mode: off WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Running on http://127.0.0.1:5000 Press CTRL+C to quit

To view the app, open a web browser and go to the URL http://127.0.0.1:5000/. You should see the message “Hello, World!” displayed on the page.

Conclusion

In this article, we showed you how to install and use Flask on a Fedora system. Flask is a lightweight and easy-to-use web framework that is perfect for developing small web applications. With Flask, you can create powerful and dynamic web applications with minimal effort.

The post How to Install and Use Flask in Fedora 37/36 appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-install-flask-in-fedora/feed/ 0
How to Print a List without Brackets in Python https://tecadmin.net/print-a-list-without-brackets-in-python/ https://tecadmin.net/print-a-list-without-brackets-in-python/#respond Thu, 12 Jan 2023 14:00:57 +0000 https://tecadmin.net/?p=33046 A Python list is an ordered and changeable collection of data objects. Unlike an array, which can contain objects of a single type, a list can contain a mixture of different types. A list in Python is used to store the sequence of various types of data. A list can be defined as a collection [...]

The post How to Print a List without Brackets in Python appeared first on TecAdmin.

]]>
A Python list is an ordered and changeable collection of data objects. Unlike an array, which can contain objects of a single type, a list can contain a mixture of different types. A list in Python is used to store the sequence of various types of data. A list can be defined as a collection of values or items of different types. Python has a great built-in list type named “list”. List literals are written within square brackets “[]”.

Let’s initialize a Python list with the following arguments:

my_list = [1, 2, 3, 4, 5]

By default, when you print a list in Python, it is displayed with square brackets and commas separating the items. For example:

print(my_list)
# Output: [1, 2, 3, 4, 5]

If you want to print a list without the brackets and commas, you can use one of the following methods:

Method 1: Using for loop

You can use a loop to iterate through the items in the list and print them one by one, without the brackets and commas. Here is an example of how to do this:

for item in my_list:
    print(item, end=' ')
# Output: 1 2 3 4 5

In this example, we use a for loop to iterate through the items in the list. For each item, we use the print() function to print it, followed by a space (end=’ ‘). This will print each item on the same line, separated by a space.

Method 2: Using the join() method

You can also use the join() method to join the items in the list into a single string, separated by a space. Then, you can use the print() function to print the string without the brackets. Here is an example of how to do this:

string = ' '.join(map(str, my_list))
print(string)
# Output: 1 2 3 4 5

In this example, we use the join() method to join the items in the list into a single string, separated by a space. The map() function is used to convert the items in the list to strings (since join() can only join strings). Finally, we use the print() function to print the string.

Method 3: Using the `*` operator

You can also use the * operator to unpack the items in the list and pass them as separate arguments to the print() function. This will print each item on the same line, separated by a space. Here is an example of how to do this:

print(*my_list)
# Output: 1 2 3 4 5

In this example, we use the “*” operator to unpack the items in the list and pass them as separate arguments to the print() function. The “*” operator tells Python to treat the items in the list as separate arguments, rather than as a single list.

Conclusion

In this article, we have covered three different methods for printing a list without brackets in Python: using a loop, using the join() method, and using the “*” operator. Each of these methods has its own advantages and disadvantages, and the best method to use will depend on your specific needs.

The post How to Print a List without Brackets in Python appeared first on TecAdmin.

]]>
https://tecadmin.net/print-a-list-without-brackets-in-python/feed/ 0
Rsync Command to Exclude Files and Directories: An Ultimate Guide https://tecadmin.net/how-to-exclude-files-and-directories-using-rsync-examples/ https://tecadmin.net/how-to-exclude-files-and-directories-using-rsync-examples/#respond Wed, 11 Jan 2023 02:36:56 +0000 https://tecadmin.net/?p=33945 Rsync is a powerful command-line utility for Unix/Linux systems, that allows you to synchronize and transfer files between different two systems. One of the key features of Rsync is the ability to exclude files and directories from the synchronization process. This feature can be incredibly useful for a variety of tasks, such as backups, codebase [...]

The post Rsync Command to Exclude Files and Directories: An Ultimate Guide appeared first on TecAdmin.

]]>
Rsync is a powerful command-line utility for Unix/Linux systems, that allows you to synchronize and transfer files between different two systems. One of the key features of Rsync is the ability to exclude files and directories from the synchronization process. This feature can be incredibly useful for a variety of tasks, such as backups, codebase synchronization, and data management.

In this article, we’ll get a basic understating of excluding files and directories with Rsync command line utility. Also includes a few useful examples using this feature.

Exclude files and directories with rsync

The most basic method for excluding files and directories with Rsync is by using the --exclude option followed by the name of the file or directory you want to exclude. For example, if you want to exclude all files with the “.log” extension, you can use the following command:

rsync -av --exclude='*.log' source/ destination/ 

You can also exclude specific directories by including the entire path, like this:

rsync -av --exclude='path/to/directory' source/ destination/ 

Exclude all written in text file

Another way to exclude files and directories is by using a separate file called an “exclude file”. This file contains a list of excluded patterns, one per line, and Rsync will read the file and apply all the patterns specified in it.

rsync -av --exclude-from='exclude.txt' source/ destination/ 

Here `exclude.txt` file containing all the patterns of files or directories to be excluded

The patterns in the exclude file can be a shell glob (e.g., *.log) or a regular expression (if the --exclude-from option is replaced with --exclude-from-file).

You can also use a `.gitignore` file to specify files to be excluded, which is a good way to exclude version control files.

rsync -av --exclude-from='.gitignore' source/ destination/ 

Include specific files and exclude other

It is also possible to include and exclude files at the same time by using the --include option followed by the name of the file or directory you want to include, and the --exclude option for everything else. For example, the following command will include all files with the “.txt” extension and exclude all other files:

rsync -av --include='*.txt' --exclude='*' source/ destination/ 

It’s important to note that the order of the --include and --exclude options is significant. If you want to include a specific file or directory and then exclude others, the --include option should come first.

Exclude existing files on destination

Another thing to consider is to exclude files that are already present in the destination and the destination is a backup. You can use --ignore-existing options to achieve this.

rsync --ignore-existing -av source/ destination/ 

You can read more about it: https://tecadmin.net/rsync-command-to-copy-missing-files-only/

Exclude large files

Another consideration when using Rsync to exclude files and directories is performance. Excluding large files or directories can save a significant amount of time and space when transferring or synchronizing data. For example, if you’re performing a backup, you may want to exclude large media files or backups of backups.

rsync --ignore-existing --size-range='+100M' -av source/ destination/

There are also many other options available with rsync that can be used to further fine-tune the file transfer process. For example, you can use the --exclude option to exclude certain files or directories from the transfer, or the --dry-run option to see what files would be copied without actually performing the transfer.

Wrap Up

Overall, the ability to exclude files and directories with Rsync is a powerful and essential feature that can greatly improve the efficiency, accuracy, and security of your backups, synchronization, and data management tasks. By using the methods and best practices discussed in this article, you can take full advantage of this feature and ensure that your Rsync commands are working as efficiently and effectively as possible.

The post Rsync Command to Exclude Files and Directories: An Ultimate Guide appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-exclude-files-and-directories-using-rsync-examples/feed/ 0
Rsync Command to Copy Missing Files (Examples) https://tecadmin.net/rsync-command-to-copy-missing-files-only/ https://tecadmin.net/rsync-command-to-copy-missing-files-only/#respond Wed, 11 Jan 2023 01:51:32 +0000 https://tecadmin.net/?p=33935 Rsync is a command-line utility that is used to synchronize files and directories between two locations. It is commonly used to copy files from one location to another while preserving file attributes such as permissions, timestamps, and ownership. One of the powerful features of rsync is the ability to copy only the files that are [...]

The post Rsync Command to Copy Missing Files (Examples) appeared first on TecAdmin.

]]>
Rsync is a command-line utility that is used to synchronize files and directories between two locations. It is commonly used to copy files from one location to another while preserving file attributes such as permissions, timestamps, and ownership. One of the powerful features of rsync is the ability to copy only the files that are missing or have been modified in the destination location. This can be useful when you want to keep a backup of your files, or when you want to update a website or server with the latest changes.

Copy Missing Files with Rsync

To copy only missing files using rsync, you can use the `--ignore-existing` option. This tells rsync to skip files that already exist in the destination location and only copy files that are missing. For example, to copy all files from the directory “source” to the directory “destination”, using the `--ignore-existing` option, you would run the following command:

rsync --ignore-existing -av source/ destination/ 

The -a option tells rsync to preserve file attributes and the -v option verbose mode which will show you the progress of the transfer and the files that are being copied.

Copy Modified Files with Rsync

It’s also possible to copy only the new or modified files and exclude the older files that already exist in the destination. For this you can use -u or --update along with -r or --recursive option to transfer the directory recursively.

rsync -ur source/ destination/ 

Copy Files Modified in Last N Days

You can also specify that the rsync should only copy files that have been modified in the last N days. For example, to copy only files that have been modified in the last 7 days, you would use the --max-age option along with the number of days, like this:

rsync --ignore-existing --max-age=7 -av source/ destination/

Copy Files By Size with Rsync

It’s also possible to specify only to copy the files that are larger or smaller than a certain size using --size-range option, which takes the argument of either +SIZE or -SIZE. For example, if you want to copy only files that are larger than 100MB, you would use the --size-range option like this:

rsync --ignore-existing --size-range='+100M' -av source/ destination/

There are also many other options available with rsync that can be used to further fine-tune the file transfer process. For example, you can use the --exclude option to exclude certain files or directories from the transfer, or the --dry-run option to see what files would be copied without actually performing the transfer.

Conclusion

In conclusion, the rsync command is a powerful tool for copying files and directories and can be used to copy only the files that are missing or have been modified in the destination location. By using the various options available with rsync, you can further fine-tune the file transfer process to suit your specific needs.

The post Rsync Command to Copy Missing Files (Examples) appeared first on TecAdmin.

]]>
https://tecadmin.net/rsync-command-to-copy-missing-files-only/feed/ 0
(Resolved) MySQL connection error: certificate verify failed https://tecadmin.net/mysql-connection-error-certificate-verify-failed/ https://tecadmin.net/mysql-connection-error-certificate-verify-failed/#respond Tue, 10 Jan 2023 03:00:35 +0000 https://tecadmin.net/?p=33812 The SSL connection error: error:0A000086:SSL routines::certificate verify failed error is usually encountered when establishing an SSL connection to a MySQL server. I was configuring the replication between two MySQL servers running with MySQL version 8.0. After configuring the replication, the “SHOW SLAVE STATUS” command on the slave instance shows me the following error: Last_IO_Error: error [...]

The post (Resolved) MySQL connection error: certificate verify failed appeared first on TecAdmin.

]]>
The SSL connection error: error:0A000086:SSL routines::certificate verify failed error is usually encountered when establishing an SSL connection to a MySQL server. I was configuring the replication between two MySQL servers running with MySQL version 8.0. After configuring the replication, the “SHOW SLAVE STATUS” command on the slave instance shows me the following error:

Last_IO_Error: error connecting to master ‘repl@107.189.159.252:3306’ – retry-time: 60 retries: 3 message: SSL connection error: error:0A000086:SSL routines::certificate verify failed

Then I tried to connect the Master server from the slave using the command line, with the client certificate. Again I received the following error with the connection:

mysql -h 192.168.1.100 -u repl_user -p --ssl-ca=/etc/mysql/certs/ca.pem --ssl-cert=/etc/mysql/certs/client-cert.pem --ssl-key=/etc/mysql/certs/client-key.pem 
Output
Enter password: ERROR 2026 (HY000): SSL connection error: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed

Possible Causes

This error can be occurred due to several reasons. Here are some possible causes:

  • The MySQL server’s SSL certificate is not trusted by the client because it is self-signed or not signed by a certificate authority (CA) that is trusted by the client.
  • The MySQL server’s SSL certificate has expired.
  • The MySQL server’s SSL certificate is not properly configured.
  • The client is using an old version of the MySQL client library that does not support the server’s SSL certificate.

Solution

  1. Check if both system clocks are synchronized.
  2. Next verify the client and server certificate with the CA file and make sure everything is OK. Use the following command to verify the certificates:
    openssl verify -CAfile ca-cert.pem server-cert.pem client-cert.pem 
    
    server-cert.pem: OK
    client-cert.pem: OK
    
  3. Make sure to set a different “Common Name (FQDN)” for the CA certificate and the master/client certificate.
  4. Check the state of the SSL/TLS variables by typing. Make sure the correct certificate is used by the server.
    SHOW VARIABLES LIKE '%ssl%'; 
    
    Output
    +-------------------------------------+----------------------------------+ | have_openssl | YES | | have_ssl | YES | | ssl_ca | /etc/mysql/certs/ca-cert.pem | | ssl_capath | | | ssl_cert | /etc/mysql/certs/server-cert.pem | | ssl_cipher | | | ssl_crl | | | ssl_crlpath | | | ssl_fips_mode | OFF | | ssl_key | /etc/mysql/certs/server-key.pem | | ssl_session_cache_mode | ON | | ssl_session_cache_timeout | 300 | +-------------------------------------+----------------------------------+ 27 rows in set (0.01 sec)
  5. Finally make sure that you are using the correct database username, hostname, and password to connect.

Conclusion

In conclusion, the `SSL connection error: error:0A000086:SSL routines::certificate verify failed error` can occur when establishing an SSL connection to a MySQL server for several reasons, including an untrusted or expired SSL certificate, a misconfigured SSL certificate, or an outdated MySQL client library. To resolve this error, you can import the server’s SSL certificate into the client’s trust store, renew the SSL certificate, check the server’s SSL configuration, or upgrade the MySQL client library to a newer version that supports the server’s SSL certificate.

The post (Resolved) MySQL connection error: certificate verify failed appeared first on TecAdmin.

]]>
https://tecadmin.net/mysql-connection-error-certificate-verify-failed/feed/ 0
Top 5 Shared Hosting Providers for Small Businesses https://tecadmin.net/shared-hosting-providers/ https://tecadmin.net/shared-hosting-providers/#respond Tue, 10 Jan 2023 02:22:58 +0000 https://tecadmin.net/?p=33851 Shared hosting is a type of web hosting service where multiple websites are hosted on the same server. Each website is allocated a certain amount of resources, such as storage space and bandwidth, which it can use to host its content and serve its visitors. It is a popular and cost-effective option for small businesses [...]

The post Top 5 Shared Hosting Providers for Small Businesses appeared first on TecAdmin.

]]>
Shared hosting is a type of web hosting service where multiple websites are hosted on the same server. Each website is allocated a certain amount of resources, such as storage space and bandwidth, which it can use to host its content and serve its visitors. It is a popular and cost-effective option for small businesses that want to launch a website. With shared hosting, your business’ website will be hosted on the same server as other websites, which helps to lower costs.

Pros & Cons of Shared Hosting

There are several pros to using shared hosting:

  • It is cost-effective: Shared hosting is generally much cheaper than other types of hosting, such as dedicated hosting or VPS hosting. This makes it a good option for small businesses and startups that are working with a tight budget.
  • It is easy to use: Shared hosting is generally very easy to set up and use, even for those with little technical experience. Most shared hosting providers offer a control panel that allows you to manage your website and hosting account easily.
  • It is flexible: Shared hosting is flexible in that it can accommodate websites of various sizes and traffic levels. This makes it a good option for businesses that are just starting out and may not have a lot of traffic yet, as well as businesses that have grown and may need more resources.

There are also some cons to using shared hosting:

  • Limited resources: Because multiple websites are hosted on the same server, the resources available to each website are limited. This means that if your website starts to receive a lot of traffic, it may not be able to handle it all and could slow down or crash.
  • Security risks: Because multiple websites are hosted on the same server, there is a higher risk of security breaches. If one website on the server is hacked, it could potentially affect all of the other websites on the server as well.
  • Lack of control: With shared hosting, you do not have as much control over your hosting environment as you would with other types of hosting, such as dedicated hosting. This means that you may not be able to customize certain aspects of your hosting setup as much as you would like.

Top 5 Shared Hosting Providers for Small Businesses

There are many shared hosting providers to choose from, so it can be difficult to determine which one is the best fit for your small business. To help you make a decision, here are the top 5 shared hosting providers for small businesses:

1. Bluehost:

Bluehost is a well-known and reliable shared hosting provider that is popular among small businesses. They offer a variety of hosting plans to meet the needs of different types of websites, including plans for beginners and more advanced users. Bluehost also has a user-friendly control panel and excellent customer support.

Visit >> http://www.bluehost.com

2. HostGator:

HostGator is another popular shared hosting provider that is known for its affordability and easy-to-use control panel. They offer a variety of hosting plans, including plans for beginners and more advanced users. HostGator also has a 99.9% uptime guarantee, which means that your website will be available to visitors almost all of the time.

Visit >> http://www.hostgator.com

3. SiteGround:

SiteGround is a shared hosting provider that is known for its fast loading speeds and excellent customer support. They offer a variety of hosting plans, including plans for beginners and more advanced users. SiteGround also has a 99.9% uptime guarantee, so you can be confident that your website will be available to visitors almost all of the time.

Visit >> https://www.siteground.com/

4. A2 Hosting:

Hosting is a shared hosting provider that is known for its fast loading speeds and excellent customer support. They offer a variety of hosting plans, including plans for beginners and more advanced users. A2 Hosting also has a 99.9% uptime guarantee, so you can be confident that your website will be available to visitors almost all of the time.

Visit >> https://www.a2hosting.com/

5. InMotion Hosting:

Hosting is a shared hosting provider that is known for its fast loading speeds and excellent customer support. They offer a variety of hosting plans, including plans for beginners and more advanced users. InMotion Hosting also has a 99.9% uptime guarantee, so you can be confident that your website will be available to visitors almost all of the time.

Visit >> https://www.inmotionhosting.com/

Wrap Up

Overall, these are the top 5 shared hosting providers for small businesses. They offer a variety of hosting plans to meet the needs of different types of websites, have user-friendly control panels, and excellent customer support. They also have a high uptime guarantee, so you can be confident that your website will be available to visitors almost all of the time.

The post Top 5 Shared Hosting Providers for Small Businesses appeared first on TecAdmin.

]]>
https://tecadmin.net/shared-hosting-providers/feed/ 0
How to Install Python3 on Pop!_OS {3 Methods} https://tecadmin.net/how-to-install-python3-on-popos/ https://tecadmin.net/how-to-install-python3-on-popos/#respond Mon, 09 Jan 2023 09:50:01 +0000 https://tecadmin.net/?p=33356 Pop!_OS is a popular operating system based on Ubuntu, and like most operating systems, it comes with a default version of Python installed. However, you may want to install a newer version of Python or multiple versions of Python on your system for different purposes. Python is a popular programming language that is widely used [...]

The post How to Install Python3 on Pop!_OS {3 Methods} appeared first on TecAdmin.

]]>
Pop!_OS is a popular operating system based on Ubuntu, and like most operating systems, it comes with a default version of Python installed. However, you may want to install a newer version of Python or multiple versions of Python on your system for different purposes.

Python is a popular programming language that is widely used in many fields, including data science, web development, and scientific computing. Pop!_OS is a popular operating system based on Ubuntu, and like most operating systems, it comes with a default version of Python installed. However, you may want to install a newer version of Python or multiple versions of Python on your system for different purposes.

In this article, we will explore three methods for installing Python 3 on Pop!_OS: using the Pop!_OS package manager, using `deadsnakes` PPA, and building Python from the source.

Method 1 – Using default package manager

Pop!_OS comes with a package manager called “apt” (Advanced Package Tool) that allows you to install and manage software packages. To install the latest version of Python using apt, you can use the following command:

sudo apt install python3 

This will install Python 3 and its associated package manager “pip3” (Python Package Index), which you can use to install additional Python packages.

Method 2 – Using PPA (Personal Package Archive)

To install Python 3 on Pop!_OS using a Personal Package Archive (PPA), you can follow these steps:

  1. Open a terminal and update the package and install the software-properties-common package, which provides the “add-apt-repository” command that you will use to add the PPA:
    sudo apt update && sudo apt install software-properties-common -y
    
  2. Add the `deadsnakes` PPA, which provides updated versions of Python:
    sudo add-apt-repository ppa:deadsnakes/ppa 
    
  3. Update the package list again to include the packages in the PPA and then install Python 3 using the apt package manager:
    sudo apt update && sudo apt install python3.11 
    

    Replace “3.11” with the desired version of Python.

  4. Verify that Python 3 was installed correctly by running the following command:
    python3 --version 
    

    You should see the version of Python that you installed.

Note that using a PPA is not the recommended method for installing Python on Pop!_OS, as it can introduce compatibility issues and security risks. It is generally better to use the package manager or Anaconda distribution to install Python.

Method 3 – Building Python from source

If you want to install a specific version of Python or customize your Python installation, you can build Python from source. To do this, you will need to download the source code from the Python website (https://www.python.org/downloads/) and follow the instructions in the “Building Python from source” section of the documentation (https://docs.python.org/3/using/unix.html#building-python).

  1. Download the required Python version
    https://www.python.org/ftp/python/3.11.1/Python-3.11.1.tgz 
    
  2. Extract the downloaded archive file
    tar xzf Python-3.11.1.tgz -C /usr/src 
    
  3. Switch to the extracted directory
    cd /usr/src/Python3.11.1 
    
  4. Build the Python source code and install it.
    ./configure 
    make 
    make install 
    
  5. Once the build and installation are completed successfully, verify the installed Python version.
    python3.11 --version 
    

Building Python from source can be a more advanced option, as it requires you to have a compiler and other dependencies installed on your system.

Regardless of which method you choose, it is important to note that Python 2 is no longer actively developed and it is recommended to use Python 3 for all new projects.

Conclusion

In this article, we have discussed three methods for installing Python 3 on Pop!_OS: using the Pop!_OS package manager, using the Anaconda distribution, and building Python from the source. Each method has its own advantages and drawbacks, and the appropriate method will depend on your specific needs and preferences. Using the Pop!_OS package manager or Anaconda distribution is generally the easiest and most reliable way to install Python while building Python from source allows for more customization and control.

Regardless of which method you choose, it is important to note that Python 2 is no longer actively developed and it is recommended to use Python 3 for all new projects.

The post How to Install Python3 on Pop!_OS {3 Methods} appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-install-python3-on-popos/feed/ 0
Git Change Remote URL to SSH (from HTTPS) https://tecadmin.net/git-change-remote-url-to-ssh-from-https/ https://tecadmin.net/git-change-remote-url-to-ssh-from-https/#respond Thu, 05 Jan 2023 13:25:46 +0000 https://tecadmin.net/?p=33659 Git is a distributed version control system that is widely used for tracking changes in source code during software development. It allows developers to collaborate on projects and keep track of their changes without the need for a central repository. One way to access a Git repository is via SSH (Secure Shell). SSH is a [...]

The post Git Change Remote URL to SSH (from HTTPS) appeared first on TecAdmin.

]]>
Git is a distributed version control system that is widely used for tracking changes in source code during software development. It allows developers to collaborate on projects and keep track of their changes without the need for a central repository.

One way to access a Git repository is via SSH (Secure Shell). SSH is a network protocol that provides a secure way to communicate with a remote computer over an unsecured network. Using SSH can be more secure and efficient than other methods, such as HTTP or HTTPS, for accessing Git repositories.

If you want to change the URL of a remote repository in your local Git repository to use SSH, here are the steps to follow:

Prerequisites

Before you can change the remote URL to use SSH, you will need to do the following:

  1. Generate an SSH key pair. This consists of a private key and a public key. The private key is kept on your local machine, and the public key is uploaded to the remote repository.
  2. Add your public key to the remote repository. This allows your local machine to securely connect to the remote repository using the private key.

If you are not familiar with generating SSH keys or adding a public key to a remote repository, you can find more information and instructions in the Git documentation or online tutorials.

Changing the Remote URL

Once you have generated an SSH key pair and added your public key to the remote repository, you can change the remote URL in your local Git repository as follows:

  1. Open a terminal window (Git Bash on Windows, or any terminal emulator on macOS or Linux).
  2. Change to the directory that contains the local Git repository.
  3. Run the following command to view the current remote repository URL:
    git remote -v 
    

    This will display a list of all the remote repositories that are linked to your local repository, along with their URL.

  4. To change the URL of a specific remote repository to use SSH, use the following command:

    # Syntax
    git remote set-url <remote> <user>@<host>:<path>

    Replace <remote> with the name of the remote repository (usually origin), <user> with your username on the remote host, <host> with the hostname or IP address of the remote host, and <path> with the path to the Git repository on the remote host.

    For example, to change the URL of the origin repository to “git@github.com:username/repo.git”, you would run the following command:

    git remote set-url origin git@github.com:username/repo.git 
    
  5. Verify that the URL has been changed by running the `git remote -v` command again. You should see the new SSH URL listed for the specified remote repository.

That’s it! The remote URL for your local Git repository should now be changed to use SSH. You should now be able to push and pull changes to and from the remote repository using the git push and git pull commands as usual.

I hope this helps! Let me know if you have any questions or need further clarification on any of the steps.

The post Git Change Remote URL to SSH (from HTTPS) appeared first on TecAdmin.

]]>
https://tecadmin.net/git-change-remote-url-to-ssh-from-https/feed/ 0
Docker system prune: A Detailed Guide to Remove Unused Objects https://tecadmin.net/docker-system-prune/ https://tecadmin.net/docker-system-prune/#respond Wed, 04 Jan 2023 09:51:44 +0000 https://tecadmin.net/?p=33587 Docker is a popular containerization platform that allows you to package, deploy, and run applications in a container. As you use Docker, you may accumulate a large number of images, containers, and volumes that take up space on your system. The `docker system prune` command allows you to remove unused data from your Docker system, [...]

The post Docker system prune: A Detailed Guide to Remove Unused Objects appeared first on TecAdmin.

]]>
Docker is a popular containerization platform that allows you to package, deploy, and run applications in a container. As you use Docker, you may accumulate a large number of images, containers, and volumes that take up space on your system. The `docker system prune` command allows you to remove unused data from your Docker system, including stopped containers, dangling images, and unused networks and volumes.

In a production environment, it is important to carefully consider the implications of using the `docker system prune`, as it can potentially remove data that is still in use. In this article, we will go over considerations for using docker system prune in a production environment.

In this article, we will go over best practices for using the `docker system prune` command to keep your Docker system clean and efficient.

Common Questios About Docker System Prune

As we know the `docker system prune` is a destructive process, that can’t be undone. So should be careful before running it. Here are some common questions, that can be in your mind about this command.

  • What does docker system prune do?
  • Docker system prune removes unused data from your Docker system. By default, it removes stopped containers, dangling images, and unused networks and volumes. This can help free up space on your system and keep your Docker system clean and organized.

  • Can I use docker system prune in production?
  • Using docker system prune in a production environment requires careful consideration and planning. It is important to understand the data that will be removed and use filters to selectively remove data. It is also recommended to test the command in a staging or development environment before deploying it to production.

  • Can I Use the --force Flag with docker system prune?
  • The docker system prune command has a --force flag that allows you to bypass the prompt and automatically removes unused data. While this can be convenient, it is important to use the --force flag carefully, as it can remove items that you may still need.

  • Is docker system prune the same as docker system prune?
  • Yes, docker system prune and docker system prune are the same command. Docker system prune is the older syntax for the command, while docker system prune is the newer, recommended syntax.

  • How do I see a list of items that will be removed before running the docker system prune?
  • The commands show a little info about what to remove but not shows what sites are removed. So you have to check it manually it like: `docker image ls --filter dangling=true`

  • Can I undo a docker system prune?
  • Once docker system prune has removed data from your system, it cannot be undone. It is important to use caution when running the command and only remove data that you are sure is no longer needed.

Deleting Unused Data with Docker System Prune

To use docker system prune, you can simply run the `docker system prune` command. This will remove all stopped containers, dangling images, unused networks, and dangling build cache.

docker system prune 
Docker system prune command
Docker system prune command

You can also use the --all flag to remove all unused data, For example, to remove all stopped containers, images (Not attached to any container), and all build cache.

docker system prune --all 
Docker system prune all unused objects
Docker system prune all unused objects

The above command will still not remove any volumes. If you also want to remove unused volumes, that are not used by any container, use the following command:

docker system prune --all --volumes 

Deleting Specific Docker Objects Only

Instead of running the prune command for all objects, you can also run it for specific objects only. Here is the examples of prune commands for specific objects.

  • `docker container prune`: This will remove all stopped containers.
  • `docker images prune`: This will remove all dangling images.
  • `docker images prune --all`: This will remove all images which are not associated with any container.
  • `docker volume prune`: This will remove all volumes which are not associated with any container.
  • `docker network prune`: This will remove all networks which are not associated with any container.

Using the --force Flag Carefully

The docker system prune command has a --force flag that allows you to bypass the prompt and automatically removes unused data. While this can be convenient, it is important to use the --force flag carefully, as it can remove items that you may still need.

The above commands will prompt for confirmation, but if you want to bypass this confirmation, just use the --force flag with the command.

docker system prune --force 

It is recommended to only use the --force flag when you are confident that you want to remove all unused data. If you are not sure, you can omit the --force flag and review the list of items that will be removed before deciding whether to proceed.

Conclusion

The `docker system prune` command is a useful tool for keeping your Docker system clean and efficient. By regularly pruning your system and using filters to selectively

Using a docker system prune in a production environment requires careful consideration and planning. It is important to understand the data that will be removed, use filters to selectively remove data, and test the command before deploying it to production. By following these best practices, you can effectively use docker system prune to keep your Docker system clean and efficient in a production environment.

The post Docker system prune: A Detailed Guide to Remove Unused Objects appeared first on TecAdmin.

]]>
https://tecadmin.net/docker-system-prune/feed/ 0
Docker exec: Running Commands in a Docker Container https://tecadmin.net/docker-exec/ https://tecadmin.net/docker-exec/#respond Wed, 04 Jan 2023 02:48:32 +0000 https://tecadmin.net/?p=33579 Docker is a popular containerization platform that allows you to package, deploy, and run applications in a container. The `docker exec` command allows you to run commands in a running Docker container. This can be useful for debugging, testing, and administering containers. In this article, we will go over how to use the docker exec [...]

The post Docker exec: Running Commands in a Docker Container appeared first on TecAdmin.

]]>
Docker is a popular containerization platform that allows you to package, deploy, and run applications in a container. The `docker exec` command allows you to run commands in a running Docker container. This can be useful for debugging, testing, and administering containers. In this article, we will go over how to use the docker exec command to run commands inside a running Docker container.

Running Commands in a Container

To run a command inside a Docker container, you can use the docker exec command followed by the container ID or container name, and the command you want to run.

For example, to run the ls command in a container with the ID “abcd12345”, you can use the following command:

docker exec abcd12345 ls 

To run the ls command in a container with the name “mycontainer”, you can use the following command:

docker exec mycontainer ls 

You can also run commands that take arguments by specifying the arguments after the command. For example, to run the `ls` command with the `-l` flag in a container with the ID “abcd12345 “, you can use the following command:

docker exec abcd12345 ls -l 
Running Command in Docker Container without Login
Running Command in Docker Container without Login

You can find the container id and name using `docker ps` command.

Running a Shell in a Container

You can also run a shell in a Docker container by specifying the shell executable as the command. For example, to run a bash shell in a container with the ID “abcd12345”, you can use the following command:

docker exec -it abcd12345 bash 

The `-it` flag is used to allocate a pseudo-TTY and run the command in interactive mode. This allows you to enter commands in the shell and see the output.

Access Docker Container  Shell with Docker exec
Access Docker Container Shell with Docker exec

You can also specify a different shell executable, such as csh, fish, dash, or zsh.

Running a Command as a Different User

By default, the docker exec command runs the command as the root user. However, you can specify a different user to run the command using the `-u` flag.

For example, to run the ls command as the www-data user in a container with the ID “abcd12345”, you can use the following command:

docker exec -u www-data abcd12345 ls 

Conclusion

The `docker exec` command is a useful tool for running commands in a Docker container. It allows you to debug, test, and administer containers from the command line. By understanding how to use the docker exec command, you can easily run commands in a Docker container and manage your containers more effectively.

The post Docker exec: Running Commands in a Docker Container appeared first on TecAdmin.

]]>
https://tecadmin.net/docker-exec/feed/ 0