Category Archives: Linux

How to upgrade SUSE 12 SP1 to SP3 or SP4

Short article to demonstrate how to upgrade SUSE 12 SP1 to SP3 and SP4

Upgrade SUSE12 SP1 to SP4

First, you need to install zypper-migration-plugin . This plugin helps you in the migration from a lower service pack to the higher service pack.

kerneltalks:~ # zypper in zypper-migration-plugin
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:
  zypper-migration-plugin

1 new package to install.
Overall download size: 10.5 KiB. Already cached: 0 B. After the operation, additional 16.7 KiB will be used.
Continue? [y/n/? shows all options] (y): y
Retrieving package zypper-migration-plugin-0.10-9.1.noarch                                                                         (1/1),  10.5 KiB ( 16.7 KiB unpacked)
Retrieving: zypper-migration-plugin-0.10-9.1.noarch.rpm ..........................................................................................................[done]
Checking for file conflicts: .....................................................................................................................................[done]
(1/1) Installing: zypper-migration-plugin-0.10-9.1.noarch ........................................................................................................[done]

Then make sure your system is patched to the current patch level. You can use the below command to install all the latest patches.

kerneltalks:~ #  zypper patch

Now, once you are ready with the backup of the current system, proceed to migrate from SP1 to SP2. Use command zypper migration and you can see a list of service pack upgrades for your system. Although, we see that we can skip SP and upgrade to higher service packs, its

kerneltalks:~ # zypper migration

Executing 'zypper  refresh'

Refreshing service 'cloud_update'.
........
All repositories have been refreshed.

Executing 'zypper  --no-refresh patch-check --updatestack-only'

Loading repository data...
Reading installed packages...
0 patches needed (0 security patches)

Unavailable migrations (product is not mirrored):

        SUSE Linux Enterprise High Performance Computing 12 SP3 x86_64 (not available)
        SUSE Linux Enterprise Software Development Kit 12 SP3 x86_64
        Advanced Systems Management Module 12 x86_64 (already installed)
        Containers Module 12 x86_64 (already installed)
        Public Cloud Module 12 x86_64 (already installed)
        Legacy Module 12 x86_64 (already installed)
        Web and Scripting Module 12 x86_64 (already installed)
        Toolchain Module 12 x86_64 (already installed)

        SUSE Linux Enterprise High Performance Computing 12 SP2 x86_64 (not available)
        SUSE Linux Enterprise Software Development Kit 12 SP2 x86_64
        Advanced Systems Management Module 12 x86_64 (already installed)
        Containers Module 12 x86_64 (already installed)
        Public Cloud Module 12 x86_64 (already installed)
        Legacy Module 12 x86_64 (already installed)
        Web and Scripting Module 12 x86_64 (already installed)
        Toolchain Module 12 x86_64 (already installed)


Available migrations:

    1 | SUSE Linux Enterprise Server 12 SP4 x86_64
        SUSE Linux Enterprise Software Development Kit 12 SP4 x86_64
        Advanced Systems Management Module 12 x86_64 (already installed)
        Containers Module 12 x86_64 (already installed)
        Public Cloud Module 12 x86_64 (already installed)
        Legacy Module 12 x86_64 (already installed)
        Web and Scripting Module 12 x86_64 (already installed)
        Toolchain Module 12 x86_64 (already installed)

    2 | SUSE Linux Enterprise Server 12 SP3 x86_64
        SUSE Linux Enterprise Software Development Kit 12 SP3 x86_64
        Advanced Systems Management Module 12 x86_64 (already installed)
        Containers Module 12 x86_64 (already installed)
        Public Cloud Module 12 x86_64 (already installed)
        Legacy Module 12 x86_64 (already installed)
        Web and Scripting Module 12 x86_64 (already installed)
        Toolchain Module 12 x86_64 (already installed)

    3 | SUSE Linux Enterprise Server 12 SP2 x86_64
        SUSE Linux Enterprise Software Development Kit 12 SP2 x86_64
        Advanced Systems Management Module 12 x86_64 (already installed)
        Containers Module 12 x86_64 (already installed)
        Public Cloud Module 12 x86_64 (already installed)
        Legacy Module 12 x86_64 (already installed)
        Web and Scripting Module 12 x86_64 (already installed)
        Toolchain Module 12 x86_64 (already installed)


[num/q]:

You can see the migration plugin gave us the choice to jump from SP1 to SP2 or SP3 or SP4. Enter numeric against your choice and then it will upgrade related packages on your system. Here we select to go from SP1 to SP2 by tying 3.

[num/q]: 3

Executing 'snapper create --type pre --cleanup-algorithm=number --print-number --userdata important=yes --description 'before online migration''

sh: snapper: command not found
Upgrading product SUSE Linux Enterprise Server 12 SP2 x86_64.
Upgrading product SUSE Linux Enterprise Software Development Kit 12 SP2 x86_64.
Upgrading product Advanced Systems Management Module 12 x86_64.
Upgrading product Containers Module 12 x86_64.
Upgrading product Public Cloud Module 12 x86_64.
Upgrading product Legacy Module 12 x86_64.
Upgrading product Web and Scripting Module 12 x86_64.
Upgrading product Toolchain Module 12 x86_64.

Executing 'zypper --releasever 12.2 ref -f'
...................................

Once completed reboot system. Check OS version and you can see we are upgraded from SP1 to SP2

kerneltalks:~ # cat /etc/os-release
NAME="SLES"
VERSION="12-SP2"
VERSION_ID="12.2"
PRETTY_NAME="SUSE Linux Enterprise Server 12 SP2"
ID="sles"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:suse:sles:12:sp2"

Now, repeat process to upgrade OS from SP2 to SP3 and SP4.

Understanding /etc/services file in Linux

The article helps you to understand /etc/services file in Linux. Learn about content, format & importance of this file.

/etc/services file in Linux

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.

$ ll /etc/services
-rw-r--r--. 1 root root 670293 Jun  7  2013 /etc/services

/etc/services file format

service-name    port/protocol   [aliases..]  [#comment]

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.

RHEL 8 BETA installation with screenshots

Complete step by step guide of RHEL 8 BETA installation with screenshots. 

RHEL 8 BETA installation

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.

RHEL 8 installer boot screen

Select Install Red Hat Enterprise Linux 8.0 and press enter

RHEL 8 BETA installer will load into memory and you will be presented with a language selection screen.

RHEL 8 installer 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.

RHEL 8 installer notice

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 :

  1. Localization
    • Keyboard
    • Language Support
    • Time & Date
  2. Software
    • Installation Source
    • Software Selection
  3. 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 & DateClick on it and you will see below screen –

RHEL 8 installer notice

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 Done at top left corner once done.

You will come back to the installation summary screen. Click on Installation Source. It will bring up below screen –

RHEL 8 install source

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 DoneYou will be back on the installation summary screen.

Click Software Selection. You will see below screen –

RHEL 8 install software selection

Here you select base and add-ons depending on your server role. Since we are installing it for testing, we choose minimal install. Click DoneYou 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.

RHEL 8 installer manual partitioning screen

Here you can select different custom partitioning along with different volume managers. We re sticking with automatic partitioning here. Click DoneYou will be back on the installation summary screen.

Click KDUMP and you will be able to do kdump configuration.

RHEL 8 kdump configuration

You can enable/disable kdump here. Also if enabled you can specify reserve memory for it or leave to automatic. Click DoneYou 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 –

RHEL 8 hostname and network configuration

Define hostname in the lower left bottom space. To configure networking details click Configure and it will pop up below network configuration window.

RHEL 8 network configuration

Configure details. Click Save. Come back to the previous window.  Click DoneYou 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

RHEL 8 installation security policy selection screen

Once done click DoneYou will be back on installation summary screen.

Click System Purpose to define the role of server. Below window let you define your server role –

RHEL 8 installation system purpose selection screen

Select appropriately. We selected it as an RHEL, self-supported test server. Click DoneYou 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.

RHEL 8 root password setup

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

Booting RHEL 8 first time

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.

What’s new in RHEL 8

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.

Download ISO and go ahead with the install.

Do check out our article on RHEL 8 installation with screenshots.

New features in RHEL 8

Lets check out what’s new in RHEL 8

RHEL 8 is built with developers in mind! There is so much in the box for application developers.

  1. RHEL 8 comes with pre-enabled repository Application Stream (AppStream) which provides many developers tools.
  2. 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.
  3. Easy to use for developers who are new to Linux
  4. It has all cloud/container application development tools.
  5. Linux containers included in the bag
  6. cockpit is available by default in RHEL repos. A cockpit is a web-based tool used by the sysadmin to manage systems.
  7. KDE environment is deprecated from RHEL 7.6 hence it’s removed in RHEL 8
  8. GNOME v3.28 is loaded with RHEL 8.
  9. With GNOME, RHEL 8 uses Wayland as default display server instead of X.org
  10. Startis is a new volume management tool introduced.
  11. XFS file system now supports shared copy on write data extents functionality
  12. LUKS2 encryption format (default) introduced which replaces legacy LUKS1 format.
  13. DNF is rolling out behind YUM
  14. RPM v4.14 is distributed in RHEL 8 which validates entire package contents before starting installation.
  15. iptables are replaced by nftables.
  16. OpenLDAP is no more available.
  17. It has composer included. It’s used to deploy custom images in the cloud.
  18. 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
  19. OS content is available through pre-enabled repository BaseOS
  20. Supports up to 4PB of physical memory.
  21. nobody user replaced by nfsnobody
  22. KVM supports 5 level paging, increasing physical and virtual address space used by host or guest.
  23. qemu-kvm 2.12 added which has many enhancement ones being hot vCPU plug-unplug
  24. 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.

How to disable IPv6 on Linux

Short post on how to disable IPv6 in RHEL, Suse or Ubuntu Linux.

Disable IPv6 on RHEL, SUSE, Ubuntu Linux

How to disable IPv6 in RHEL 7

Edit /etc/default/grub and append ipv6.disable=1 to GRUB_CMDLINE_LINUXline like below :

GRUB_CMDLINE_LINUX="rd.lvm.lv=rhel/swap crashkernel=auto rd.lvm.lv=rhel/root ipv6.disable=1"

Now, you need to regenerate the grub.cfg file by running the grub2-mkconfig command :

root@kerneltalks # grub2-mkconfig -o /boot/grub2/grub.cfg

That’s it. Reboot and it will disable IPv6 on your system.

Another method is to disable it using /etc/sysctl.d/ipv6.conf file.

Add below entry in file :

# To disable for all interfaces
net.ipv6.conf.all.disable_ipv6 = 1
#Disable default
net.ipv6.conf.default.disable_ipv6 = 1
#Disable on loopback
net.ipv6.conf.lo.disable_ipv6 = 1

Now, reload sysctl file,

root@kerneltalks # sysctl -p /etc/sysctl.d/ipv6.conf

You need to re-build the Initial RAM Disk as well. You can do it using :

root@kerneltalks # dracut -f

That’s it. You are done.

Disable IPv6 in RHEL 6

Create a new file /etc/modprobe.d/ipv6.conf with below one liner –

root@kerneltalks # echo "options ipv6 disable=1" >/etc/modprobe.d/ipv6.conf

Stop ip6tables service from loading at boot by using chkconfig

root@kerneltalks # chkconfig ip6tables off

And you are done Reboot the system to run it without IPv6.

Disable IPv6 in Suse Linux

Add below lines in /etc/sysctl.conf

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

Reload file with sysctl -p and you are done.

If you are having GUI access of server then  you can do it under network settings. Navigate to Applications > System Tools > YaST > Network Settings . Goto Global Options tab and uncheck Enable IPv6.

Disable ipv6 in suse

You will require to reboot server to take this effect.

Disable IPv6 in Ubuntu Linux

Above process of Suse Linux applies to ubuntu as well. You need to edit /etc/sysctl.conf and add above lines. Reload the file with sysctl -p and you are done.

To verify if IPv6 is disabled on server use below command –

root@kerneltalks # cat /proc/sys/net/ipv6/conf/all/disable_ipv6

If output is 1 then IPv6 is disabled. If output is 0 then IPv6 is enabled.

Format date and time for Linux shell script or variable

Learn how to format date and time to use in a shell script or as a variable along with different format examples.

Date formats

There are many times you need to use date in your shell script e.g. to name log file, to pass it as a variable, etc. So we need a different format of dates that can be used as a string or variable in our scripts. In this article, let’s see how to use date in shell script and what all different types of formats you can use.

  • Check timedatectl command to easily manage date & time in Linux

How to use date in shell script?

You can use the date by inserting shell execution within the command. For example, if you want to create a log file by inserting the current date in it, you can do it by following way –

root@kerneltalks # echo test > /tmp/`date +%d`.txt
root@kerneltalks # ls -lrt
-rw-r--r--. 1 root  root     5 Sep 10 09:10 10.txt

Basically you need to pass format identifier with +% to date command to get your desired format of the output. There is a different identifier date command supply.

You can even save specific date format to some variable like –

root@kerneltalks # MYDATE=`date +%d.%b.%Y`
root@kerneltalks # echo $MYDATE
10.Sep.2018

Different format variables for date command

These format identifiers are from date command man page :

%a     locale’s abbreviated weekday name (e.g., Sun)
%A     locale’s full weekday name (e.g., Sunday)
%b     locale’s abbreviated month name (e.g., Jan)
%B     locale’s full month name (e.g., January)
%c     locale’s date and time (e.g., Thu Mar  3 23:05:25 2005)
%C     century; like %Y, except omit last two digits (e.g., 20)
%d     day of month (e.g, 01)
%D     date; same as %m/%d/%y
%e     day of month, space padded; same as %_d
%F     full date; same as %Y-%m-%d
%g     last two digits of year of ISO week number (see %G)
%G     year of ISO week number (see %V); normally useful only with %V
%h     same as %b
%H     hour (00..23)
%I     hour (01..12)
%j     day of year (001..366)
%k     hour ( 0..23)
%l     hour ( 1..12)
%m     month (01..12)
%M     minute (00..59)
%N     nanoseconds (000000000..999999999)
%p     locale’s equivalent of either AM or PM; blank if not known
%P     like %p, but lower case
%r     locale’s 12-hour clock time (e.g., 11:11:04 PM)
%R     24-hour hour and minute; same as %H:%M
%s     seconds since 1970-01-01 00:00:00 UTC
%S     second (00..60)
%T     time; same as %H:%M:%S
%u     day of week (1..7); 1 is Monday
%U     week number of year, with Sunday as first day of week (00..53)
%V     ISO week number, with Monday as first day of week (01..53)
%w     day of week (0..6); 0 is Sunday
%W     week number of year, with Monday as first day of week (00..53)
%x     locale’s date representation (e.g., 12/31/99)
%X     locale’s time representation (e.g., 23:13:48)
%y     last two digits of year (00..99)
%Y     year
%z     +hhmm numeric timezone (e.g., -0400)
%:z    +hh:mm numeric timezone (e.g., -04:00)
%::z   +hh:mm:ss numeric time zone (e.g., -04:00:00)
%Z     alphabetic time zone abbreviation (e.g., EDT)

Using combinations of above you can get your desired date format as output to use in shell script! You can even use %n for new-line and %t for adding a tab in outputs that are mostly not needed since you will be using it as a single string.

Different date format examples

For your convenience and ready to use, I listed below combinations for different date formats.

root@kerneltalks # date +%d_%b_%Y
10_Sep_2018

root@kerneltalks # date +%D
09/10/18

root@kerneltalks # date +%F-%T
2018-09-10-11:09:51

root@kerneltalks # echo today is  `date +%A`
today is Monday

root@kerneltalks # echo Its `date +%d` of `date +%B" "%Y` and time is `date +%r`
Its 10 of September 2018 and time is 11:13:42 AM

Why ps output shows UID instead of username

Learn why ps output shows UID instead of username.

PS reads UID instead of username in output

One of our reader asked me:

I see userid in place of the username in ps -ef command output, please explain.

In this article, we will see why ps output shows UID instead of username sometimes. In some recent Linux distributions like RHEL 7, it shows cropped username ending with + sign. Let’s see the reason behind ps doesn’t show username.

Normal ps -ef command output looks like below –

root       541     1  0 17:48 ?        00:00:00 /usr/sbin/NetworkManager --no-da
root       559   541  0 17:48 ?        00:00:00 /sbin/dhclient -d -q -sf /usr/li
root       791     1  0 17:48 ?        00:00:00 /usr/bin/python -Es /usr/sbin/tu
root      1067     1  0 17:48 ?        00:00:00 /usr/libexec/postfix/master -w

where the first column is username who owns that particular process. Sometimes you see output like below –

kernelt+  1354  1335  0 17:50 pts/0    00:00:00 top
OR
1001  1354  1335  0 17:50 pts/0    00:00:00 top

where username in ps output is numeric or cropped username ending with +

This is because ps -ef output restricts username up to 8 characters. If your username is longer than 8 characters then it will display UID or cropped version of it. Here we have kerneltalks user on our server.

# cat /etc/passwd |grep kernel
kerneltalks:x:1001:1001::/home/kerneltalks:/bin/bash

If you observe, user kerneltalks has UID 1001 and hence we could see that UID in ps -ef output.

Documentary films on Linux!

The Code & Revolution OS! Documentary films on Linux released in 2001.

Documentary films on Linux

Yup, you read it right. The Code & Revolution OS! Those are documentary films released in 2001. The Code is based on birth and journey of Linux & Revolution OS is based on 20 years journey of Linux, GNU, Open Source world.

Have you watched them?

The Code (Wiki Page) is a 58-minute documentary featuring the creator of Linux, Linus Torvalds, and some of the programmers who contributed to Linux. And yeah, there is a piece of the interview where Linus talks about developers of India! Since I am from India, I feel like mentioning it here 🙂

Revolution OS is (Wiki Page) is 85 minutes long documentary which spans over 20 years journey of free software movement through Linux, GNU, and Open Source.

Documentary films are available on YouTube along with subtitles.

The Code : https://www.youtube.com/watch?v=XMm0HsmOTFI

Revolution OS : https://www.youtube.com/watch?v=GsHh2wfy_-4

Embedded versions below if you wanna watch it right way 🙂

If you know some more titles, let me know in the comments I will add them up in the list.

4 ways to check the size of physical memory (RAM) in Linux

An article explaining how to check physical memory (RAM) in the Linux server. 4 different commands to get memory information from the Linux server.

Checking physical memory (RAM)

In this article we will see basic commands to check physical memory on a server in Linux. Many beginners struggle with knowing their system well in context to resources like CPU, Memory, disks, etc. So I decided to write this small article pinpointing commands to check RAM on the Linux server. These commands will work in different flavors of Linux like Red Hat, CentOS, Suse, Ubuntu, Fedora, Debian, etc.

Without much delay lets dive into commands –

1. Using free command

The first command is free. This is the simplest command to check your physical memory. This command is mainly used for checking RAM and SWAP on the system. Using different switch you can change the byte-format of output. Like -b for bytes, -k for kilobytes, -m for megabytes and -g for gigabytes.

Check row with Mem: and number against it. That’s the physical RAM of your server.

root@kerneltalks # free -b
             total       used       free     shared    buffers     cached
Mem:    135208493056 1247084544 133961408512          0  175325184  191807488
-/+ buffers/cache:  879951872 134328541184
Swap:   17174347776          0 17174347776

root@kerneltalks # free -k
             total       used       free     shared    buffers     cached
Mem:     132039544    1218368  130821176          0     171216     187316
-/+ buffers/cache:     859836  131179708
Swap:     16771824          0   16771824

root@kerneltalks # free -m
             total       used       free     shared    buffers     cached
Mem:        128944       1189     127754          0        167        182
-/+ buffers/cache:        839     128105
Swap:        16378          0      16378

root@kerneltalks # free -g
             total       used       free     shared    buffers     cached
Mem:           125          1        124          0          0          0
-/+ buffers/cache:          0        125
Swap:           15          0         15

In the above output you can see the system is installed with 125GB of physical RAM (observe highlighted rows). By using a different switch -b, -k, -m and -g output changed numbers according to selected byte-format.

2. Using /proc/meminfo file

Another way is to read memory info from the proc filesystem. /proc/meminfo is the file you should read to get detailed information about memory. The very first line or line starts with MemTotal is your total physical memory on the server.

root@kerneltalks # cat /proc/meminfo |grep MemTotal
MemTotal:       132039544 kB

As you can see from output, memory is displayed in kilobytes.

3. Using top command

The famous top command also lists physical memory information in a very clear way. In the upper section of the top command output lies the CPU, Memory, and SWAP information.

root@kerneltalks # top
top - 16:03:41 up 89 days,  3:43,  1 user,  load average: 0.00, 0.01, 0.05
Tasks: 141 total,   1 running, 140 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:  132039544k total,  1218336k used, 130821208k free,   171224k buffers
Swap: 16771824k total,        0k used, 16771824k free,   187420k cached

I clipped the above section of the top command output in the above example. Check second last line saying Mem: (highlighted row). This shows physical memory in kilobytes. You can see the total, used, and free portions of it. Total is your actual RAM installed on the server.

4. Using vmstat

Another way is to use vmstat (virtual memory stats) command with -s switch. This will list memory in detail with the first-line being total memory on the server.

# vmstat -s
    132039544  total memory
      1218692  used memory
       181732  active memory
----output trimmed----

Memory is displayed in kilobytes by default. The very first line shows you total memory on the server.

Difference between /etc/passwd and /etc/shadow

Learn about the difference between /etc/passwd and /etc/shadow files in the Linux system. 9 points to understand the comparison of these two files.

/etc/passwd vs /etc/shadow

Its one of the Linux beginners interview question explain the difference between /etc/passwd and /etc/shadow files or compare passwd and shadow files in Linux. Basically both files serve different purposes on the system so it’s not completely logical to compare them but still if you want to we have this article for you explaining  /etc/passwd vs /etc/shadow.

Before reading ahead, if you are not sure about these files read our articles explaining these files field by field.

Difference between /etc/passwd and /etc/shadow

  1. File formats are the same i.e. fields separated by colons & new row for each user. But the number of fields is different. passwd file has 7 fields whereas the shadow file has 8 fields.
  2. All fields are different except for the first one. It’s the same for both files and is the username.
  3. /etc/passwd file aims at user account details while /etc/shadow aims at the user’s password details.
  4. the passwd file is world-readable. shadow file can only be read by the root account.
  5. The user’s encrypted password can only be stored in /etc/shadow file.
  6. pwconv command is used to generate a shadow file from the passwd file if it doesn’t exist.
  7. passwd file exists by default when the system is installed.
  8. passwd file information is more of a static (home directory, shell, uid, gid which hardly changes)
  9. shadow file information changes frequently since its related to password and user password changes frequently (if not, password policies are loosely defined!)