Discover DevOps roles and learn Linux from basics to advanced at DevOpsRoles.com. Detailed guides and in-depth articles to master Linux for DevOps careers.
This tutorial covers how to record Linux terminal commands using the scriptcommand.
This command allows you to record and replay all the activity in your terminal.
Using scriptcommands can be especially helpful when you want to create a tutorial for a set of commands.
Record Linux Terminal Commands
The script command can be run without any arguments
script
A new capturing session will start. your terminal session is saved to ./typescipt in your working directory. When you’re done, press Ctrl+D or type the exit command to drop out of the sub-shell.
The output terminal is as follows
[vagrant@localhost ~]$ script
Script started, file is typescript
[vagrant@localhost ~]$ ls
share typescript
[vagrant@localhost ~]$ whoami
vagrant
[vagrant@localhost ~]$ exit
exit
Script done, file is typescript
[vagrant@localhost ~]$
[vagrant@localhost ~]$ cat typescript
Script started on Sat 18 Sep 2021 08:59:49 PM +07
[vagrant@localhost ~]$ ls
share typescript
[vagrant@localhost ~]$ whoami
vagrant
[vagrant@localhost ~]$ exit
exit
Script done on Sat 18 Sep 2021 09:00:09 PM +07
[vagrant@localhost ~]$
You can specify a different file with a script that commands an argument:
script session_`hostname`_`whoami`
The following is the output from the terminal command:
[vagrant@localhost ~]$ script session_`hostname`_`whoami`
Script started, file is session_localhost.localdomain_vagrant
[vagrant@localhost ~]$ cat /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)
[vagrant@localhost ~]$ exit
Script done, file is session_localhost.localdomain_vagrant
[vagrant@localhost ~]$
Appending to an Existing File
Use -a flag to append your commands.
script -a session_`hostname`_`whoami`
Conclusion
You have Record Linux Terminal Commands. I hope will this your helpful. Thank you for reading the DevopsRoles page!
This tutorial covers how to manage and monitor swap on Linux, including how to determine the amount of swap space available and how much is currently in use.
Swap space plays an important role in system performance, so it’s crucial to understand how to manage it effectively.
How much swap on Linux do you need?
The recommendation is to swap the space used to double your RAM. If your system has a lot of memory, you may never need to use swap space.
In this tutorial, how to deploy a React Application using our own Ubuntu Server and Nginx. You can quickly deploy react Applications using the default Create React App build tool.
Prerequisites
VPS Ubuntu 21.04. I use Linode is Cloud Hosting High-performance SSD Linux servers.
Nginx: Lightweight and high-performance Web server or Reverse Proxy
On your local machine: you will need a development environment running node.js.
A registered domain name. And setup DNS records for your server.
An A record with your_domain pointing to your server’s public IP address.
An A record with www.your_domain pointing to your server’s public IP address.
Deploy a React Application with Nginx on Ubuntu 21.04
Your local machine
Step 1 — Creating a React Project
npx create-react-app react-deploy
cd react-deploy
npm start
Open a browser and navigate to http://localhost:3000.
Step 2: Build production
npm run build
Your VPS
Step 3: Uploading build files to VPS
Use scp command uploading build files to /var/www/your_domain/html directory on VPS.
Discover how to remove orphaned packages on CentOS Linux in this detailed tutorial. Orphaned packages, which are remnants not needed for package dependencies, can clutter your system.
Learn the step-by-step process to clean up these unnecessary files effectively, enhancing your CentOS system’s performance and reliability. Orphaned packages are all packages that no longer serve the purpose of package dependencies.
Now, we remove Orphaned packages using the yum remove command to remove the entire list:
yum remove `package-cleanup --leaves`
The output terminal is as below:
[root@centos7 ~]# yum remove `package-cleanup --leaves`
Loaded plugins: fastestmirror
No Match for argument: Loaded
No Match for argument: plugins:
No Match for argument: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package cryptsetup-libs.x86_64 0:1.7.4-3.el7_4.1 will be erased
---> Package libicu.x86_64 0:50.2-4.el7_7 will be erased
---> Package libicu62.x86_64 0:62.2-1.el7.remi will be erased
---> Package libmemcached.x86_64 0:1.0.16-5.el7 will be erased
---> Package libsysfs.x86_64 0:2.1.0-16.el7 will be erased
---> Package libtool-ltdl.x86_64 0:2.4.2-22.el7_3 will be erased
---> Package libunwind.x86_64 2:1.2-2.el7 will be erased
---> Package libuv.x86_64 1:1.40.0-1.el7 will be erased
---> Package libwebp.x86_64 0:0.3.0-7.el7 will be erased
--> Finished Dependency Resolution
Dependencies Resolved
==============================================================================================================================================================================================================
Package Arch Version Repository Size
==============================================================================================================================================================================================================
Removing:
cryptsetup-libs x86_64 1.7.4-3.el7_4.1 @updates 947 k
libicu x86_64 50.2-4.el7_7 @updates 24 M
libicu62 x86_64 62.2-1.el7.remi installed 31 M
libmemcached x86_64 1.0.16-5.el7 @base 677 k
libsysfs x86_64 2.1.0-16.el7 @anaconda 146 k
libtool-ltdl x86_64 2.4.2-22.el7_3 @base 66 k
libunwind x86_64 2:1.2-2.el7 @base 150 k
libuv x86_64 1:1.40.0-1.el7 @epel 378 k
libwebp x86_64 0.3.0-7.el7 @base 371 k
Transaction Summary
==============================================================================================================================================================================================================
Remove 9 Packages
Installed size: 57 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Erasing : libmemcached-1.0.16-5.el7.x86_64 1/9
Erasing : 2:libunwind-1.2-2.el7.x86_64 2/9
Erasing : 1:libuv-1.40.0-1.el7.x86_64 3/9
Erasing : libicu-50.2-4.el7_7.x86_64 4/9
Erasing : libtool-ltdl-2.4.2-22.el7_3.x86_64 5/9
Erasing : libicu62-62.2-1.el7.remi.x86_64 6/9
Erasing : libsysfs-2.1.0-16.el7.x86_64 7/9
Erasing : cryptsetup-libs-1.7.4-3.el7_4.1.x86_64 8/9
Erasing : libwebp-0.3.0-7.el7.x86_64 9/9
Verifying : libwebp-0.3.0-7.el7.x86_64 1/9
Verifying : cryptsetup-libs-1.7.4-3.el7_4.1.x86_64 2/9
Verifying : libsysfs-2.1.0-16.el7.x86_64 3/9
Verifying : libicu62-62.2-1.el7.remi.x86_64 4/9
Verifying : libtool-ltdl-2.4.2-22.el7_3.x86_64 5/9
Verifying : libicu-50.2-4.el7_7.x86_64 6/9
Verifying : 1:libuv-1.40.0-1.el7.x86_64 7/9
Verifying : 2:libunwind-1.2-2.el7.x86_64 8/9
Verifying : libmemcached-1.0.16-5.el7.x86_64 9/9
Removed:
cryptsetup-libs.x86_64 0:1.7.4-3.el7_4.1 libicu.x86_64 0:50.2-4.el7_7 libicu62.x86_64 0:62.2-1.el7.remi libmemcached.x86_64 0:1.0.16-5.el7 libsysfs.x86_64 0:2.1.0-16.el7
libtool-ltdl.x86_64 0:2.4.2-22.el7_3 libunwind.x86_64 2:1.2-2.el7 libuv.x86_64 1:1.40.0-1.el7 libwebp.x86_64 0:0.3.0-7.el7
Complete!
[root@centos7 ~]#
Conclusion
Remove orphaned packages from CentOS systems is an essential step in maintaining the efficiency and stability of your server. Orphaned packages are remnants left behind after uninstalling software that no longer serve any functional purpose. By eliminating these unnecessary files, you can optimize system performance and prevent potential conflicts. This guide on DevopsRoles aims to assist you in cleaning up your CentOS installation effectively. We hope you find these instructions beneficial. Thank you for choosing DevopsRoles for your technological needs and for trusting us with your system optimization tasks. Your continued support inspires us to provide helpful and practical content.
Combining PowerShell with Git Bash can enhance your productivity by allowing you to use Unix-like commands within a Windows environment. In this guide, we’ll show you how to call Git Bash commands from PowerShell, using an example script. We’ll cover everything from basic setups to advanced configurations. In this tutorial, How to call the git bash command from Powershell. For example, git bash content to split CSV files on windows :
Setting Up Your Environment
Installing Git Bash
First, ensure you have Git Bash installed on your system. Download it from the official Git website and follow the installation instructions.
Adding Git Bash to Your System PATH
To call Git Bash command from PowerShell, add Git Bash to your system PATH:
Open the Start menu, search for “Environment Variables,” and select “Edit the system environment variables.”
Click the “Environment Variables” button.
Under “System variables,” find and select the “Path” variable, then click “Edit.”
Click “New” and add the path to the Git Bash executable, typically C:\Program Files\Git\bin.
Call the git bash command from Powershell
Save the following script as split.sh in your K:/TEST directory:
#!/bin/bash
cd $1
echo split start
date
pwd
split Filetest.CSV Filetest -l 20000000 -d
ls -l
for filename in $1/*; do
wc -l $filename
done
date
echo split end
exit
This script performs the following tasks:
Changes the directory to the one specified by the first argument.
Prints a start message and the current date.
Displays the current directory.
Splits Filetest.CSV into smaller files with 20,000,000 lines each.
Lists the files in the directory.
Counts the number of lines in each file in the directory.
Prints the current date and an end message.
Exits the script.
PowerShell Script
Create a PowerShell script to call the split.sh script:
Yes, you can automate Git Bash scripts by scheduling PowerShell scripts or using task automation features in PowerShell.
Conclusion
By following this guide, you can easily call Git Bash command from PowerShell, enabling you to leverage the strengths of both command-line interfaces. Whether you’re performing basic operations or advanced scripting, integrating Git Bash with PowerShell can significantly enhance your workflow. Thank you for reading the DevopsRoles page!
lsof command meaning “List open files“. This command will not find CentOS7/RHEL. We will install lsof command example as below:
$ sudo yum install lsof
In the realm of Linux administration, understanding the tools at your disposal is key to effective system management. The lsof command, which stands for “List Open Files”, is an indispensable utility that provides crucial visibility into the system’s file usage. By listing information about files opened by processes, lsof helps administrators manage resources, troubleshoot system issues, and ensure secure operations. This guide aims to demystify the lsof command through practical examples, enhancing your system management toolkit.
Basic Usage
lsof
This will display a list of all open files and the processes that are using them.
List User-Specific Opened Files. This will display a list of all open files that are being used by the specified user.
$ lsof -u huupv
Search by PID
$ lsof -p 1
Exclude User with ^ Character
$ lsof -i -u^root
List TCP Port ranges 8000-9000
$ lsof -i TCP:8000-9000
Conclusion
The lsof command is a powerful tool in the Linux administrator’s arsenal, offering deep insights into the system’s interaction with files. From tracking down process-specific files to managing system resources, lsof facilitates a wide range of administrative tasks.
By mastering its usage through the examples provided, you enhance your capabilities in system management, contributing to the overall efficiency and security of your operations. Dive into these examples to leverage lsof effectively, ensuring your Linux systems run smoothly and securely. I hope will this your helpful. Thank you for reading the DevopsRoles page!
OS Centos 6 is the default Python version 2. How to Install Python 3.6 on Centos 6. Python is a powerful and flexible programming language widely used in various fields such as web development, data science, artificial intelligence, and DevOps. Python 3.6 brings many improvements and new features, enhancing performance and security.
In this article, we will guide you through the process of installing Python 3.6 on CentOS 6, one of the popular Linux operating systems for server environments. This installation will allow you to take full advantage of Python 3.6 in your projects.
cd /tmp/
wget https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tgz
tar xzf Python-3.6.6.tgz
cd Python-3.6.6
./configure --enable-optimizations
sudo make altinstall
[huupv2@server1 ~]$ cat .bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
alias python='/usr/bin/python3.6'
Check Python version 3.6 on Centos 6
[huupv2@server1 ~]$ python
Python 3.6.6 (default, Mar 8 2021, 14:41:43)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-23)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
[huupv2@server1 ~]$
Conclusion
You have to install Python 3.6 on Centos 6. Installing Python 3.6 on CentOS 6 may present some challenges, but with this detailed guide, you can easily accomplish it. Python 3.6 will open up many new opportunities for your projects, from web application development to data processing and automating DevOps workflows.
We wish you success in installing and leveraging the full potential of Python 3.6 on CentOS 6. If you encounter any difficulties, don’t hesitate to contact us or refer to community support resources. I hope will this your helpful. Thank you for reading the DevopsRoles page!
How to install and configure jira on Centos. Installing and configuring JIRA on CentOS involves a series of systematic steps to set up this popular project management tool effectively. Begin by preparing your CentOS system with the necessary prerequisites, including Java. Then, download and install the JIRA software from Atlassian’s official site. Configuration involves setting up a database, typically PostgreSQL or MySQL, and adjusting the JIRA setup wizard to connect to your newly prepared database. This process ensures that JIRA runs smoothly on CentOS, providing a robust platform for managing your projects. Now, let’s proceed with the JIRA installation and configuration on CentOS.
[jira@DevopsRoles jira]$ wget https://product-downloads.atlassian.com/software/jira/downloads/atlassian-jira-software-8.13.4-x64.bin
[jira@DevopsRoles jira]$ ls -l
total 399948
-rw-rw-r--. 1 jira jira 409545222 Feb 15 11:02 atlassian-jira-software-8.13.4-x64.bin
[jira@DevopsRoles jira]$ chmod u+x atlassian-jira-software-8.13.4-x64.bin
[jira@DevopsRoles jira]$ ./atlassian-jira-software-8.13.4-x64.bin
The result is as follows:
[jira@DevopsRoles jira]$ ./atlassian-jira-software-8.13.4-x64.bin
Unpacking JRE ...
Starting Installer ...
You do not have administrator rights to this machine and as such, some installation options will not be available. Are you sure you want to continue?
Yes [y, Enter], No [n]
y
This will install Jira Software 8.13.4 on your computer.
OK [o, Enter], Cancel [c]
o
Click Next to continue, or Cancel to exit Setup.
Choose the appropriate installation or upgrade option.
Please choose one of the following:
Express Install (use default settings) [1], Custom Install (recommended for advanced users) [2, Enter], Upgrade an existing Jira installation [3]
1
Details on where Jira Software will be installed and the settings that will be used.
Installation Directory: /home/jira/atlassian/jira
Home Directory: /home/jira/atlassian/application-data/jira
HTTP Port: 8080
RMI Port: 8005
Install as service: No
Install [i, Enter], Exit [e]
i
Extracting files ...
Please wait a few moments while Jira Software is configured.
Installation of Jira Software 8.13.4 is complete
Start Jira Software 8.13.4 now?
Yes [y, Enter], No [n]
y
Please wait a few moments while Jira Software starts up.
Launching Jira Software ...
Installation of Jira Software 8.13.4 is complete
Your installation of Jira Software 8.13.4 is now ready and can be accessed
via your browser.
Jira Software 8.13.4 can be accessed at http://localhost:8080
Finishing installation ...
[jira@DevopsRoles jira]$
mysql -u root -p
mysql> CREATE DATABASE jiradb CHARACTER SET utf8 COLLATE utf8_bin;
mysql> CREATE USER 'jiradb'@'localhost' IDENTIFIED BY 'Abc123!@#';
mysql> GRANT ALL PRIVILEGES ON jiradb.* TO 'jiradb'@'localhost' WITH GRANT OPTION;
we need a JDBC connector driver for MySQL
[jira@DevopsRoles ~]$ cd && mkdir tmp
[jira@DevopsRoles ~]$ cd tmp/
[jira@DevopsRoles tmp]$ wget http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.29.tar.gz
[jira@DevopsRoles tmp]$ tar xfp mysql-connector-java-5.1.29.tar.gz
[jira@DevopsRoles tmp]$ find mysql-connector-java-5.1.29 -name "mysql-connector-java-*-bin.jar"
mysql-connector-java-5.1.29/mysql-connector-java-5.1.29-bin.jar
[jira@DevopsRoles tmp]$ cp mysql-connector-java-5.1.29/mysql-connector-java-5.1.29-bin.jar ~/atlassian/jira/lib/
[jira@DevopsRoles tmp]$ cd
In this tutorial, How To Install Apache cassandra on Centos 6. Apache Cassandra is a NoSQL database for storing large amounts of data in a decentralized, high availability server cluster.
Step 1: Install Java
I will install Oracle java 7 instead of OpenJDK. Link download Oracle Java 7 here
rpm -ivh /home/huupv/jdk-7u79-linux-x64.rpm
I find both executable files – OpenJDK and Oracle:
find / -name "java" -type f
Check java version
java -version
Setting up the default JDK
alternatives --config java
Step 2: Install Apache cassandra
Cassandra will be installed from the Datastax repository. Create a repository file:/etc/yum.repos.d/datastax.repo
[datastax]
name = DataStax Repo for Apache Cassandra
baseurl = http://rpm.datastax.com/community
enabled = 1
gpgcheck = 0
Find the version
yum list dsc2*
Install
yum install dsc21
Start and add to the auto-launch:
service cassandra start
chkconfig cassandra on
Check
cqlsh
nodetool status
Conclusion
You have to Install Apache Cassandra on Centos 6. I hope will this your helpful. Thank you for reading the DevopsRoles page!