UNIX Course Portfolio

What Is UNIX?

UNIX is a multi-user, multi-tasking Network Operating System.

UNIX was first developed in 1969 by AT&T for a DEC PDP platform and throughout the 80s was ported to many different hardware platforms, made possible through licenses to the source code. AT&T also made their source code available to some US universities, one of which was Berkeley University, and they developed their instances of UNIX.

By the mid 80s there were two main variants of UNIX source code available to computer manufacturers:

Linux/UNIX - Using grep With Regular Expressions

Searching for Lines Containing Patterns 

There will be many occasions when you are trying locate a specific set of lines in a file, such as a log file, or perhaps you are trying filter the results that have come back from a Linux or Unix command to just the ones relevant to your specific needs.

The grep command is perfect in these situations and we explore some of it’s capabilities here.

Linux - Changing the system time and hostname

Linux Systems offer an X Windows interface which can make changing system settings and configuration pretty straight forward, but what if you remotely log in via a Secure Shell (SSH) session using a tool such as putty?

Here is how to change the system date and time and the hostname from the command line.

Changing The Date & Time in Linux

The date command can be used by root to change the system date and time.

UNIX & Linux Pipes & Utilities - tr, cut, sort, egrep

Creating UNIX & Linux Piped Commands

UNIX and Linux offer a very powerful feature know as pipes. It is often possible to carry out really complicated tasks without the need for shell scripting, variables, loops, etc.

Take the following example, which creates a dictionary file from a text document, but excludes one and two letter words:

tr -cs "[a-z][A-Z]" "[\012*]" < readme.txt | sort -uf | tr "[A-Z]" "[a-z]" | egrep -v "(^.$|^..$)" > dictionary

One command line that is comprised of five separate steps:

RedHat RHEL/CentOS 7 Service Start Up Changes

RHEL/CentOS 7 Has A New Initialisation Daemon

The init daemon is the initialisation daemon first implemented in System V UNIX systems and has been around for over 40 years!

RedHat’s RHEL 7 and CentOS 7 introduces a replacement for init called systemd.

Startup & Run Levels

RHEL 6 (and CentOS 6) supported SysV init and Upstart with start and kill scripts created as links to scripts in /etc/rc.d/init.d scripts in the appropriate run level directory e.g. /etc/rc2.d.

Which IP Addresses Have Accessed Apache Web Server The Most?

Last week I was asked the following question:

“Is there any way that you can find out which hosts or IP addresses have been accessing your Apache Web Server the most?”

The answer to this question is “YES!”.

Apache maintains an access log file, its default location is in the Apache logs directory, but this can be defined in the Apache httpd.conf file. The “out of the box” location  for the Apache distribution with CentOS/= and RHEL 6 and 7 is: /etc/httpd/logs/access_log. Here is an example of the the default log entries for this file:

Enable Remote Access to Apache Web Server on CentOS 7

In its out of the box configuration you may find that CentOS Linux has iptables configured to prevent inbound HTTP requests.

You can add access for inbound HTTP requests on port 80 with the following command:

iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp -dport 80 -j ACCEPT

Line 4 of the iptables -L output now shows that http is allowed inbound from anywhere: