How to use ChatGPT with the API in the Linux command line interface

Exercises to complete: Obtain an API key Make sure that you have the OpenAI Python client installed Create a python 3 script Create a Bash script Make scripts executable and run the Bash script To be able to run chatGPT in command line, you can follow these steps. Please note that you need to have sudo privileges or root access. Obtain an API key To use the OpenAI API, you need an API key. If you don’t have one, you can sign up on the OpenAI website and create a new API key. ...

May 25, 2023 · 3 min · 527 words · sysadmin

How to install Docker

Exercises to complete: Update your system Add the Docker repository and refresh repositories if needed Install Docker Enable and start Docker service Verify the Docker installation To install Docker, you can follow these steps. Please note that you need to have sudo privileges or root access. SLES Debian RedHat SLES 15 / openSUSE Leap 15.4 Update your system: Firstly, make sure your package list and the system is up to date. 1 2 sudo zypper refresh sudo zypper update Install Docker: Now, you can install Docker with the following command. 1 sudo zypper install docker Enable and start Docker service: After the installation, you need to start Docker and enable it to start at boot. 1 2 sudo systemctl enable docker sudo systemctl start docker Verify the Docker installation: To ensure Docker has been installed correctly, you can check the installed version of Docker. 1 docker --version This should display the version of Docker installed on your system. You can also run a simple Docker command such as: 1 sudo docker run hello-world This command downloads a test image and runs it in a container. If it runs without errors, it’s a good indication that Docker is functioning correctly. Remember, in order to run Docker commands as a non-root user without prepending sudo, you need to add the user to the docker group: 1 sudo usermod -aG docker $USER Then you need to log out and log back in so that your group membership is refreshed. That’s it! You have successfully installed Docker. Debian 11 To install Docker on Debian 11, follow these steps: Step 1: Update the System First, update your existing list of packages: 1 sudo apt update Next, upgrade the packages: 1 sudo apt upgrade -y Step 2: Install the Necessary Software Docker requires some packages that are not installed by default, including packages to allow apt to use a repository over HTTPS: 1 sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release -y Step 3: Add Docker’s GPG Key Next, add Docker’s official GPG key: 1 2 3 sudo install -m 0755 -d /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg sudo chmod a+r /etc/apt/keyrings/docker.gpg Step 4: Set up the Docker Stable Repository Then, use the following command to set up the stable Docker repository: 1 2 3 4 echo \ "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \ "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null Step 5: Install Docker CE (Community Edition) Update the apt package list and install the latest version of Docker CE: 1 2 sudo apt update sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y Step 6: Verify the Docker Installation Finally, verify that Docker CE is installed correctly by running the hello-world Docker image: 1 sudo docker run hello-world This command downloads a test image and runs it in a container. If it runs successfully, it prints an informational message and exits. You should now have Docker installed on your Debian 11 system. If you want to run Docker commands as a non-root user without prepending sudo, you’ll need to add your user to the docker group: 1 sudo usermod -aG docker ${USER} You may need to log out and back in for these changes to take effect. Red Hat 9 Red Hat Enterprise Linux 9 has removed Docker from its official repositories. However, you can still install Docker using other methods. One such alternative is using Podman, which is a daemonless container engine for developing, managing, and running OCI Containers on your Linux System. Containers can either be run as root or in rootless mode. If you want to install Docker, here is a way to do it: Setup the repository: 1 sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo Install Docker Engine: 1 sudo dnf install docker-ce docker-ce-cli containerd.io Start Docker: 1 sudo systemctl start docker Verify that Docker Engine is installed correctly by running the hello-world image: 1 sudo docker run hello-world Enable Docker to start on boot: 1 sudo systemctl enable docker Please note that the installation process might slightly differ based on the exact version of your RHEL system and the system setup. If any of the steps does not work as expected, refer to the Docker official documentation. Remember that using Docker requires root privileges so make sure to use sudo with Docker commands, or give Docker these privileges correctly. If you want to use a more RHEL native solution, consider using Podman and Buildah. These tools provide similar functionalities to Docker but are designed with a different architecture that doesn’t require a daemon and run as a normal user. Also, be aware that running the Docker daemon on your system can have security implications; you should understand these before deciding to use Docker. ...

May 24, 2023 · 4 min · 791 words · sysadmin

Web Server - Nginx

Exercises to perform: Install Nginx. Enable and start Nginx. Add a port to firewalld. Create a simple website. Check if the page displays correctly using the IP address. Install Nginx SLES Debian RedHat SLES To install Nginx, type: # refresh repositories sudo zypper ref # install Nginx sudo zypper -n in nginx # enable Nginx at system startup sudo systemctl enable nginx # start Nginx sudo systemctl start nginx Debian To install Nginx, type: # refresh repositories sudo apt update # install Nginx sudo apt -y install nginx # enable Nginx at system startup sudo systemctl enable nginx # start Nginx sudo systemctl start nginx Red Hat To install Nginx, type: # install Nginx sudo yum install nginx -y or sudo dnf install nginx -y # enable Nginx at system startup sudo systemctl enable nginx # start Nginx sudo systemctl start nginx ...

April 21, 2023 · 2 min · 384 words · admin

Web Server - Apache2

Exercises to complete: Install Apache2 Enable and start Apache2 Add a port to firewalld Create a simple website Check does the website display correctly using IP address Install Apache2 SLES Debian RedHat SLES To install Apache2 type: # refresh repositories sudo zypper ref # install Apache2 sudo zypper -n in apache2 # enable Apache2 on boot sudo systemctl enable apache2 # start the Apache2 sudo systemctl start apache2 Debian To install apache2 type: # refresh repositories sudo apt update # install apache2 sudo apt -y install apache2 # enable apache2 on boot sudo systemctl enable apache2 # start the apache2 sudo systemctl start apache2 Red Hat To install apache2 type: sudo yum install httpd -y or sudo dnf install httpd -y # enable apache2 on boot sudo systemctl enable httpd # start the apache2 sudo systemctl start httpd ...

April 6, 2023 · 2 min · 347 words · admin

SSH server

Exercises to complete: generate an RSA key pair using ssh-keygen export the public key from the client to the server using ssh-copy-id log in with the password via ssh to the server and switch to the root account using the sudo - su or sudo -i command enable key login and disable password login. Save the changes and restart the ssh service. do not close the current session. Open a new ssh session and log in to the server with your private key. if you have successfully logged in, secure the server using the information below and then restart the ssh service on the second session. remember to keep the first ssh session open all the time so you can undo changes if necessary. restart the ssh service and check if you can log in with the third session to the server. If so, you have successfully configured the ssh server correctly. if you are willing, write a script using sed or awk to make server-side changes to the sshd_config file so that you don’t have to manually apply the changes. OpenSSH : KeyBoard-Intereractive Auth OpenSSH is already installed by default, so it’s not necessarry to install new packages. You can login with KeyBoard-Intereractive Authentication by default, but change some settings for security like follows. ...

April 1, 2023 · 12 min · 2430 words · sysadmin

Welcome to the Sysadmin blog

Hi, What follows is history. More than 3 years have passed since then. Is that a lot or a little? For me it has changed a lot, as I managed to move to the third line at Fujitsu and worked more than a year in the Linux team and then moved to Research and Development, where I now work as Quality Assurance, but basically my work is still related to Linux, only that I now work with SLES and open SUSE. At home, I currently have a Raspberry Pi 4b rev 1.4 with 8 GB RAM and a 120 GB SSD, on which Debian 11, Home Assistant Supervised and a couple of other things are installed, and a Fujitsu Esprimo Q920 with 16 GB RAM and a 512 GB SSD, on which I have Proxmox with virtual machines such as a multi-node Wazuh cluster though, and Portainer, which I use to quickly put up Docker containers. I’ve managed to get through installing the system on several VPS I’ve purchased. I’ve set up a mail server on Postfix as well as Dovecot, Dovecot Sieve, Postgrey, SpamAssassin, ClamAV, etc. I also installed Apache and Nginx, which I then secured, so called hardening. I learned about OpenvSwitch, Qemu KVM, Proxmox, ESXi, Zabbix, Zephyr Enterprise, Jenkins, Selenium Grid, Confluence, Jira and many other tools and solutions. I have gone through the management of old machines such as Solaris, SCO_SV, old CentOS and Red Hat (versions 4, 5, 6, 7). I’ve learned a lot of things and I’m still learning. I am not standing still. I’m developing the Technology Stack. I’m learning AWS and how to configure environments that are already more advanced in terms of security. I don’t program, although writing code in Java, Python, Bash, C is not a problem for me. It’s just that programming is not my passion. My passion is Linux and the extensive security associated with it. OSINT, although I know it, is not something I do either, because it’s not a challenge for me and it’s not my role to seek people out over the Internet. If someone has more knowledge than me, but does not respect me, is not cultured and hides behind an illness, which I have personally encountered, in addition, shows elementary deficiencies in reading with understanding, is a dinosaur and presses SELinux or AppArmor to beginners, this person has nothing to look for here. Netiquette such a person should have learned at the very beginning, because it is the basis of the Internet. Let’s respect each other, because this is the way to professionalism. Plus the ability to control one’s own emotions, and the quote of Master Yoda “Do or do not, there is no try” - is the road to success. ...

March 19, 2023 · 3 min · 594 words · sysadmin

How to install properly a virtual machine in QEMU KVM

In this video I explained how to properly install the QEMU KVM virtual machine. I provided two methods of installation and described in details how to make it work. preallocation=metadata – allocates the space required by the metadata but doesn’t allocate any space for the data. This is the quickest to provision but the slowest for guest writes. Read the article: https://www.jamescoyle.net/how-to/181… ...

October 25, 2022 · 1 min · 67 words · sysadmin

How to fix QEMU KVM virtual machine network configuration through the xml

In this video I explained the QEMU KVM network configuration issue connected with type direct and provided a solution by editing a configuration in xml file

October 22, 2022 · 1 min · 26 words · sysadmin

Issue with a type direct in QEMU KVM network configuration explained

In this video I explained the QEMU KVM network configuration issue connected with type direct. Manual for virt-install command: https://www.mankier.com/1/virt-install#Networking_Options

October 22, 2022 · 1 min · 20 words · sysadmin

How to install QEMU KVM and configure virtual machine in openSUSE 15.4

How to install QEMU KVM and configure virtual machine in openSUSE 15.4

October 17, 2022 · 1 min · 12 words · sysadmin