Hands on activity with basic Linux commands and Apache installation

Linux - Introduction

Similar to the Windows and Mac OS, the Linux is the best-known and most-used open source operating system. Users can modify and create distinctions of the source code, known as distributions, for computers and other devices. 

Linux is mostly used in as a server, but it is also used in desktop computers, smartphones, e-book readers and gaming consoles, etc. Currently the most popular Linux (& server) distributions are:
  • Red Hat Enterprise Linux
  • Ubuntu Server/Ubuntu Linux
  • CentOS
  • SUSE Enterprise Linux.
  • Linux Mint
  • Arch Linux
  • Deepin
  • Fedora
  • Debian etc.

Some of the above server distributions are free (such as Ubuntu Server and CentOS) and some have an associated price (such as Red Hat Enterprise Linux and SUSE Enterprise Linux).

In fact, the Linux is considered as the best operating system in all leading IT industries today for project development and deployment. Henceforth it is very necessary for all of us to learn how to work on Linux.

Let's learn the basic but must know Linux commands.

ls - Listing Files

It shows a list of all the files and directories present in the current working directory of your machine.  

cd – Change Directory

“cd” is change directory, with the help of this command, you can easily navigate to the directory of your choice at any moment of time.

The 'Man' Command

Man stands for manual which is a reference book of a Linux operating system. It is similar to HELP file found in different software. 

For an example, if we type man ls and hit enter; terminal would give us information on ls command –

touch – Create File

This command creates an empty file with the specified name in the present working directory.

cat – Creating & Viewing File

The 'cat' command is used to display text files. It can also be used for copying, combining and creating new text files.

To create a new file, use the command as -
  • cat > filename
  • Add content
  • Press 'ctrl + d' to return to command prompt.

The syntax to combine 2 files is -
cat file1 file2 > newfilename

mkdir - Creating Directories

It will create a subdirectory in your present working directory, or you can create using a different path also.

You can also create more than one directory at a time, via passing different names.

rmdir - Removing Directories

It will remove the suggested directory, make ensure no file / sub-directory under the directory that you want to delete. 

mv – Moving and Renaming File

This Linux command allows user to move file to another location.
mv filename destination

mv command needs super user permission. Currently, we are executing the command as a standard user. Sudo program allows regular users to run programs with the security privileges of the superuser or root.

If you use this command with a new filename in the same directory, then it will rename the file.

history – History Command

History command shows all the commands that you have been executed in the past for the current terminal session. It can be beneficial to refer to the old commands and re-utilized again.

apt – Installing Software

In windows, the installation of a program is done by running the setup.exe file, but in case of Linux, the installation files are distributed as packages. You can use the apt commands to install or remove a package. 

The Apache HTTP Server is a freely-available Web server software package that is distributed under an open source license. It is designed to create web servers that have the ability to host one or more HTTP-based websites.

Let's install Apache server – 

STEP - 1
Start by updating the local package index to reflect the latest upstream changes – 
sudo apt update

STEP - 2
Next thing, install the apache2 package – 
sudo apt install apache2

You can see a list of the application profiles using the ufw command as – 
sudo ufw app list

STEP - 3
Next make firewall active and enable the system.

sudo ufw enable

sudo ufw allow 'Apache'
sudo ufw status

STEP - 4
Time to verify the Apache Web Server, to make sure the service is running – 
sudo systemctl status apache2

STEP - 5
You can execute your server IP address over the browser, it will display default Ubuntu 18.04 Apache web page – (for example in my case).

1 comment:

  1. Thanks for sharing basic command in linux and good for a starter. Thanks for sharing. I started learning cat command and it’s all options very interesting.