Posts

Showing posts from July, 2018

Run bash script on boot time on centos

How to Auto Execute Commands/Scripts During Reboot or Startup on centos . Many method to execute a command or run scripts during startup. Method 1: Linux Execute Cron Job After System Reboot Use @reboot in cron scheduler. It will run once, at startup after reboot your system. Edit crontab # crontab -e To run a script called /home/huuphan/auto_excute.sh @reboot /home/huuphan/auto_excute.sh Method 2: Using /etc/rc.d/rc.local file This method is vaild for systemd-based distributions. To grant execute permission to /etc/rc.d/rc.local # chmod +x /etc/rc.d/rc.local And add your script at the bottom of the file /etc/rc.d/rc.local # echo "/home/huuphan/auto_excute.sh" >> /etc/rc.d/rc.local Conclusion In this article, how to Run bash script on boot time on centos. Use two method: Crontab and /etc/rc.d/rc.local file.

Linux create user Using `useradd`

Image
Introduction Learn how to create and configure a user in Linux using the `useradd` command. This comprehensive guide covers creating a user, assigning groups, and configuring sudo privileges without a password. Managing user accounts is a fundamental task for any Linux system administrator. Whether you are setting up a new server or adding users to an existing system, understanding how to create and configure users efficiently is crucial. In this tutorial, we will explore how to use the `useradd` command to create a new user in Linux, assign them to specific groups, and enable them to execute sudo commands without requiring a password. Why Use `useradd` for User Creation? The `useradd` command is a powerful tool that allows system administrators to create user accounts with specific options such as User ID (UID), Group ID (GID), home directory, shell, and more. Unlike graphical user interfaces, `useradd` provides a streamlined way to automate user creation through scripts, making it i...

Shell script parse xml in linux

Image
How to use shell script parse xml file . In this tutorial, I will use grep command, awk command and sed command Reading xml file extracting value in linux . For example xml person file as below <person>   <sex>Male</sex>   < firstname >Huu</ firstname >   <lastname>Phan</lastname>   <sex>female</sex>   < firstname >Miranda</ firstname >   <lastname>Kerr</lastname> </person> How to extracting value Huu and Miranda  of < firstname > < /firstname > Use grep command [huupv@huupv huuphan.com]$ grep -oP '(?<=<firstname>).*(?=</firstname)' person.xml Use awk command [huupv@huupv huuphan.com]$ awk -F "[><]" '/firstname/{print $3}' person.xml Use sed command [huupv@huupv huuphan.com]$ sed -n '/firstname/{s/.*<firstname>//;s/<\/firstname.*//;p;}' person.xml  The result, Shell script parse xml in linux

rename command in linux

Image
rename command similar with mv command. This command is slightly more advanced than mv  command. How to rename multiple files in linux. The syntax rename command rename [options] expression replacement-file For example, basic use rename command [huupv@huupv huuphan.com]$  rename file huu file1.txt The same output How to rename all file extension .txt to .atxt file [huupv@huupv huuphan.com]$ rename .txt .atxt *.txt The same output Use option --verbose in rename command [huupv@huupv huuphan.com]$ rename -v foo huu foo?.atxt The same ouput `foo2.atxt' -> `huu2.atxt' `foo3.atxt' -> `huu3.atxt' Details more information rename command man rename

How to setup OpenVPN Server on Centos 7

Introduction Learn how to set up an OpenVPN server on CentOS 7 with this comprehensive step-by-step guide. Ensure your network's security and privacy with one of the most reliable VPN solutions available. Perfect for both beginners and advanced users. Setting up a secure and reliable VPN is essential for ensuring privacy and data protection, especially in today's increasingly interconnected world. OpenVPN is one of the most trusted and robust VPN solutions available, providing a high level of security and flexibility for both businesses and individual users. This guide will walk you through the process of setting up an OpenVPN server on CentOS 7, offering step-by-step instructions to help you establish a secure connection that meets your specific needs. Step 1: Prepare install OpenVPN server sudo yum update -y sudo yum install epel-release -y sudo yum update -y sudo yum install -y openvpn easy-rsa Configure Ip forwarding for OpenVPN Server vim /etc/sysctl.conf The c...

Failed to create the VirtualBox COM object solve problem

Image
Someday, your Virtualbox not start and the display error "Failed to create the VirtualBox COM object". it got somewhat corrupted. The error of Virtualbox "Failed to create the VirtualBox COM object" as below: Location: '/home/huupv/.config/VirtualBox/VirtualBox.xml' , line 1 (0), column 1. /home/vbox/vbox-5.2.14/src/VBox/Main/src-server/VirtualBoxImpl.cpp[554] (nsresult VirtualBox::init()). How to solve problem! Step 1: make sure process VBoxSVC not running Step 2: make a copy file VirtualBox.xml then delete original file. Step 3: Rename VirtualBox.xml-prev file to VirtualBox.xml file. Step 4: try again start VirtualBox. To check not running process VBoxSVC not running use ps command as below: $ ps -ef | grep VBoxSVC huupv 10122 2421 0 22:19 pts/1 00:00:00 grep --color=auto VBoxSVC To check VirtualBox.xml file and Delete VirtualBox.xml file $ ll /home/huupv/.config/VirtualBox/ | grep VirtualBox.xml -rw-----...

How to connect openvpn server from a linux computer

Image
Connect access server (VPS) from a linux computer. In this tutorial, I will access server VPS installed OpenVPN server from a linux computer. Ref to How to setup OpenVPN Server on Centos 7 Install openvpn client on linux Run Openvpn client with .ovpn file for example: client.ovpn Install OpenVPN client on linux  Fedora/CentOS/RedHat client sudo yum install openvpn Ubuntu/Debian client sudo apt-get install openvpn Checking Openvpn client version [huupv@huupv ~]$ openvpn --version The output as below: OpenVPN 2.4.6 x86_64-redhat-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on Apr 26 2018 library versions: OpenSSL 1.1.0h-fips  27 Mar 2018, LZO 2.08 Running the OpenVPN client linux computer with the downloaded client config ovpn file: [huupv@huupv vpn-client-01-config]$ sudo openvpn --config client.ovpn The output OpenVPN client linux connect to server OpenVPN server as below: Sun Jul  1 21:43:35 2018 TUN/TAP de...