The article helps you to understand /etc/services file in Linux. Learn about content, format & importance of this file.
Internet daemon is an important service in the Linux world. It takes care of all network services with the help of /etc/services file. In this article, we will walk you through the content, format of this file, and what it means to a Linux system.
/etc/services file contains a list of network services and ports mapped to them. inetd or xinetd looks at these details so that it can call a particular program when a packet hits respective port and demand for service.
As a normal user, you can view this file since the file is world-readable. To edit this file you need to have root privileges.
Last two fields are optional hence denoted in [] where –
service-name is the name of the network service. e.g. telnet, FTP, etc.
port/protocol is the port being used by that network service (numerical value) and protocol (TCP/UDP) used for communication by service.
alias is an alternate name for service.
a comment is a note or description you can add to service. Starts with # mark
Sample /etc/services file
# Each line describes one service, and is of the form:
#
# service-name port/protocol [aliases ...] [# comment]
tcpmux 1/tcp # TCP port service multiplexer
rje 5/tcp # Remote Job Entry
echo 7/udp
discard 9/udp sink null
Here, you can see the use of optional last two fields as well. discard service has an alternate name as sink or null.
Learn to install LAMP in RHEL. Linux, Apache, Mysql/MariaDB, Php/PHPmyadmin i.e. LAMP is a complete application stack used for development, testing & hosting dynamic websites.
LAMP is an application stack which helps you to develop, test, and host dynamic website. You can test dynamic applications as well with this stack. Basically LAMP stands for Linux Apache Mysql/MariaDB and PHP/PHPMyadmin.
Linux gives a kernel platform on which the rest of the stack runs. Apache provides your web-server which is front-end for your application or website. Mysql/MariaDB is a database you could use for data on your site or app. PHP is as you know server-side strong scripting language just fit for web application development.
Without any further delay, let’s run through commands to setup and configure your LAMP stack. For the demonstration, I will be using RHEL 7 on AWS here to setup LAMP.
Setting Linux in LAMP
Nothing to tell you here! Having a Linux server already pass you through this. Here are a few installations articles from our factory.
Check and make sure you get Apache welcome page in the browser after entering the IP address of the server. Open port 80 in Linux firewall, network firewall, or AWS security group if necessary.
Secure your MariaDB setup by running below command –
root@kerneltalks # /usr/bin/mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] Y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] n
... skipping.
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] Y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] Y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
Now you are running the MySQL database i.e. MariaDB and secured it too. You can test by connecting to database and running simple command –
root@kerneltalks # mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 18
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> SELECT VERSION();
+----------------+
| VERSION() |
+----------------+
| 5.5.60-MariaDB |
+----------------+
1 row in set (0.00 sec)
Setting up PHP in LAMP
Install PHP to complete this step. Install PHPMyAdmin if you are planning to host a dynamic website using CMS like WordPress.
root@kerneltalks # yum install php
You can test sample PHP code like one below by placing it in /var/www/html (default webserver directory)
It will shows PHP information in web browser when you hit http://ip-address/php_info.php
How to list PHP extensions in Linux
You can check active PHP modules using the below command. If an extension is missing you need to install its corresponding package on the system. Generally, it follows naming convention like PHP-extension i.e. for curl extension you need to search and install php-curl or phpX-curl where X is PHP version
# php -m
[PHP Modules]
Core
ctype
date
dom
filter
hash
iconv
json
libxml
mbstring
mysqli
mysqlnd
pcre
PDO
pdo_mysql
pdo_sqlite
Reflection
session
SimpleXML
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zlib
[Zend Modules]
That’s it. You have a working web server (Apache), Database (MariaDB), and web development scripting language (PHP) running on Linux! Complete LAMP stack is at your service!
Learn how to install Apache 9 in Linux like RedHat, CentOs, Suse, OEL etc.
This is a quick post to a list of steps for Apache Tomcat 9 installation on Linux. Let’s start with download the software. Get your Apache Tomcat 9 from the official download page.
Apache being a webserver is part of LAMP stack. Red more about LAMP here.
First download core binary file from the official download page. Use tools like wget to download a file right on your server itself.
Now extract the tarball. You will have apache-tomcat-9.0.14 directory after unzipping.
root@kerneltalks # tar -xvf apache-tomcat-9.0.14.tar.gz
Now move the directory or its content to your required directory where you want your Apache Tomcat binaries should stay & you are done. For demonstration, I moved them in /opt
root@kerneltalks # mv apache-tomcat-9.0.14 /opt
You have startup.sh and shutdown.sh scripts in the bin directory. Test them and you are all set. If you do not have java installed on your server, you will see below error while you try to start Apache.
root@kerneltalks # cd /opt/apache-tomcat-9.0.14/bin
root@kerneltalks # sh startup.sh
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program
Install java package using your package manager according to Linux you use. The package installation will set the above variables automatically. Then you can try starting Apache again.
root@kerneltalks # ]# sh startup.sh
Using CATALINA_BASE: /opt/apache-tomcat-9.0.14
Using CATALINA_HOME: /opt/apache-tomcat-9.0.14
Using CATALINA_TMPDIR: /opt/apache-tomcat-9.0.14/temp
Using JRE_HOME: /
Using CLASSPATH: /opt/apache-tomcat-9.0.14/bin/bootstrap.jar:/opt/apache-tomcat-9.0.14/bin/tomcat-juli.jar
Tomcat started.
And here you go. Your Apache instance is started with the default configuration. It listens on port 8080 by default. You can open your server IP in a browser and make sure you get default Apache page like below –
Learn how to install sar utility in SUSE Linux. Also, it lists commands to enable sar to collect monitoring data in the background.
sar is a monitoring utility mostly native to Linux. But with SUSE Linux you can not find sarpre-installed. There you will see an error like one below :
root@kerneltalks # sar
If 'sar' is not a typo you can use command-not-found to lookup the package that contains it, like this:
cnf sar
To make sar available on SUSE, you need to install package named sysstat. If you have zypper repo configured then you can directly run below command :
root@kerneltalks # zypper in sysstat
Refreshing service 'SUSE_Linux_Enterprise_Server_12_SP3_x86_64'.
Loading repository data...
Reading installed packages...
Resolving package dependencies...
The following NEW package is going to be installed:
sysstat
1 new package to install.
Overall download size: 358.7 KiB. Already cached: 0 B. After the operation,
additional 1.3 MiB will be used.
Continue? [y/n/...? shows all options] (y): y
Retrieving package sysstat-12.0.2-10.15.1.x86_64
(1/1), 358.7 KiB ( 1.3 MiB unpacked)
Retrieving: sysstat-12.0.2-10.15.1.x86_64.rpm ..............[done (160.0 KiB/s)]
Checking for file conflicts: .............................................[done]
(1/1) Installing: sysstat-12.0.2-10.15.1.x86_64 ..........................[done]
If zypper repo is not configured you can download appropriate rpm for your kernel version and install using rpm command. We used SUSE12SP3 here for a demonstration.
Once done you need to start sysstat service so that it will start collecting monitoring data in the background. Also, enable this service at boot so that after reboot it starts itself and keeps on collecting data in the background.
root@kerneltalks # systemctl enable sysstat
Created symlink from /etc/systemd/system/multi-user.target.wants/sysstat.service to /usr/lib/systemd/system/sysstat.service.
root@kerneltalks # systemctl start sysstat
That’s it. You have installed sar on SUSE Linux and started collecting monitoring data.
Learn how to disable GUI in SUSE Linux. Also, how to enable GUI at boot time in SUSE Linux.
Sometimes when installing with ISO you end up in booting the Suse Linux system in GUI mode. In this short article, we will walk you through how to disable GUI and how to enable GUI in Suse Linux.
For the demonstration, we used SUSE12 in this article. You can use system control systemctl to set the default for the next reboot. We will be using this feature to enable or disable GUI in SUSE Linux
Disable GUI in SUSE Linux
Note that, you will require downtime for this activity. You can disable GUI for the next reboot. So once you run the command you need to reboot your server. To disable GUI in SUSE Linux run below command –
kerneltalks:~ # systemctl set-default multi-user
Removed symlink /etc/systemd/system/default.target.
Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/multi-user.target.
This will set the system to boot into CLI mode only. Now reboot your server and you can see server boots into CLI.
Enable GUI in SUSE Linux
If you want to go back into GUI mode again, run below command –
kerneltalks:~ # systemctl set-default graphical
Removed symlink /etc/systemd/system/default.target.
Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/graphical.target.
Reboot the server and you will be back greeted with GUI login screen.
That’s it. You can toggle CLI or GUI using systemctl command. The only thing is you need a reboot each time you toggle.
Learn how to restart inetd service in Linux. Xinetd service is a replacement for inetd service in new Linux versions.
inetd is internet daemon. Inetd is responsible for internet services like telnet, pop3, ftp, etc. Whenever a packet comes over the network to a server on a particular port, inetd is responsible to check it and launch the appropriate program to handle the connection request. For checking port information and its related services it consults /etc/services file.
Below is a list of commands to manage inetd service. In newer systems inetd is replaced with more powerful daemon xinetd.
Start inetd service
# /etc/init.d/inetd start
Stop inetd service
# /etc/init.d/inetd stop
Restart inetd service
# /etc/init.d/inetd restart OR # killall -HUP inetd
All inetd configuration can be found in file /etc/inetd.conf
On newer systems, inetd is being replaced by xinetd. xinetd is an Extended internet daemon. If you fail to run above command your system probably runs xinetd as an inetd replacement. In that case, follow below commands –
Start inetd service
# service xinetd start
Stop inetd service
# service xinetd stop
Restart inetd service
# service xinetd restart
Check xinetd service state
root@kerneltalks # service xinetd status
● xinetd.service - Xinetd A Powerful Replacement For Inetd
Loaded: loaded (/usr/lib/systemd/system/xinetd.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2019-01-02 17:17:31 EST; 6s ago
Main PID: 17135 (xinetd)
Tasks: 1 (limit: 512)
CGroup: /system.slice/xinetd.service
└─17135 /usr/sbin/xinetd -stayalive -dontfork
All the services being handled by xinetd can be found under/etc/xinetd.d directory. Each service has its own configuration file under /etc/xinetd.d directory.
Learn how to configure a proxy in Linux flavors like RHEL, SUSE, OEL, CentOS, Ubuntu, etc.
One of the basic tasks after building a new system in your environment is to set up a proxy to enable internet access on the server. In this tutorial, we will walk you through step by step how to configure internet proxy in major Linux flavors like RHEL, SUSE, OEL, Centos, Ubuntu, etc. Without further delay lets jump in.
How to setup proxy in Linux using shell variables
Typically you can set up internet proxy details using shell variable http_proxy. The syntax is below –
The above proxy configuration is for the current user only. To configure a proxy for all users on the system, just add above command entry into /etc/profile file on your system and it will be applicable/available to all users on the system.
You can configure no_proxy hosts using the below command. no_proxy hosts are those destinations that you want to reach directly bypassing proxy for them.
How to setup proxy persistently using shell variable
It’s pretty much the same as above. The only thing is we are going to save this variable in /etc/environment. So every time anyone logs into the system, this proxy variable loaded into his/her login environment automatically.
yast is configuration manager native to SUSE Linux which gives nice text-based GUI in PuTTY terminal! If you are used to it, you can configure proxy from yast as well.
Navigate to Network Services -> Proxy
Check Enable Proxy using tab. It will allow you to fill in details below like server details, authentication, etc. Fill in details and you can test the configuration by selecting Test Proxy Settings. After successful testing select OK.
You can even mention hostnames, IPs under No Proxy Domainsso that they can be connected bypassing the proxy. This is very much helpful when you have internet and local network repos configured under zypper. By adding FQDN / IPof local patching server under No Proxy Domain you can reach a local patching server while the proxy is enabled.
You will be presented with the notice “It is recommended to relogin to make new proxy settings effective.” Re-login and test internet access.
How to setup proxy in RHEL using GUI
In RHEL, navigate to Application -> System Tools -> Settings -> Network
Select the Network Proxy and then Manual method.
Here fill in proxy server details along with port and you are good to go. Add hostnames or IPs in Ignore Hosts so that they can be connected bypassing the proxy. This is helpful when you have repo from the local server and internet configured under yum. By entering local patching server FQDN/ IP in Ignore Hostsyou can use local patching server in YUM while the proxy is enabled server-wide.
How to ignore proxy for local patching server in Linux
As I mentioned a couple of times above, here is a particular case you may face in your system. You have a repo manager like zypper is configured with repo from the internet and also from a local patching server (with FQDN). It’s the same as ‘No proxy for‘ or ‘Bypass proxy server for local addresses‘ setting in Windows.
Now when you enable proxy, internet repo works (via proxy) and local patching server repo won’t work. Since it tries to reach a local patching server over the internet and couldn’t do it (via proxy). If you disable proxy, your local patching repo will work and internet repo won’t.
In such a case, you need a local repo to bypass proxy and internet repo should go through the proxy. Here you can define local server FQDN/IP in Ignore Hosts or No Proxy Domains as I explained earlier.
From CLI, you can edit file /etc/sysconfig/proxy add entry in below line –
Learn how to install, configure and use cockpit web console in RHEL 8.
What is cockpit web console?
The cockpit is an open-source project aims at Red Hat Enterprise Linux web console using which system can be administered. Introduced in RHEL 7, Cockpit provides a user and device friendly web console to manage your systems. Being a web console, it can be accessed over mobile devices as well. Obviously CLI (Command Line Interface) is the wizard wand in sysadmin’s hand but sometimes small and quick changes can be done through this console. Cockpit is integrated systemd. Let’s see how to install the cockpit on RHEL.
How to install Cockpit web console in RHEL 8?
The cockpit is offered with a package of the same name. Install packagecockpit, using yum to install the Cockpit web console in RHEL 8. If YUM configuration is not in place on your system, you can always mount RHEL 8 BETA ISO and configure yum with this ISO as a repo. Below are commands for it –
[root@kerneltalks ~]# cat /etc/yum.repos.d/dvdiso.repo
[dvdiso]
name=RedHat DVD ISO
baseurl=file:///mnt/dvd/BaseOS/
enabled=1
gpgcheck=1
gpgkey=file:///mnt/dvd/BaseOS/RPM-GPG-KEY-redhat-release
[root@kerneltalks BaseOS]# yum repolist
RedHat DVD ISO 1.0 MB/s | 2.2 MB 00:02
Last metadata expiration check: 0:00:01 ago on Wed 28 Nov 2018 12:30:43 PM EST.
repo id repo name status
dvdiso RedHat DVD ISO 1,688
[root@kerneltalks ~]# systemctl status cockpit.socket
● cockpit.socket - Cockpit Web Service Socket
Loaded: loaded (/usr/lib/systemd/system/cockpit.socket; enabled; vendor preset: disabled)
Active: active (listening) since Wed 2018-11-28 12:38:52 EST; 1s ago
Docs: man:cockpit-ws(8)
Listen: [::]:9090 (Stream)
Process: 9823 ExecStartPost=/bin/ln -snf active.motd /run/cockpit/motd (code=exited, status=0/SUCCESS)
Process: 9816 ExecStartPost=/usr/share/cockpit/motd/update-motd localhost (code=exited, status=0/SUCCESS)
Tasks: 0 (limit: 11516)
Memory: 392.0K
CGroup: /system.slice/cockpit.socket
Nov 28 12:38:52 kerneltalks.com systemd[1]: Starting Cockpit Web Service Socket.
Nov 28 12:38:52 kerneltalks.com systemd[1]: Listening on Cockpit Web Service Socket.
This will enable and activate the Cockpit service on RHEL. Since service is running now, Cockpit will listen to port 9090 by default. Check if the Cockpit service is listening on a port and open up your browser to access the web console.
How to connect Cockpit web console on RHEL 8
As we already mentioned, by default Cockpit listens on port 9090. All you have to do is open up a browser and go to https://ip_or_hostname:9090 URL and you will be connected to the Cockpit web console. So, in our case the Cockpit URL is https://192.168.56.101:9090. You will be greeted with the login screen as below –
Use root account to login and you will be presented with the home screen of Cockpit web administration console like below –
That’s it. You have web console in front of you. You can see utilization metrics in real time on home screen. Left hand side menu gives you ways to manage your system. Explore!
Complete step by step guide of RHEL 8 BETA installation with screenshots.
In this article, we will walk you through step by step installation of Red Hat Enterprise Linux 8.0 BETA along with screenshots. Before you begin to read what’s new in RHEL 8 and how to download RHEL 8 ISO. For this article, we installed RHEL 8 BETA on Oracle VM VirtualBox but the process almost remains the same whether you install on VM or physical machine. So, let’s learn how to install RHEL 8 BETA with screenshots.
Boot server with bootable ISO and you will be presented with below boot menu. Test media and install will be by default selected and you get the 60-sec timer to cancel it out. Since ISO is almost 6.5 GB it takes a while to test media so you can cancel this out, move up and choose to install without checking media.
Select Install Red Hat Enterprise Linux 8.0and press enter
RHEL 8 BETA installer will load into memory and you will be presented with a language selection screen.
Note here that Red Hat highlighted its PRE-RELEASE/TESTING so you understand it’s not to run in your live environment.
Select language of your choice and click Continue
Now, before moving forward installer will again remind you that this is pre-release software with below notice screen.
Click I want to proceed
Now you will see installation summary screen. Here all the custom configurations to be made. Everything is segregated in three categories :
Localization
Keyboard
Language Support
Time & Date
Software
Installation Source
Software Selection
System
Installation Destination
Kdump
Network & Host Name
Security Policy
System Purpose
You can click on each category and customize it according to your choice. We will walk you through each of them with screenshots except Keyboard and Language Support.
Lets start with Time & Date. Click on it and you will see below screen –
Select timezone, date, time of your choice. You can even setup NTP here. Slide button on upper-right corner next to Network Time to configure NTP.
Click Doneat top left corner once done.
You will come back to the installation summary screen. Click on Installation Source. It will bring up below screen –
By default, the install source is selected from where you boot up this system. You can notice additional AppStream repo here which is one of the features of RHEL 8 BETA. Click Done. You will be back on the installation summary screen.
Click Software Selection. You will see below screen –
Here you select base and add-ons depending on your server role. Since we are installing it for testing, we choose minimal install. Click Done. You will be back on the installation summary screen.
Click Installation Destination and you get access to partition your root disk. By default, Automatic partitioning is selected.
Here you can select different custom partitioning along with different volume managers. We re sticking with automatic partitioning here. Click Done. You will be back on the installation summary screen.
Click KDUMP and you will be able to do kdump configuration.
You can enable/disable kdump here. Also if enabled you can specify reserve memory for it or leave to automatic. Click Done. You will be back on installation summary screen.
Click Network & Host Name. Here hostname and networking details can be configured. You will be presented with below screen –
Define hostname in the lower left bottom space. To configure networking details click Configure and it will pop up below network configuration window.
Configure details. Click Save. Come back to the previous window. Click Done. You will be back on the installation summary screen.
Click Security Policy and below screen will allow you to define security policies of your choice. You can even specify URL to fetch policies
Once done click Done. You will be back on installation summary screen.
Click System Purpose to define the role of server. Below window let you define your server role –
Select appropriately. We selected it as an RHEL, self-supported test server. Click Done. You will be back on the installation summary screen.
Now all customization according to your requirement has been done. You are now ready to start OS installation. Hit Begin installation button. The installer will start partitioning your disks and prepare them for installation. Meanwhile, it shows you below the screen to set the root password and add users to the system.
Set root password, sit back, and relax while installer complete setup! Once setup finishes, it will show up completion screen as below and ask for a reboot.
Click Reboot to enter whole new world of Red Hat Enterprise Linux 8.0 BETA!
System reboots and here you have first ever boot menu of RHEL 8.0
Default kernel will be automatically selected to boot in 5s. Let system boot and then login !!
And here we are! On root hash prompt of RHEL 8.0 BETA!!!
You have successfully completed RHEL8 installation and now it’s ready to use.
A quick article listing what’s new in RHEL 8 BETA. Also, enlist steps to download RHEL 8 BETA ISO from the Red Hat developer portal.
RHEL 8 Beta version got released recently (Nov 14, 2018) and its Beta version is available for developers! In this quick post, we will walk you through features RHEL 8 offering currently and how to download your own RHEL 8 ISO for testing. If you are looking for more details then follow RHEL 8 release notes by Red Hat.
How to download RHEL 8 ISO
Red Hat Enterprise Linux 8 Beta is available to download on their developers portal. You need to sign up for a free account on the Red Hat developers portal. Login to the portal using your created account Navigate to download section. There you can check the link to RHEL 8 separate page or you can directly go to RHEL 8 page here. Here you will find links to download RHEL 8 ISO.
RHEL 8 is built with developers in mind! There is so much in the box for application developers.
RHEL 8 comes with pre-enabled repository Application Stream (AppStream) which provides many developers tools.
Its developer-friendly means fewer efforts needed for setup or configuration. A developer can start working on codes easily without wasting many efforts in setting up the environment for it.
Easy to use for developers who are new to Linux
It has all cloud/container application development tools.
Linux containers included in the bag
cockpit is available by default in RHEL repos. A cockpit is a web-based tool used by the sysadmin to manage systems.
It has composer included. It’s used to deploy custom images in the cloud.
Few software versions available with RHEL 8 are Python 3.6, Nginx 1.14, Apache 2.4.35, PHP 7.2, Ruby 2.5, Perl 5.26, Databases like MariaDB 10.3, MySQL 8.0, PostgreSQL 10, PostgreSQL 9.6, and Redis 4.0
OS content is available through pre-enabled repository BaseOS
Supports up to 4PB of physical memory.
nobody user replaced by nfsnobody
KVM supports 5 level paging, increasing physical and virtual address space used by host or guest.
qemu-kvm 2.12 added which has many enhancement ones being hot vCPU plug-unplug
and many more…
We have curated only a few features in the above list. You can always navigate to 8.0 release notes and read the detailed list of enhancements and features in RHEL 8!
Go ahead, grab your ISO copy of RHEL 8 and get your hands on this new sensation in Linux world.