Tag Archives: CentOs

How to run a command on Startup on Linux (works on CentOS & Ubuntu)

Hi there,

In this example I had a need to record boot up times in a file that i could access easily. To do so I decided to run a command on startup. This tutorial tool place on CentOS but the commands should also work on Ubuntu.

Step 1

Edit the rc.local file in vi by running:

sudo vi /etc/rc.local

Step 2

Add the following line to the file, update the home directory to represent your home directory.

  • Press i to go into insert mode
  • Enter the line:
    • echo “the computer booted up at” `date` >> /home/darren/bootup.log
  • Press ESC and then wq! and enter to save and quit the file.

Step 3

Give the executable  permission to the rc.local file by running the following command:

chmod +x /etc/rc.d/rc.local

Step 4

Reboot the system by running:

sudo init 6

Step 5

When the machine reboots run the following command to insure the file has been created and that there is content in the file:

cat /home/darren/bootup.log

A full video tutorial can be found here:

How to statically assign DNS in CentOS 7

You can statically assign DNS in Centos 7. In this example we will assign Googles DNS, which is:

8.8.8.8

8.8.44

To begin we will first edit the our internet adaptor, do so run the command:

sudo vi /etc/sysconfig/network-scripts/ifcfg-enpXXX

in our case we ran

 sudo vi /etc/sysconfig/network-scripts/ifcfg-enp0s3

We changed the line

PEERDNS=yes

to:

PEERDNS=no

 

Next we need to edit the resolv.conf file:

 sudo vi /etc/resolv.conf

nameserver 8.8.8.8

nameserver 8.8.4.4

 

How to RDP (Remote Desktop) into CentOS 7

Hi There,

In this tutorial I will show you how to RDP into your CentOS 7 Server. This tutorial will also work on a Redhat 7 server. In order to follow this tutorial you will need to be sure that you have CentOS 7 installed with the GNOME Desktop. If you haven’t done this yet be sure to follow this tutorial to get up to speed.

The first thing that we need to do is to add two repos to our CentOS server. The two commands that you need to run are:

  1. sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm
  2. sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm

Next we will install the xrdp software package and then start it as a service. The commands to do this are:

  1. sudo yum -y install xrdp tigervnc-server
  2. Sudo systemctl start xrdp.service

Now we need to allow the ports for xrdp through the firewall. After that we’ll need to restart the firewall service. This can be done by running these commands.

  1. sudo firewall-cmd –permanent –zone=public –add-port=3389/tcp
  2. sudo firewall-cmd –reload

Finally we need to configure SELinux. To do so run these two commands:

  1. sudo chcon –type=bin_t /usr/sbin/xrdp
  2. sudo chcon –type=bin_t /usr/sbin/xrdp-sesman

We can now try to RDP to our CentOS 7 server.

First open RDP and type in the IP address of you CentOS 7 Server.

If you get certificate warnings click yes to continue.

Now enter your CentOS username and password

You will now be brought to your CentOS Desktop.

 

 A full video of this tutorial can be seen here:

How to reset the root password on CentOS 7 / Redhat 7 (RHEL 7)

This tutorial will show you how to reset the root password on CentOs 7 / Redhat 7. As a health warning please be sure that when doing this you have taken a snapshot of your VM or if it’s a physical server that you follow the instructions very carefully. With that in mind lets get started.

Step 1

When the system boots up press e on this screen.

Step 2

In the screen that appears scroll down to the line were you see Linux 16

Now Change where its says ro to:

rw init=/sysroot/bin/sh

Then press ctrl + x

Step 3

You will now be in emergency mode which will look like the screen below:

Step 4

Type in the command:

chroot /sysroot

Step 5

Reset the root password by typing in:

passwd root

Step 6

No ensure that selinux will be relabelled by typing the command:

touch /.autorelabel

Step 7

Type in:

exit

Step 8

Now reboot by typing in:

reboot

How to Install CentOS 7 On VMware Workstation 12

In this tutorial you will learn how to install CentOS 7 on VMWare workstation 12. The first thing that you need to do to Install CentOS 7 is to download CentOS 7 from the CentOS website:

https://www.centos.org/download/

The version that you will need to download is the DVD ISO. Once you have downloaded the CentOS7 ISO, you will need to open VMWare workstation.

Once VMWare workstation is open you will then need to follow the following steps to ensure that CentOS 7 is installed.

  • Click file and then New Virtual Machine.
  • Then click typical and next.
  • Find the ISO file you saved and click next.
  • Give your machine a name and click next.
  • Set your disk size and click next.
  • Click customise hardware.
  • Increase the RAM to 2GB
  • Then click close and finish.
  • Then power on the CentOS 7 machine.
  • Select install CentOs 7.
  • Select your language and click next.
  • Select Gnome Desktop for Software Selection and then done.
  • Select the disk you created for installation destination and then done.
  • Then click begin install.
  • Next create your root password and click done.
  • Then create your user, create a password for that user and select make that user an administrator.
  • Then click reboot.
  • Accept the license on start up and click finish configuration.
  • You have now installed Centos 7 On VMWare.
  • The video guide below shows the process in more detail.

 

How to install Joomla 3 on CentOs 7 /Redhat 7 Linux.

This tutorial shows you how to install Joomla 3 on CentOS 7 / Redhat 7 Linux (RHEL).It shows you first how to download, unzip and move the Joomla files to the correct directory for apache.

 

Next it shows you how to download and install php including the php-mysqli extension that is needed by Joomla. You will then see how to configure Apache to see the Joomla files.

 

Next you will then configure permissions and set up your Joomla Database in MYSQL (MariaDB) Finally you will install Joomla.

 

 

The commands that you need to follow along with this tutorial are:

 

Downloading, Unzipping and Moving Joomla:

 

sudo Wget https://downloads.joomla.org/cms/joomla3/3-8-3/Joomla_3-8-3-Stable-Full_Package.zip?format=zip
Sudo mkdir Joomla
Sudo mv Joomla_3-8-3-Stable-Full_Package.zip\?format\=zip Joomla
Cd Joomla
Sudo unzip Joomla_3-8-3-Stable-Full_Package.zip\?format\=zip Joomla
Sudo rm Joomla_3-8-3-Stable-Full_Package.zip\?format\=zip
Sudo mv Joomla /var/www/html

 

Installing PHP

 

Sudo yum install php
Sudo yum install php-mysqli

 

Configuring Apache and Permissions  

 

Sudo vi /etc/httpd/conf/httpd.conf
Sudo service httpd restart
Sudo chown apache:apache -R /var/www/html/Joomla
Sudo chcon -Rv –type=httpd_sys_rw_content_t /var/www/html

Configuring MYSQL / MariaDB

 

Mysql -u root -p
Create database joomla;
grant all on joomla.* to ‘darren’@’localhost’ identified by ‘password123’;

 

 

How to Install Drupal 8 on CentOs 7 / Redhat (RHEL) 7

This video describes the process of installing Drupal 8 on CentOS 7. This tutorial takes place on a CentOS 7 machine but the commands will also work on a Redhat (RHEL) 7 Machine.

 

The commands that you need to follow along with this tutorial are:

 

  • sudo wget https://ftp.drupal.org/files/projects/drupal-8.4.2.tar.gz
  • sudo tar -zxvf drupal-8.4.2.tar.gz
  • sudo mv drupal-8.4.2 /var/www/html/
  • sudo mv drupal-8.4.2/ drupal
  • sudo chcon -R –type=httpd_sys_rw_content_t /var/www/html/
  • sudo chown apache:apache /var/www/html
  • sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
  • sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
  • sudo yum install php70w
  • sudo service httpd restart
  • sudo yum install php70w-dom
  • sudo yum install php70w-gd
  • sudo yum install php70w-pdo
  • sudo service httpd restart

 

 

 

How to Install PHP 7 on CentOs 7 / Redhat 7 (RHEL)

This tutorial shows you how to install PHP 7 on CentOS 7.

 

This tutorial is on an CentOS 7 machine but the commands will also work on Redhat (RHEL) 7.

 

The commands that you need to follow along with this tutorial are:

 

  • sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
  • sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
  • sudo yum install php70w
  • sudo yum install php70w-pdo

How to Connect To Linux (CentOs 7) Using SSH Keys (Password free authentication) from Windows

This video shows how to log into a CentOs 7 server from a Windows machine using SSH keys. The video will show you how to generate the keys using Putty and then how to configure your CentOS 7 Server to allow you to authenticate into the server.

Putty is available to download from www.putty.org.

The commands that you need to follow along with the tutorial are:

sudo mkdir ~/.ssh
sudo chmod 700 ~/.ssh
sudo vi ~/.ssh/authorized_keys
sudo chown YourUserName:YourUserName ~/.ssh -R
sudo chmod 600 ~/.ssh/authorized_keys

Vim: How to create, save and exit a file

Vim has a reputation as a difficult file editor. However it’s quite easy once you know how to use it. This quick tutorial steps through how to create, save and exit a file using Vim and it only takes 5 minutes to step through.

To create a new file using Vim, type the following into your terminal:

vi newfile

You will now see a screen similar to the one below.

The first thing we need to do is enter insert mode. This will allow us to enter text into our file. To enter insert mode press i

Notice at the bottom of the screen it now says insert.

We can now add some text into our file, type hello world.

Now we want to save our file but to do this we first need to exit insert mode. You can do this by pressing Esc.

Notice that the insert at the bottom of the screen is gone. Now type :wq!  (w is for write and q is to quit) and then click enter.

That’s it! You have now created, edited and saved a file using Vim.