Linux Administration Commands

As a system administrator, you may want to know who is on the system at any give point in time. You may also want to know what they are doing. In this article let us review 4 different methods to identify who is on your Linux system.

1. Get the running processes of logged-in user using w

w command is used to show logged-in user names and what they are doing. The information will be read from /var/run/utmp file. The output of the w command contains the following columns:
  • Name of the user
  • User’s machine number or tty number
  • Remote machine address
  • User’s Login time
  • Idle time (not usable time)
  • Time used by all processes attached to the tty (JCPU time)
  • Time used by the current process (PCPU time)
  • Command currently getting executed by the users
 
Following options can be used for the w command:
  • -h Ignore the header information
  • -u Display the load average (uptime output)
  • -s Remove the JCPU, PCPU, and login time.

$ w
 23:04:27 up 29 days,  7:51,  3 users,  load average: 0.04, 0.06, 0.02
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
ramesh   pts/0    dev-db-server        22:57    8.00s  0.05s  0.01s sshd: ramesh [priv]
jason    pts/1    dev-db-server        23:01    2:53   0.01s  0.01s -bash
john     pts/2    dev-db-server        23:04    0.00s  0.00s  0.00s w

$ w -h
ramesh   pts/0    dev-db-server        22:57   17:43   2.52s  0.01s sshd: ramesh [priv]
jason    pts/1    dev-db-server        23:01   20:28   0.01s  0.01s -bash
john     pts/2    dev-db-server        23:04    0.00s  0.03s  0.00s w -h

$ w -u
 23:22:06 up 29 days,  8:08,  3 users,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
ramesh   pts/0    dev-db-server        22:57   17:47   2.52s  2.49s top
jason    pts/1    dev-db-server        23:01   20:32   0.01s  0.01s -bash
john     pts/2    dev-db-server        23:04    0.00s  0.03s  0.00s w -u

$ w -s
 23:22:10 up 29 days,  8:08,  3 users,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM               IDLE WHAT
ramesh   pts/0    dev-db-server        17:51  sshd: ramesh [priv]
jason    pts/1    dev-db-server        20:36  -bash
john     pts/2    dev-db-server         1.00s w -s

2. Get the user name and process of logged in user using who and users command

who command is used to get the list of the usernames who are currently logged in. Output of the who command contains the following columns: user name, tty number, date and time, machine address.
$ who
ramesh pts/0        2009-03-28 22:57 (dev-db-server)
jason  pts/1        2009-03-28 23:01 (dev-db-server)
john   pts/2        2009-03-28 23:04 (dev-db-server)
 
To get a list of all usernames that are currently logged in, use the following:
$ who | cut -d' ' -f1 | sort | uniq
john
jason
ramesh

Users Command

users command is used to print the user name who are all currently logged in the current host. It is one of the command don’t have any option other than help and version. If the user using, ‘n’ number of terminals, the user name will shown in ‘n’ number of time in the output.
$ users
john jason ramesh

3. Get the username you are currently logged in using whoami

whoami command is used to print the loggedin user name.
$ whoami
john
 
whoami command gives the same output as id -un as shown below:
$ id -un
john
 
who am i command will display the logged-in user name and current tty details. The output of this command contains the following columns: logged-in user name, tty name, current time with date and ip-address from where this users initiated the connection.
$ who am i
john     pts/2        2009-03-28 23:04 (dev-db-server)

$ who mom likes
john     pts/2        2009-03-28 23:04 (dev-db-server)

Warning: Don't try "who mom hates" command.
Also, if you do su to some other user, this command will give the information about the logged in user name details.

4. Get the user login history at any time

last command will give login history for a specific username. If we don’t give any argument for this command, it will list login history for all users. By default this information will read from /var/log/wtmp file. The output of this command contains the following columns:
  • User name
  • Tty device number
  • Login date and time
  • Logout time
  • Total working time
$ last jason
jason   pts/0        dev-db-server   Fri Mar 27 22:57   still logged in
jason   pts/0        dev-db-server   Fri Mar 27 22:09 - 22:54  (00:45)
jason   pts/0        dev-db-server   Wed Mar 25 19:58 - 22:26  (02:28)
jason   pts/1        dev-db-server   Mon Mar 16 20:10 - 21:44  (01:33)
jason   pts/0        192.168.201.11  Fri Mar 13 08:35 - 16:46  (08:11)
jason   pts/1        192.168.201.12  Thu Mar 12 09:03 - 09:19  (00:15)
jason   pts/0        dev-db-server   Wed Mar 11 20:11 - 20:50  (00:39

Steps to create a youtube channel

Steps to create a youtube channel:


  1. Define a name and description
  2. Go to YouTube and create a business account (https://www.youtube.com/)
  3. Create Social Media Elements (Facebook/Twitter)
  4. Create Channel
  5. Verify Channel
  6. Create Channel Art
    https://snappa.com/






Data Design Patterns

Data design patterns are solutions to recurring data modeling problems. They are reusable designs that can be applied to different data models.

Data design patterns can help you to improve the quality, efficiency, and scalability of your data models. They can also help you to avoid common data modeling problems.

There are many different data design patterns available. Some of the most common data design patterns include:

  • Active record: The active record pattern is a design pattern that decouples data access from business logic.
  • Data mapper: The data mapper pattern is a design pattern that separates the data access layer from the business logic layer.
  • Repository: The repository pattern is a design pattern that provides a central access point to data.
  • Value object: The value object pattern is a design pattern that encapsulates data that does not change.
  • Entity: The entity pattern is a design pattern that represents a real-world object in the data model.
  • Association: The association pattern is a design pattern that represents the relationship between two entities.
  • Aggregation: The aggregation pattern is a design pattern that represents a relationship between an entity and a collection of other entities.
  • Composition: The composition pattern is a design pattern that represents a relationship between an entity and another entity that is part of it.

The best data design pattern for you will depend on your specific needs and requirements. If you are not sure which pattern is right for you, I recommend that you consult with a data modeling expert.

Here are some of the factors to consider when choosing a data design pattern:

  • The size and complexity of the data: The larger and more complex the data, the more complex the data design pattern will need to be.
  • The performance requirements: The data design pattern should be chosen to meet the performance requirements of the application.
  • The maintainability requirements: The data design pattern should be chosen to make the data model easy to maintain.
  • The scalability requirements: The data design pattern should be chosen to make the data model scalable.
  • The security requirements: The data design pattern should be chosen to meet the security requirements of the application.

Once you have chosen a data design pattern, you need to implement it in your data model. The implementation of the data design pattern will depend on the specific pattern that you have chosen.

Data is Immutable - Cap Theorm

https://en.wikipedia.org/wiki/CAP_theorem

Open Source Monitoring Software for IT Infrastructure

Monitoring is essential to businesses to ensure a necessary system is up and running. Monitoring different aspects of your IT Infrastructure setup can cause a lot of tantrum if not done properly with the right tools.
It doesn’t matter if you have a small or enterprise-level configuration, you can’t ignore the monitoring devices.  Even if you own a personal website, you need uptime monitoring.
There are many software from open source to a commercial level, which helps you to monitor your infrastructure and notify for any failure. Considering a large number of options, it might be challenging to find one that hangs well on the string of your price range is not easy.
The good thing is, there is a powerful open-source monitoring solution available for you to use. Thanks for the open-source community to maintain them.
Let’s take a look at the best open source monitoring software for IT Infrastructure monitoring and see what works for you.

Nagios

Nagios, founded in 1999, is one of the industry leaders in providing monitoring solutions from small to enterprise-level infrastructure.
Nagios is capable of monitoring almost all types of components like network protocols, operating systems, system metrics, applications, services, web servers, websites, middleware, etc.
Nagios runs on a Core 4 monitoring engine, which provides a high level of performance by consuming fewer server resources.
nagios-core
You can integrate with almost any type of third-party software by using a plugin, and most likely, someone has already written the plugin.
If you are into Middleware, you can leverage Nagios to monitor WebLogic, WebSphere, JBoss, Tomcat, Apache, URL, Nginx, etc.
Features
  • Centralized view of entire monitored IT infrastructure
  • Its event handlers grant automatic restart of failed applications
  • Multi-user access
  • Selective access allows clients to view only the infrastructure components about them
  • An active community of over 1 million users
  • Extendable architecture
Do you need some help with Nagios installation? Check out this Fiverr gig.

Zabbix

Zabbix is a splendid enterprise-level software designed to monitor everything from performance and availability of servers, network equipment to web applications, and databases.
Zabbix is used by thousands of companies worldwide, including DELL, Salesforce, ICANN, Orange, etc.
zabbix
Zabbix is a server-agent system architecture where you got to install the agent on a server (client) to be monitored by the Zabbix server. However, you don’t need to install the agent for services like FTP, SSH, HTTP, DNS, etc.
You can get it installed on Linux, AIX, Windows, Solaris, MacOS X, FreeBSD, OpenBSD, etc.
It supports SNMP and provides better reporting.
Features
  • Monitor Java application servers over JMX directly
  • VM monitoring allows VMWare, vCenter, and vSpehere
  • The front end has self-protection against brute force attacks
  • Automation can be done by scripts in various languages like Ruby, Python, Perl, PHP, Java or shell scripts
  • Integrates with other system management tools like Puppet, cfengine, Chef, bcfg2 to name a few
If you are looking to learn how to implement Zabbix for a large organization, then you may refer to this online course.

Cacti

Cacti is another open-source network monitoring tool that can be installed on Linux or Windows OS. It is connected to RRDTool, which allows us to generate graphs related to relevant network data.
It works with SNMP and presents the network statistics in the form of easy to understand charts.
catci
Cacti require MySQL, Apache, or IIS that support PHP.
Features
  • Unlimited graph items can be defined for each graph optionally utilizing CDEF or data sources from within Cacti
  • Auto padding support for graphs
  • Supports RRD(Round-Robin Database) files with more than one data source and can also use an RRD file stored anywhere on the local file system
  • User-based management and security
  • Custom data gathering scripts

OpenNMS

OpenNMS let you build a network monitoring solution for any IT infrastructure. You can collect system metrics using JMX, WMI, SNMP, NRPE, XML HTTP, JDBC, XML, JSON, etc.
With the help of OpenNMS, you can discover layer two network topologies in your network. It’s built on event-driven architecture and supports Grafana.
opennms-graphana-e1489406407871
OpenNMS got built-in reporting, which means you can view the report in a beautiful dashboard and chart. Overall, OpenNMS got an excellent user interface.
You can also install it in Docker.
Features:
  • It is specially designed for Linux, but Windows, Solaris, and OSX are also supported.
  • Device Temperature monitoring
  • Customizable admin dashboard
  • Power Supply Monitoring
  • IPv4 and IPv6 support
  • Events can generate notifications via email, SMS, XMPP, and various other methods.
  • Geographical node map to show nodes and service outages using Open Street Map, Google Maps or Mapquest

Icinga

Icinga monitoring framework allows you to monitor all the available systems in your network, which alerts you in the case of an alarm in many ways and provides you with a database for your SLA reporting.
Icinga, which began as Nagios Fork in 2009, got freed from the constraints of a fork and crafted Icinga 2, which is faster, easier to configure, more comfortable to scale significantly better.
icinga-e1489406382764
Features:
  • Monitoring of network services, host services, and server components
  • It performs monitoring with Icinga 2 plugins.
  • Support for event handlers and notifications
  • Phone, SMS, call and email support
  • Cross-platform support for various operating systems
  • Parallelized service checks
  • You can choose between 2 user interfaces, Classic UI and Icinga web
  • Template-based reports

Netdata

Netdata provides unparalleled real-time health monitoring and performance troubleshooting for systems and applications. Over the past six years of development, Netdata’s GitHub community has been essential to its growth.
Netdata is fast and efficient, designed to run on all systems without disruption. Instantly diagnose slowdowns and anomalies in your infrastructure with thousands of metrics, interactive visualizations, and insightful health alarms.
netdata
Netdata is free, open-source software, and currently runs on physical systems, virtual machines, containers, and IoT/edge devices.
Features:
  • High-resolution metrics, with per-second data collection.
  • Auto-detects and monitors thousands of metrics from dozens of services and applications.
  • Monitoring for all possible sources, including thousands of metrics per node.
  • Meaningful presentation, optimized for visual anomaly detection.
  • Advanced alarm notification system for detecting performance and availability issues.
  • Quick installation with immediate results—zero dedicated resources required.
  • A custom database engine that saves recent metrics to RAM and “spills” historical metrics to disk for long-term storage.

M/Monit

M/Monit tool is used for supervising the process for Unix and Linux. It is a software that has covered the need to manage many identical infrastructure processes.
It runs on any POSIX system and uses around 10-15 MB of RAM, depending on how many hosts you monitor. It works with the following database systems:
  • MySQL 5.x or later
  • PostgreSQL 8.4 or later
  • SQLite 3.x
If a process dies, M/Monit can perform an automated restart. So, in the case of patchy situations, it can jump in for automatic repair and maintenance. Therefore your systems will be able to gain the maximum uptime.
MMonit
Features
  • Easy and a time saver when it comes to installing and setting it up.
  • Collects key data from monitored hosts and creates beautiful and easily understandable charts by analyzing the collected data.
  • Its user interface is simple, clean, and responsive. Its UI can rearrange itself to fit the device screen.
  • Manage and monitor both the background or daemon processes.
  • Higher application uptime because it can handles error conditions automatically, without human intervention.
  • Monitor processes, servers, disks, files, folders, and cloud activities.
  • Control the services remotely.
  • HTTP rest API to query M/Monit for data.
  • Based on existing data, we can extrapolate future values by using its trend predictions feature.

LibreNMS

LibreNMS is a fully featured network monitoring system. It is based on PHP/MySQL/SNMP. LibreMNS covers a wide range of operating systems and network hardware.
LibreNMS
It can do interface-grouping based on the prefix of the interfaces. The entire network can be automatically discovered by the use of SNMP, CDP, ARP, FDP, OSPF, LLDP, and BGP.
Features
  • A highly flexible and reliable alerting system is being used here. So, immediate notifications will pop up via email, IRC, Slack, etc.
  • Whatever data will come in from the installation, LibreMNS can retrieve, manage, and graph it using the full API it has.
  • Another very important feature is its capability to generate the bandwidth bills on the network, based on the usage.
  • As the network grows, you can scale it horizontally.
  • It provides integration support for NfSen, collected, SmokePing, RANCID, Oxidized.
  • It supports multiple authentication methods with MySQL, HTTP, LDAP, Radius, Active Directory.
  • Extensive device support with mobile-friendly web UI.

Conclusion


Above listed monitoring software can get you started in FREE to monitor various aspects of IT infrastructure.

Big data tools

Apache Flume
https://flume.apache.org/FlumeUserGuide.html


http://blog.thilinamb.com/2014/06/how-to-pump-syslog-data-into-flume.html

Test Twitter: https://developer.twitter.com/en/docs/tweets/compliance/api-reference/compliance-firehose