Hollywood movie MATRIX like desktop in Linux terminal

cmatrix: One of the command to have fun in a Linux terminal. It will turn your terminal into the Hollywood movie “MATRIX” like a cool desktop. 

Hollywood movie MATRIX falling code in Linux terminal

About cmatrix program:

It’s written by Chris Allegretta. The Cmatrix page can be found here. This program is distributed via the GNU GPL and its Sourceforge page is here. To download the latest release visit Sourceforge page.

Have you seen the Hollywood movie “Matrix”? You must have liked those monitors with falling green code. It looks like a cool hacker/coder desktop! After the movie went to the box office, many matrix screensavers were out for windows. Do you want one for Linux? Like the one below?

Matrix falling code in terminal

Yes, that’s possible. You can have such a matrix-like desktop in Linux terminal too. In very simple two steps.

Step 1

Install cmatrix package using YUM or APT depending on your Linux distro.

If you don’t have a YUM repository configured then you can download a standalone file (check Sourceforge page if this link is broken). Then follow below commands to set it up from source code.

  • Install packages: gcc, make, autoconf, automake ncurses-devel
  • Download above mentioned file, un-zip, un-tar it and goto unpacked directory cmatrix-1.2a
  • Within cmatrix directory execute below commands.
# aclocal
aclocal: warning: autoconf input should be named 'configure.ac', not 'configure.in'
# autoconf
# automake -a
automake: warning: autoconf input should be named 'configure.ac', not 'configure.in'
configure.in:3: warning: AM_INIT_AUTOMAKE: two- and three-arguments forms are deprecated.  For more info, see:
configure.in:3: http://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_005fINIT_005fAUTOMAKE-invocation
Makefile.am: installing './depcomp'
automake: warning: autoconf input should be named 'configure.ac', not 'configure.in'

Then configure and make ready to install.

# ./configure
checking for a BSD-compatible install... /bin/install -c
checking whether build environment is sane... yes
/root/cmatrix-1.2a/missing: Unknown `--is-lightweight' option
Try `/root/cmatrix-1.2a/missing --help' for more information
configure: WARNING: 'missing' script is too old or missing
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking whether make sets $(MAKE)... (cached) yes
checking for main in -lncurses... yes
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking sys/ioctl.h usability... yes
checking sys/ioctl.h presence... yes
checking for sys/ioctl.h... yes
checking for unistd.h... (cached) yes
checking termios.h usability... yes
checking termios.h presence... yes
checking for termios.h... yes
checking termio.h usability... yes
checking termio.h presence... yes
checking for termio.h... yes
checking return type of signal handlers... void
checking for putenv... yes
checking curses.h usability... yes
checking curses.h presence... yes
checking for curses.h... yes
checking ncurses.h usability... yes
checking ncurses.h presence... yes
checking for ncurses.h... yes
checking for tgetent in -lncurses... yes
"Using ncurses as the termcap library"
checking for use_default_colors in -lncurses... yes
checking for resizeterm in -lncurses... yes
checking for wresize in -lncurses... yes
checking for consolechars... no
checking for setfont... /bin/setfont
checking for /usr/lib/kbd/consolefonts... yes
checking for /usr/share/consolefonts... no
checking for mkfontdir... no
checking for /usr/lib/X11/fonts/misc... no
checking for /usr/X11R6/lib/X11/fonts/misc... no
configure: WARNING:

*** You do not appear to have an X window fonts directory in the standard
*** locations (/usr/lib/X11/fonts/misc or /usr/X11R6/lib/X11/fonts/misc). The
*** mtx.pcf font will not be installed.  This means you will probably not
*** be able to use the mtx fonts in your x terminals, and hence be unable
*** to use the -x command line switch.  Sorry about that...

checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating cmatrix.spec
config.status: creating config.h
config.status: executing depfiles commands
# make
(CDPATH="${ZSH_VERSION+.}:" && cd . && autoheader)
autoheader: WARNING: Using auxiliary files such as `acconfig.h', `config.h.bot'
autoheader: WARNING: and `config.h.top', to define templates for `config.h.in'
autoheader: WARNING: is deprecated and discouraged.
autoheader:
autoheader: WARNING: Using the third argument of `AC_DEFINE' and
autoheader: WARNING: `AC_DEFINE_UNQUOTED' allows one to define a template without
autoheader: WARNING: `acconfig.h':
autoheader:
autoheader: WARNING:   AC_DEFINE([NEED_FUNC_MAIN], 1,
autoheader:             [Define if a function `main' is needed.])
autoheader:
autoheader: WARNING: More sophisticated templates can also be produced, see the
autoheader: WARNING: documentation.
rm -f stamp-h1
touch config.h.in
cd . && /bin/sh ./config.status config.h
config.status: creating config.h
make  all-am
make[1]: Entering directory `/root/cmatrix-1.2a'
gcc  -g -O2   -o cmatrix cmatrix.o  -lncurses  -lncurses
make[1]: Leaving directory `/root/cmatrix-1.2a'

Finally install it. and thats it.

# make install
make[1]: Entering directory `/root/cmatrix-1.2a'
 /bin/mkdir -p '/usr/local/bin'
  /bin/install -c cmatrix '/usr/local/bin'
 Installing matrix fonts in /usr/lib/kbd/consolefonts...
 /bin/mkdir -p '/usr/local/share/man/man1'
 /bin/install -c -m 644 cmatrix.1 '/usr/local/share/man/man1'
make[1]: Leaving directory `/root/cmatrix-1.2a'

Step 2

Type cmatrix command and experience matrix! You can exit out the matrix screen anytime by hitting ctlr+c on the terminal. Check cmatrix command in action in the GIF above!

Reader’s tip :

One of our readers, @Pranit Raje  sent us this one-liner which did the trick. Its not as exact matrix code as we saw above but yeah it’s promising. Try and have fun in the terminal.

LC_ALL=C tr -c "[:digit:]" " " < /dev/urandom | dd cbs=$COLUMNS conv=unblock | GREP_COLOR="1;32" grep --color "[^ ]"

					

Understanding package naming convention (rpm & deb)

This article will help you understand the package naming convention followed while naming RPM or DEB packages. It helps while you work on package management.

Package naming convention

Linux world is moved by packages since you need a flavor punch on plain vanilla OS! Although there are quite a few package managers available in the market largely two package managers are popular: RPM (Red Hat package manager) & DEB (Debian package manager).

Red Hat package managers release their packages with extension .rpm while Debian package managers have .deb extension. The extension really doesn’t matter in Linux world but still, it’s there for identification purposes for humans!

Recommended read:

Apart from extensions they also have a package naming convention which makes it easy to identify package name, version, release & what architecture it supports. Lets quickly walk through these conventions.

Red Hat package naming convention

Red Hat package name follows below format –

packagename-version-release.architecture.rpm

Field involved here are

  1. It starts with the package name
  2. Then its version (separated by hyphen – from the last field)
  3. Then its release (separated by hyphen – from the last field)
  4. Sometimes OS details are padded here (separated by a dot .  from the last field)
  5. Then architecture for which package built (separated by a dot .  from the last field)
  6. Ends with rpm extension (separated by a dot . from the last field)

For example, look at this telnet package file name “telnet-0.17-60.el7.x86_64.rpm

Here,

  • telnet is a package name
  • 0.17 is version
  • 60 is release
  • el7 is enterprise Linux 7 (package built for rhel7)
  • x86_64 is architecture

Extra OS details mentioned in names can be :

  1. elX or rhlX – RHEL X
  2. suseXXY – Suse Linux XX.Y
  3. fcX – Fedora Core X
  4. mdv or mdk – Mandriva Linux

Debian package naming convention

Debian package name follows below format –

packagename_version-release_architecture.deb

Field involved here are

  1. It starts with the package name
  2. Then its version (separated by underscore – from the last field)
  3. Then its release (separated by a hyphen – from the last field)
  4. Sometimes Debian codename details are padded here (separated by hyphen –  from the last field)
  5. Then architecture for which package built (separated by a dot .  from the last field)
  6. Ends with deb extension (separated by a dot . from the last field)

Debian codename can be squeeze or wheezy.

For example look at this telnet package file name “telnet_0.17-40_amd64.deb

Here,

  • telnet is a package name
  • 0.17 is version
  • 40 is release
  • amd64 is architecture

Different types of architectures which can be seen in names are :

  1. x86_64 or amd64 – 64 bit on x86 microprocessor
  2. i386  – The Intel x86 family of microprocessors, starting with the 80386.
  3. ppc – The Power PC microprocessor family.
  4. alpha – The Digital Alpha microprocessor family.
  5. sparc – Sun Microsystem SPARC processor family.
  6. noarch – No particular architecture. The package may work on all types of architecture.

Package removal in Linux (YUM & APT)

Different types of package removal in Linux explained with examples. Learn package removal or uninstall on a yum or apt-based system.

Package removal in Linux

This article is part of the YUM series. Other articles in this series can be found at below links :

We will be seeing how to uninstall packages from YUM and APT based Linux systems. Package removal also knows as an erasing package from the system.

Package removal on YUM based system

Removing package using yum

On YUM based system like Red Hat or CentOS, the package can be removed by supplying erase or remove argument to yum command along with package name. For example to remove telnet, we will use yum remove telnet

# yum remove telnet
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
Resolving Dependencies
--> Running transaction check
---> Package telnet.x86_64 1:0.17-60.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================
 Package                      Arch                         Version                             Repository                                               Size
=============================================================================================================================================================
Removing:
 telnet                       x86_64                       1:0.17-60.el7                       @rhui-REGION-rhel-server-releases                       113 k

Transaction Summary
=============================================================================================================================================================
Remove  1 Package

Installed size: 113 k
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : 1:telnet-0.17-60.el7.x86_64                                                                                                               1/1
  Verifying  : 1:telnet-0.17-60.el7.x86_64                                                                                                               1/1

Removed:
  telnet.x86_64 1:0.17-60.el7

Complete!

The above output will be the same even if you use yum erase telnet command. Before removing it will print package details to be removed on screen and ask for confirmation to avoid unwanted removals.

Removing package using rpm command

Same task can be achieved by using rpm command with erase -e option.

# rpm -evh telnet
Preparing...                          ################################# [100%]
Cleaning up / removing...
   1:telnet-1:0.17-60.el7             ################################# [100%]

In above example we used -e (erase), -v (verbose) and -h (print hash marks) along with name of package.

Package removal on APT based system

Removing package using apt-get

On APT based systems like Ubuntu or Debian, the package can be removed with apt-get remove <package_name> command. Note that like YUM this command doesn’t support erase option.

# apt-get remove telnet                                                                                                                                      
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  telnet
0 upgraded, 0 newly installed, 1 to remove and 60 not upgraded.
After this operation, 182 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 81678 files and directories currently installed.)
Removing telnet (0.17-40) ...
Processing triggers for man-db (2.7.5-1) ...

apt-get to asks for confirmation before removing package from system.

Removing package using dpkg

With Debian package manager command i.e. dpkg, this can be done using --remove argument.

# dpkg --remove telnet
(Reading database ... 81678 files and directories currently installed.)
Removing telnet (0.17-40) ...
Processing triggers for man-db (2.7.5-1) ...

See above output as it removes telnet.

Observe that dpkg or rpm commands don’t ask for user confirmation before removing the package.

How to open port on AWS EC2 Linux server

Small tutorial with screenshots that show how to open port on the AWS EC2 Linux server. This will help you to manage port-specific services on the EC2 server.

Open port on AWS EC2 Linux

AWS i.e. Amazon Web Services is no new term for the IT world. It’s a cloud services platform offered by Amazon. Under its Free tier account, it offers you limited services free of cost for one year. This is one of the best places to try out new technologies without spending much on the financial front.

AWS offers server computing as one of their services and they call them EC (Elastic Computing). Under this, we can build our Linux servers. We have already seen how to set up a Linux server on AWS free of cost.

By default, all Linux servers build under EC2 has post 22 i.e. SSH service port (inbound from all IP) is open only. So, if you are hosting any port-specific service then the relative port needs to be open on the AWS firewall for your server.

Also, it has port 1 to 65535 are open too (outbound for all traffic). If you want to change this you can use the same below process for editing outbound rules too.

Setting up a firewall rule on AWS for your server is an easy job. You will be able to open ports in seconds for your server. I will walk you through the procedure with screenshots to open a port for the EC2 server.

Step 1

Log in to the AWS account and navigate to the EC2 management console. Go to Security Groups under Network & Security menu as highlighted below :

AWS EC2 management console

Step 2

On Security, Groups screen select your EC2 server and under Actions menu select Edit inbound rules

AWS inbound rules menu

Step 3

Now you will be presented with an inbound rule window. You can add/edit/delete inbound rules here. There are several protocols like HTTP, nfs, etc listed in the drop-down menu which auto-populate ports for you. If you have customer service and port you can define it too.

AWS add inbound rule

For example, if you want to open port 80 then you have to select :

  • Type: HTTP
  • Protocol: TCP
  • Port range: 80
  • Source: Anywhere (Open port 80 for all incoming req from any IP (0.0.0.0/0),  My IP: then it will auto-populate your current public internet IP

Step 4

That’s it. Once you save these settings your server inbound port 80 is open! you can check by telneting to port 80 for your EC2 server public DNS (can be found it EC2 server details)

You can also check it on websites like ping.eu.

The same way outbound rules can be edited too! These changes are active on the fly and don’t need any downtime.

How to download the package using YUM or APT

Learn how to download packages from YUM or APT repository. The standalone package can be used to install on another server that has no YUM or APT configured.

Process to download package using YUM or APT

Many production environments don’t prefer to configure YUM or APT repositories on all servers. This is to avoid accidental installation of packages or up-gradating packages, which may cause issues on operations. Most of them use a centralized patch server to push updates to all servers.

If you want to install a single package on a server in such a setup, you need to have a standalone package file .rpm or .deb with you—directly downloading packages from the internet is not allowed in production areas. So you have to get packages from the server with registered YUM or APT repository configured.

The good news is you can download the package using YUM or APT! Later this package can be transferred to the intended server and can be installed. See below steps to download packages :

Download package on YUM configured server

Using downloadonly switch with yum command is a way to download packages on yum supported servers (Red Hat, CentOS). You need to fire yum install command and instruct it to download only without installing a package.

# yum install telnet --downloadonly
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
Resolving Dependencies
--> Running transaction check
---> Package telnet.x86_64 1:0.17-60.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================
 Package                      Arch                         Version                              Repository                                              Size
=============================================================================================================================================================
Installing:
 telnet                       x86_64                       1:0.17-60.el7                        rhui-REGION-rhel-server-releases                        63 k

Transaction Summary
=============================================================================================================================================================
Install  1 Package

Total download size: 63 k
Installed size: 113 k
Background downloading packages, then exiting:
telnet-0.17-60.el7.x86_64.rpm                                                                                                         |  63 kB  00:00:00
exiting because "Download Only" specified

In the above output, the install process exists since we specified download the only option (see the highlighted line).

This downloaded package (.rpm) will be saved under /var/cache/yum/<architecture>/<OS>/<repository>/packages directory. A repository name can be seen in the above install command output under package details. We downloaded packages on the RHEL7 server running on x86_64 architecture. See where our package (.rpm) got downloaded :

# pwd
/var/cache/yum/x86_64/7Server/rhui-REGION-rhel-server-releases/packages
# ll
total 68
-rw-r--r--. 1 root root 64872 Nov  6 11:09 telnet-0.17-60.el7.x86_64.rpm

Alternatively, you can install yum-utils and then use the yumdownloader program to download the RPM from a repo in your PWD.

# yum install yum-utils -y
# yumdownloader telnet
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
telnet-0.17-65.amzn2.x86_64.rpm                                                                                                                  |  64 kB  00:00:00
# ll
total 68
-rw-r--r-- 1 root root 65496 May  5  2020 telnet-0.17-65.amzn2.x86_64.rpm

Download package on APT configured server

On APT supported servers like Debian, ubuntu you need to use -d option in apt-get install command.

# apt-get install -d telnet
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  telnet
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/63.5 kB of archives.
After this operation, 182 kB of additional disk space will be used.
Download complete and in download only mode

This will download package in /var/cache/apt/archives.

# pwd
/var/cache/apt/archives

# ll
total 72
drwxr-xr-x 2 root root  4096 Mar  6 11:55 ./
drwx------ 4 root root  4096 Mar  6 12:02 ../
-rw-r--r-- 1 root root 63460 May  6  2015 telnet_0.17-40_amd64.deb
----output clipped ----

Check telnet package file .deb is downloaded in the current directory. If you want to download them in the current working directory, use download option instead of install. So no hassle of tracking down the package in a variable path like yum!

# pwd
/tmp/mypackages
# apt-get download  ssh
Get:1 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 ssh all 1:7.2p2-4ubuntu2.1 [7,070 B]
Fetched 7,070 B in 0s (9,252 B/s)
# ll
total 16
drwxr-xr-x  2 root root 4096 May 17 10:17 ./
drwxr-xr-x 11 root root 4096 May 17 10:13 ../
-rw-r--r--  1 root root 7070 Aug 15  2016 ssh_1%3a7.2p2-4ubuntu2.1_all.deb

You can see the ssh package got downloaded within the same working directory. Now this package can be transferred to other servers (where repositories are not configured) for installation!

Package installation in Linux (YUM,APT & zypper)

Different types of package installations in Linux explained with examples. Learn package installation on a yum or apt-based system.

Package installation in Linux

One of the sysadmin tasks in Linux administration is package management. Under which he needs to install, remove, upgrade packages on the system. In another post, we already saw package/patch installation in HPUX (Unix based system), in this article we will be studying package installation in Linux.

There are many distributions in the market and they support different ways to manage packages on the system. Distros like Red Hat, Cent OS supports YUM (Yellow dog Updater Modified) whereas distros like Debian or Ubuntu support APT (Advanced Packaging Tool).

YUM based system uses packages with .rpm extension (RedHat package manager) whereas APT based systems use packages with .deb extension (Debian distribution)

Package installation on YUM based system

YUM needs to be configured properly to receive package inventory from source server over HTTP/FTP etc. If not then you should have a package file (.rpm) with you.

Installing package from list using yum in RHEL / CentOS

YUM is smart enough to locate packages for you. For instance, if you want to install a telnet package, you are not supposed to supply a complete telnet package name which includes version, architecture, etc details in the name. Typing yum install telnet is enough. YUM will search the package with the name telnet and confirm with you before installation.

root@kerneltalks # yum install telnet
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
Resolving Dependencies
--> Running transaction check
---> Package telnet.x86_64 1:0.17-60.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================
 Package                      Arch                         Version                              Repository                                              Size
=============================================================================================================================================================
Installing:
 telnet                       x86_64                       1:0.17-60.el7                        rhui-REGION-rhel-server-releases                        63 k

Transaction Summary
=============================================================================================================================================================
Install  1 Package

Total download size: 63 k
Installed size: 113 k
Is this ok [y/d/N]: y
Downloading packages:
telnet-0.17-60.el7.x86_64.rpm                                                                                                         |  63 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 1:telnet-0.17-60.el7.x86_64                                                                                                               1/1
  Verifying  : 1:telnet-0.17-60.el7.x86_64                                                                                                               1/1

Installed:
  telnet.x86_64 1:0.17-60.el7

Complete!

In the above output, you can see the install process goes through stages checks, resolving dependencies, printing details, confirmation from the user, downloading, installing, verifying. You can even download the only package using this command.

Recommended read : How to upgrade package using YUM

Installing a standalone package using rpm in RHEL / CentOS

If you don’t have yum repositories setup and have standalone package file (.rpm) then you can install it using rpm -i command.

root@kerneltalks # rpm -ivh telnet-0.17-60.el7.x86_64.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:telnet-1:0.17-60.el7             ################################# [100%]

In the above command, we used -v verbose mode and -h to print progress hash marks!

Package installation on APT based system

APT configuration needs to be in place to fetch packages from the source server. If not then at least you should have a package file .deb with you for installation.

Installing package from list using apt-get on Ubuntu / Debian

apt-get command used for package management. For installing new package use apt-get install <package-name>See below example for installing telnet package :

root@kerneltalks # apt-get install telnet                                                                                                                                      
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  telnet
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/63.5 kB of archives.
After this operation, 182 kB of additional disk space will be used.
Selecting previously unselected package telnet.
(Reading database ... 53784 files and directories currently installed.)
Preparing to unpack .../telnet_0.17-40_amd64.deb ...
Unpacking telnet (0.17-40) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up telnet (0.17-40) ...
update-alternatives: using /usr/bin/telnet.netkit to provide /usr/bin/telnet (telnet) in auto mode

You can see in the above output, it first checks the availability of the stated package in the package list. Then it prints install-info along with size details. Then it downloads a package, unpacks it, installs it, and completes configurations.

While installing a new package, default dependencies will be checked and resolved. There are a few options which you can use with install operation :

Installing standalone package using dpkg on Debian / Ubuntu

If you have a package file (.deb) with you on the server and you want to install it then you can use dpkg command. Supply package file path along with -i option.

root@kerneltalks # dpkg -i telnet_0.17-40_amd64.deb                                                                                                                       
Selecting previously unselected package telnet.
(Reading database ... 53784 files and directories currently installed.)
Preparing to unpack telnet_0.17-40_amd64.deb ...
Unpacking telnet (0.17-40) ...
Setting up telnet (0.17-40) ...
update-alternatives: using /usr/bin/telnet.netkit to provide /usr/bin/telnet (telnet) in auto mode
Processing triggers for man-db (2.7.5-1) ...

The command will set up the package for you with an almost the same sequence as apt-get only looking for a package in the list and downloading stuff omitted.

Installing package using zypper in Suse Linux

In Suse Linux, zypper is mainly used for package management. You can use install or in switch followed by package name to install package using zypper.

root@kerneltalks # zypper install telnet
Refreshing service 'SMT-http_smt-ec2_susecloud_net'.
Refreshing service 'cloud_update'.
Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following NEW package is going to be installed:
  telnet

1 new package to install.
Overall download size: 51.8 KiB. Already cached: 0 B. After the operation, additional 113.3 KiB will be used.
Continue? [y/n/...? shows all options] (y): y
Retrieving package telnet-1.2-165.63.x86_64                                                                                        (1/1),  51.8 KiB (113.3 KiB unpacked)
Retrieving: telnet-1.2-165.63.x86_64.rpm .........................................................................................................................[done]
Checking for file conflicts: .....................................................................................................................................[done]
(1/1) Installing: telnet-1.2-165.63.x86_64 .......................................................................................................................[done]

zypper also auto-resolve dependencies and install them along with your required package.

YUM automatic updates! Save your valuable time!

Learn how to schedule YUM automatic updates to upgrade all system packages to the available latest version in the background without manual intervention!

Set YUM to update packages automatically

Recently we published a post about how to update packages in the RHEL system using YUM. In this post, we have explained how to update single or multiple packages and even all packages at once using the command line. But these ways are manual tasks and needs human intervention to complete them.

In this post, we will see how to set automatic updates using YUM-cron. This will save sysadmin time which is invested in updating packages manually.

Setting this up is not recommended in the production system since they always need a risk analysis of their environment before processing updates.

Setting YUM automatic updates in production servers not recommended. Since production servers seek analysis on who updates will impact the operation of the server and its hosted apps. And this process is completely automatic and runs in the background, it’s advisable to refrain implementing it on critical servers.

YUM-cron is service available on RHEL which runs in background and updates packages on the system automatically. It’s like cron for YUM like we have crons for scripts/commands in Linux. It’s available with the package name yum-cron. Let’s see stepwise install and configure the process of it.

Install yum-cron

yum-cron package is available on optional and supplementary channels. Your YUM should be configured to fetch packages from these channels. Install these packages using :

# yum install yum-cron

Once installed, you need to enable this service since its disabled by default. Enable service using chkconfig & start it manually:

# chkconfig yum-cron on
# service yum-cron start

Configure yum-cron:

yum-cron configuration file is /etc/sysconfig/yum-cron/etc/sysconfig/yum-cron-houely.confIn this configuration file, you can set the frequency and extent of updates.

It has majorly three important fields to set as highlighted below :

# Whether a message should emitted when updates are available.
update_messages = yes

# Whether updates should be downloaded when they are available. Note
# that updates_messages must also be yes for updates to be downloaded.
download_updates = yes

# Whether updates should be applied when they are available.  Note
# that both update_messages and download_updates must also be yes for
# the update to be applied
apply_updates = yes

In the hourly conf file you can set security updates with below settings to make sure your system running latest secured packages and not missing any important security update :

#  What kind of update to use:
# default                            = yum upgrade
# security                           = yum --security upgrade
# security-severity:Critical         = yum --sec-severity=Critical upgrade
# minimal                            = yum --bugfix update-minimal
# minimal-security                   = yum --security update-minimal
# minimal-security-severity:Critical =  --sec-severity=Critical update-minimal

You can also configure email ID so that notification will be sent out after yum-cron finishes its tasks. This can be defined against MAILTO or email_to variable in the configuration file.

Once configuration is done restart yum-cron service.

That’s it! you are done. Now yum-cron service runs in the background quietly. It will update packages on the system (configured as per extent) on time set by frequency in the config and send you an email notification (if configured). You can use your valuable time in other sysadmin tasks!

4 tools to download any file using the command line in Linux

Learn how to download any file using the command line from the internet or FTP servers to your Linux server. Get files in your server in seconds!

How to download any file using command line

There are many times when you want a file on your Linux server from the Internet or FTP server and you are on command line terminal! When using the GUI of Linux, it’s easy to get files by using browsers but for command-line, it’s a little bit difficult.

We have 4 tools here to help you with the task! They are :

  1. wget
  2. curl
  3. elinks
  4. w3m

wget

Most popular utility! wget is a package you can install and use it right out of the box. You can install it with YUM or APT package. Once installed you can use it with supplying URL of the targeted download.

# wget https://kerneltalks.com/image.png
--2017-03-05 06:56:54--  https://kerneltalks.com/image.png
Resolving kerneltalks.com... 208.91.198.91
Connecting to kerneltalks.com|208.91.198.91|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 12477 (12K) [image/png]
Saving to: “image.png”

100%[===================================================================================================================>] 12,477      --.-K/s   in 0s

2017-03-05 06:56:55 (782 MB/s) - “image.png” saved [12477/12477]

In the above example, we have downloaded one picture file from the internet! The file will be saved in your present working directory by default.

# wget ftp://rpmfind.net/linux/fedora/linux/development/rawhide/Everything/x86_64/os/Packages/s/systemd-233-2.fc27.x86_64.rpm
--2017-03-05 06:58:54--  ftp://rpmfind.net/linux/fedora/linux/development/rawhide/Everything/x86_64/os/Packages/s/systemd-233-2.fc27.x86_64.rpm
           => “systemd-233-2.fc27.x86_64.rpm.1”
Resolving rpmfind.net... 195.220.108.108
Connecting to rpmfind.net|195.220.108.108|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD (1) /linux/fedora/linux/development/rawhide/Everything/x86_64/os/Packages/s ... done.
==> SIZE systemd-233-2.fc27.x86_64.rpm ... 3179496
==> PASV ... done.    ==> RETR systemd-233-2.fc27.x86_64.rpm ... done.
Length: 3179496 (3.0M) (unauthoritative)

100%[===================================================================================================================>] 3,179,496   1.85M/s   in 1.6s

2017-03-05 06:58:57 (1.85 MB/s) - “systemd-233-2.fc27.x86_64.rpm.1” saved [3179496]

In this example, we used wget to download file from the FTP server. It used anonymous login to get into the server and download the file!

There are several options which you can use according to your requirement. The listing below a few important ones.

  • -b: send copy progress in the background
  • -c: continue download (broken or paused download resume)
  • -r: recursive (download all files in destination)
  • -A file extension: download only files with the specified extension

curl

Curl is a simple downloader that supports many protocols for file transfer few being FTP, HTTP, HTTPS, telnet, etc. It can be installed using the same above method yum install curl or apt-get install curl.

Curl renders file downloaded to its best-known way. Like if you try to download HTML URL then it will render it and shows you HTML code on terminal :

# curl https://kerneltalks.com
<!DOCTYPE html><html lang="en-US" prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#"><head ><meta charset="UTF-8" /><title>Kernel Talks - Unix, Linux & scripts.</title><meta name="viewport" content="width=device-width, initial-scale=1" /><meta name="google-site-verification" content="jeFc7PXM8ZxDY5awb8nCCD5-bYwj5S7bwsAIgp1JIgU" /><meta name="msvalidate.01" content="920806CD9A79B08EC8477C0D440658A4" /><meta name="p:domain_verify" content="738d0b16e329ab01cc894a68d2adda34" /><meta name="yandex-verification" content="bd079834c4df4ebf" />
------output clipped-----

See the above example where it shows the HTML code of URL. Same way if you get text file it will show you text file content on the terminal.

To only download the file without trying to read/open it on terminal use option -o with curl.

# curl -O  ftp://rpmfind.net/linux/fedora/linux/development/rawhide/Everything/x86_64/os/Packages/s/systemd-233-2.fc27.x86_64.rpm
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 3104k  100 3104k    0     0   361k      0  0:00:08  0:00:08 --:--:--  618k

It will download file and progress will be shown on terminal in real time.

elinks

elinks is a text-based browser that supports colors, rendering, tabbed menus, etc. Mostly it’s preloaded with Installations but if not you can install it using yum or apt-getLet try to download website using elinks https://kerneltalks.com :

elinks renders URL

Above example shows elinks renders website in text mode (kind of) on terminal!

If you try to download image (or any type of) file it will show you below the GUI screen (within the terminal) with options to choose from what to do next. If you choose to save then it will download a file and keep it.

w3m

The last tool of this article to download internet-based files is w3m. w3m is a text-based www (world wide web) client. Installation steps remain same yum/apt-get install w3m

It also opens up a text-mode GUI screen like elinks and gives you interactive options to choose actions. w3m ftp://rpmf...../...86_64.rpm opens :

w3m menu

If you right-click on the terminal window (normally we don’t!!) it does show you a menu you can use to perform various actions.

You can navigate through this menu using keyboard arrow keys or even using mouse clicks. You can even use short cut keys defined for each menu item in brackets beside them.

All user interactive commands/options are shown in the lower-left corner of the terminal and choices can be submitted there only.

In all, if you are looking for a simple tool, less eye-rolling on-screen, a fast way to get the file on the server then wget is the choice you should make IMHO! Let me know which command-line tool you use for downloading internet files in comments.

How to upgrade package using YUM in RHEL

Learn step by step to upgrade the package using YUM on the RHEL system. Insights into how the package upgrade process takes place in the background.

Upgrade package using yum

YUM is a Red Hat package manager who is capable of searching available packages, install, un-install packages and update them to the latest version. In this article, we are seeing how to update the package using YUM.

You should be having superuser privilege to perform YUM updates or you can use sudo, su for performing it with superuser privilege.

You can update the single package, multiple packages, or all available packages at once. Let’s see stepwise commands for the upgrade package using YUM.

1. Check for updates :

First of all, you can check for available updates using below command :

# yum check-update
Loaded plugins: amazon-id, rhui-lb, security

ConsoleKit.x86_64                                                       0.4.1-6.el6                                          rhui-REGION-rhel-server-releases
ConsoleKit-libs.x86_64                                                  0.4.1-6.el6                                          rhui-REGION-rhel-server-releases
Red_Hat_Enterprise_Linux-Release_Notes-6-en-US.noarch                   8-2.el6                                              rhui-REGION-rhel-server-releases
abrt.x86_64                                                             2.0.8-40.el6                                         rhui-REGION-rhel-server-releases
abrt-addon-ccpp.x86_64                                                  2.0.8-40.el6                                         rhui-REGION-rhel-server-releases
abrt-addon-kerneloops.x86_64                                            2.0.8-40.el6                                         rhui-REGION-rhel-server-releases
------ output clipped -----

You will be presented with the list of packages with the available update. You can update one, multiple, or all packages at once. Dependencies during the update will be resolved and installed by YUM itself. You need not worry about them.

During any package update it goes through below steps :

  1. It checks if package update available or not
  2. It checks and resolves any dependencies
  3. It will present the user with updated information and seeks user confirmation to proceed
  4. Post confirmation it downloads the package from YUM server
  5. It installs/updates dependencies and package
  6. It cleans up stuff it created during the update
  7. It verifies package post-update
  8. Prints completion details screens and exits.

2. Update single package :

For single package update, you need to use the command yum update <package_name>

# yum update bash.x86_64
Loaded plugins: amazon-id, rhui-lb, security
Setting up Update Process
Resolving Dependencies
--> Running transaction check
---> Package bash.x86_64 0:4.1.2-33.el6_7.1 will be updated
---> Package bash.x86_64 0:4.1.2-41.el6_8 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================
 Package                    Arch                         Version                                Repository                                              Size
=============================================================================================================================================================
Updating:
 bash                       x86_64                       4.1.2-41.el6_8                         rhui-REGION-rhel-server-releases                       909 k

Transaction Summary
=============================================================================================================================================================
Upgrade       1 Package(s)

Total download size: 909 k
Is this ok [y/N]: y
Downloading Packages:
bash-4.1.2-41.el6_8.x86_64.rpm                                                                                                        | 909 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : bash-4.1.2-41.el6_8.x86_64                                                                                                                1/2
  Cleanup    : bash-4.1.2-33.el6_7.1.x86_64                                                                                                              2/2
  Verifying  : bash-4.1.2-41.el6_8.x86_64                                                                                                                1/2
  Verifying  : bash-4.1.2-33.el6_7.1.x86_64                                                                                                              2/2

Updated:
  bash.x86_64 0:4.1.2-41.el6_8

Complete!

In the above example, we updated the bash package. You can see command also tried to check and resolve any dependencies for this update process.

3. Update multiple packages :

Multiple packages can be updated using the same command but supplying more than one package name at the end.

# yum update grep.x86_64 sudo.x86_64
Loaded plugins: amazon-id, rhui-lb, security
Setting up Update Process
Resolving Dependencies
--> Running transaction check
---> Package grep.x86_64 0:2.20-3.el6_7.1 will be updated
---> Package grep.x86_64 0:2.20-5.el6_8 will be an update
---> Package sudo.x86_64 0:1.8.6p3-20.el6_7 will be updated
---> Package sudo.x86_64 0:1.8.6p3-25.el6_8 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================
 Package                    Arch                         Version                                Repository                                              Size
=============================================================================================================================================================
Updating:
 grep                       x86_64                       2.20-5.el6_8                           rhui-REGION-rhel-server-releases                       345 k
 sudo                       x86_64                       1.8.6p3-25.el6_8                       rhui-REGION-rhel-server-releases                       710 k

Transaction Summary
=============================================================================================================================================================
Upgrade       2 Package(s)

Total download size: 1.0 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): grep-2.20-5.el6_8.x86_64.rpm                                                                                                   | 345 kB     00:00
(2/2): sudo-1.8.6p3-25.el6_8.x86_64.rpm                                                                                               | 710 kB     00:00
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                        2.3 MB/s | 1.0 MB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : grep-2.20-5.el6_8.x86_64                                                                                                                  1/4
  Updating   : sudo-1.8.6p3-25.el6_8.x86_64                                                                                                              2/4
warning: /etc/sudoers created as /etc/sudoers.rpmnew
  Cleanup    : grep-2.20-3.el6_7.1.x86_64                                                                                                                3/4
  Cleanup    : sudo-1.8.6p3-20.el6_7.x86_64                                                                                                              4/4
  Verifying  : sudo-1.8.6p3-25.el6_8.x86_64                                                                                                              1/4
  Verifying  : grep-2.20-5.el6_8.x86_64                                                                                                                  2/4
  Verifying  : grep-2.20-3.el6_7.1.x86_64                                                                                                                3/4
  Verifying  : sudo-1.8.6p3-20.el6_7.x86_64                                                                                                              4/4

Updated:
  grep.x86_64 0:2.20-5.el6_8                                                  sudo.x86_64 0:1.8.6p3-25.el6_8

Complete!

In the above example, we updated grep and sudo package using single command.

4. Updating all packages at once :

Sometimes you want to avoid the hassle of updating multiple packages and want to install all available updates in a single shot. Then you can go for yum update command. Make a note that all related dependencies also gets installed/updated with this.

This is not recommended in a production environment unless you review the complete list of available updates thoroughly.

# yum update
----- output clipped -----
Transaction Summary
=============================================================================================================================================================
Install       3 Package(s)
Upgrade     243 Package(s)

Total download size: 237 M
Is this ok [y/N]: y
Downloading Packages:
(1/246): ConsoleKit-0.4.1-6.el6.x86_64.rpm                                                                                            |  83 kB     00:00
----- output clipped -----

Installed:
  kernel.x86_64 0:2.6.32-642.15.1.el6                                      python-libipa_hbac.x86_64 0:1.13.3-22.el6_8.6

Dependency Installed:
  libnl3.x86_64 0:3.2.21-8.el6

Updated:
  ConsoleKit.x86_64 0:0.4.1-6.el6                                                  ConsoleKit-libs.x86_64 0:0.4.1-6.el6
  Red_Hat_Enterprise_Linux-Release_Notes-6-en-US.noarch 0:8-2.el6                  abrt.x86_64 0:2.0.8-40.el6
  abrt-addon-ccpp.x86_64 0:2.0.8-40.el6                                            abrt-addon-kerneloops.x86_64 0:2.0.8-40.el6
----- output clipped -----

You can see I had 243 updates available, 3 new packages were available and 1 dependency has to be installed for the update process.

We have seen above all manual steps to upgrade packages using YUM. In a case where you are comfortable with updating all packages on the system without checking the available list then you can use YUM crons as well which will automate the complete process for you.

YUM-cron is service available on RHEL which runs in background and updates packages on the system automatically. See the complete YUM-cron configuration here.

All outputs in this post are from RHEL 6.8 server.