Categories

A sample text widget

Etiam pulvinar consectetur dolor sed malesuada. Ut convallis euismod dolor nec pretium. Nunc ut tristique massa.

Nam sodales mi vitae dolor ullamcorper et vulputate enim accumsan. Morbi orci magna, tincidunt vitae molestie nec, molestie at mi. Nulla nulla lorem, suscipit in posuere in, interdum non magna.

CentOS 6.9 Docker

CentOS 6.9 Docker

public key

rpm –import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

ELRepo
Centos6?

rpm -Uvh http://www.elrepo.org/elrepo-release-6-6.el6.elrepo.noarch.rpm

Cenos7?

rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm (external link)

kernel

yum –enablerepo=elrepo-kernel install -y kernel-lt

yum –enablerepo=elrepo-kernel install -y kernel-ml

vi /etc/grub.conf

default

# grub.conf generated by anaconda
#
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (3.10.28-1.el6.elrepo.x86_64)
root (hd0,0)
kernel /boot/vmlinuz-3.10.28-1.el6.elrepo.x86_64 ro root=UUID=0a05411f-16f2-4d69-beb0-2db4cefd3613 rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD crashkernel=auto.UTF-8 rd_NO_LVM rd_NO_DM rhgb quiet
initrd /boot/initramfs-3.10.28-1.el6.elrepo.x86_64.img
title CentOS (2.6.32-431.3.1.el6.x86_64)
root (hd0,0)
kernel /boot/vmlinuz-2.6.32-431.3.1.el6.x86_64 ro root=UUID=0a05411f-16f2-4d69-beb0-2db4cefd3613 rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD crashkernel=auto.UTF-8 rd_NO_LVM rd_NO_DM rhgb quiet
initrd /boot/initramfs-2.6.32-431.3.1.el6.x86_64.img

docker

?1?selinux

selinux LXCselinux

vi /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing – SELinux security policy is enforced.
# permissive – SELinux prints warnings instead of enforcing.
# disabled – SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
# targeted – Only targeted network daemons are protected.
# strict – Full SELinux protection.
SELINUXTYPE=targeted

Fedora EPEL

yum -y install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

?3?docker

docker-io

yum install -y docker-io

?4?docker

service docker start

?5?docker

docker version

Client version: 1.7.1
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 786b29d/1.7.1
OS/Arch (client): linux/amd64
Server version: 1.7.1
Server API version: 1.19
Go version (server): go1.4.2
Git commit (server): 786b29d/1.7.1
OS/Arch (server): linux/amd64

docker hello-world

hello-world

docker pull hello-world

hello-world

docker run hello-world

Hello from Docker.
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the “hello-world” image from the Docker Hub.
(Assuming it was not already locally available.)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

For more examples and ideas, visit:
http://docs.docker.com/userguide/

yum list installed | grep docker

yum -y remove docker-io.x86_64

rm -rf /var/lib/docker

weblogic 12c

WebLogic Server 12c (12.1.1)

http://www.oracle.com/technetwork/middleware/weblogic/downloads/wls-main-097127.html

Installers with Oracle WebLogic Server and Oracle Coherence:?Generic (997 MB)

wls1211_generic.jar

java -jar wls1211_generic.jar

java -jar wls1211_generic.jar -mode=console

java -jar wls1211_generic.jar -log=D:\wlog\wsl_install.log

Enter username to boot WebLogic server:weblogic
Enter password to boot WebLogic server:

home/weblogic_12c/user_projects/domains/base_domain/servers/AdminServer/security
boot.properties

username=weblogic
password=weblogic

nohup ./startWebLogic.sh

Install Gnome GUI on CentOS 7 / RHEL 7

Install Gnome GUI on CentOS 7 / RHEL 7

Linux admins spend most of their time on working in a terminal; there are some who like to work on GUI instead of a terminal. By default, CentOS 7 installed as the minimal server, and user intervention is required to change the installation type. This guide will help you to install GUI on CentOS 7 on the top of the minimal server installation.

Before installing GUI, make a Local Yum Repository to avoid downloading packages from the internet.

Optional: Run the following command to list down the available package groups for CentOS 7.

# yum group list

Output:

Loaded plugins: fastestmirror
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
Available Environment Groups:
 Minimal Install
 Compute Node
 Infrastructure Server
 File and Print Server
 Basic Web Server
 Virtualization Host
 Server with GUI
 GNOME Desktop
 KDE Plasma Workspaces
 Development and Creative Workstation
Available Groups:
 Compatibility Libraries
 Console Internet Tools
 Development Tools
 Graphical Administration Tools
 Legacy UNIX Compatibility
 Scientific Support
 Security Tools
 Smart Card Support
 System Administration Tools
 System Management
Done

Step 1: Install Gnome GUI using the YUM command.

CentOS 7

# yum groupinstall "GNOME Desktop" "Graphical Administration Tools"

RHEL 7

# yum groupinstall "Server with GUI"

Step 2: Enable GUI on system startup. In CentOS 7,  systemd uses “targets” instead of runlevel. The /etc/inittab file is no more used to change run levels. So, issue the following command to enable the GUI on system start.

# ln -sf /lib/systemd/system/runlevel5.target /etc/systemd/system/default.target

Step 3: Reboot the machine to start the server in the graphical mode.

# reboot

Performance Co-Pilot (PCP) on my RHEL server to capture performance logs

# run these commands on a Centos 7 server as root
yum install -y pcp pcp-webapi pcp-system-tools
chkconfig pmcd on
service pmcd start
chkconfig pmlogger on
service pmlogger start
chkconfig pmwebd on
service pmwebd start
# open port 44323 in the firewall
# To start vector on your laptop
docker run -d –name vector -p 80:80 netflixoss/vector:latest

open http://localhost

 

Performance Co-Pilot (PCP) on my RHEL server to capture performance logs

 

RHEL 7 (prior to RHEL 7.4)

PCP is included in the base RHEL and Fedora distributions. A minimal installation requires just the pcp package (and its dependencies) to enable performance data logs to be collected for later analysis:

yum install pcp
systemctl enable pmcd
systemctl enable pmlogger
systemctl start pmcd
systemctl start pmlogger



pcp

pmstat

pmatop

pmcollectl


At the moment Vector comes with the following list of widgets and dashboards that can be easily extended. Here is a short list of metrics available by default.

CPU

  • Load Average
  • Runnable
  • CPU Utilization
  • Per-CPU Utilization
  • Context Switches

Memory

  • Memory Utilization
  • Page Faults

Disk

  • Disk IOPS
  • Disk Throughput
  • Disk Utilization
  • Disk Latency

Network

  • Network Drops
  • TCP Retransmits
  • TCP Connections
  • Network Throughput
  • Network Packets

“This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.”

two solutions

  1. in the plugin configuration file disable plugin

    vim /etc/yum/pluginconf.d/subscription-manager.conf

    enabled=0

  2. or register to the satellite

ps command #1 – Basic

A linux command to monitor the system process consuming resources on the server. If you are working on a linux system it is good to have at least basic understanding of this command.

ps program or command when run take a snapshot of running processes at that time and display on the terminal which can be used to analyse the system performance or identify any problematic process which can be a risk for system.

ps Command:


When we run simple ps command, it will display very basic information –

$ ps
  PID TTY          TIME CMD
22396 pts/0    00:00:00 su
22402 pts/0    00:00:00 bash
22417 pts/0    00:00:00 su
22420 pts/0    00:00:00 bash
23332 pts/0    00:00:00 ps
PID – process id
TTY – terminal in which process is running
TIME – total cpu time taken till now
CMD – command

Let’s try with one argument -f (full)

$ ps -f
UID PID PPID C STIME TTY TIME CMD
root 22396 22377 0 09:49 pts/0 00:00:00 su
root 22402 22396 0 09:49 pts/0 00:00:00 bash
root 22417 22402 0 09:50 pts/0 00:00:00 su
root 22420 22417 0 09:50 pts/0 00:00:00 bash
root 23337 22420 0 11:02 pts/0 00:00:00 ps -f

this output is display with some more information –
UID – process owner user id
PPID – parent process id
STIME – process start time

Let’s play with some argument and see what will be the output look like –

$ ps -ef

mohan 7585 1 0 18:29 ? 00:00:00 /usr/libexec/gvfsd-http –spawner :1.7 /org/gtk/gvfs/exec_spaw/2
root 16991 1 0 Dec04 ? 00:00:00 /usr/sbin/bluetoothd –udev
mohan 17099 1 0 Dec04 ? 00:09:26 /usr/lib64/firefox/firefox
mohan 22246 1 0 19:28 ? 00:00:05 gnome-terminal
mohan 22248 22246 0 19:28 ? 00:00:00 gnome-pty-helper
mohan 22377 22246 0 19:35 pts/0 00:00:00 bash
root 22396 22377 0 19:35 pts/0 00:00:00 su
root 22402 22396 0 19:35 pts/0 00:00:00 bash
root 22417 22402 0 19:35 pts/0 00:00:00 su
root 22420 22417 0 19:35 pts/0 00:00:00 bash
mohan 22937 1 0 20:06 ? 00:00:00 gedit
root 23282 1899 0 20:47 ? 00:00:00 /usr/libexec/hald-addon-rfkill-killswitch
root 24348 1810 0 22:07 ? 00:00:00 /sbin/dhclient -d -4 -sf /usr/libexec/nm-dhcp-client.action -pf /var/run/dhclient-eth1.pid -lf /var/lib/dhclient/dhclient-e738be73-e337-4f64-865e-aa936ac77c14-eth1.lease -cf /var/run/nm-dhclient-eth1.conf eth1
mohan 27098 1236 2 22:23 ? 00:00:00 /usr/lib/rstudio-server/bin/rsession -u mohan
root 27112 1 0 22:23 ? 00:00:00 /usr/libexec/fprintd

All process
To see all processes on the system (along with the command line arguments used to start each process) you could use:

$ ps aux

Processes for User
To see all processes for a particular user (along with the command line arguments for each process) you could use:

$ ps U <username> u

$ ps U mohan u

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
mohan 2695 0.0 0.0 229128 672 ? Sl Dec03 0:00 /usr/bin/gnome-keyring-daemon –daemonize –login
mohan 2705 0.0 0.1 253264 1888 ? Ssl Dec03 0:01 gnome-session
mohan 2713 0.0 0.0 20040 128 ? S Dec03 0:00 dbus-launch –sh-syntax –exit-with-session
mohan 2714 0.0 0.1 32476 1356 ? Ssl Dec03 0:01 /bin/dbus-daemon –fork –print-pid 5 –print-address 7 –session
mohan 2732 0.0 0.3 133360 3636 ? S Dec03 0:06 /usr/libexec/gconfd-2
mohan 2740 0.0 0.3 507280 3408 ? Ssl Dec03 0:26 /usr/libexec/gnome-settings-daemon
mohan 2741 0.0 0.1 286220 1624 ? Ss Dec03 0:00 seahorse-daemon
mohan 2746 0.0 0.0 137388 844 ? S Dec03 0:00 /usr/libexec/gvfsd
mohan 2760 0.0 0.5 447048 5116 ? Sl Dec03 0:25 metacity
mohan 2767 0.0 0.7 502416 7600 ? Sl Dec03 0:34 gnome-panel
mohan 2769 0.0 0.3 450232 3156 ? S<sl Dec03 0:35 /usr/bin/pulseaudio –start –log-target=syslog
mohan 2772 0.0 0.0 94828 252 ? S Dec03 0:00 /usr/libexec/pulse/gconf-helper
mohan 2773 0.0 5.6 1199004 57544 ? Sl Dec03 1:18 nautilus
mohan 2775 0.0 0.0 696412 256 ? Ssl Dec03 0:00 /usr/libexec/bonobo-activation-server –ac-activate –ior-output-fd=18
mohan 2778 0.0 0.2 30400 2212 ? S Dec03 0:00 /usr/sbin/restorecond -u
mohan 2783 0.0 0.4 469076 4244 ? Sl Dec03 0:02 gpk-update-icon
mohan 2786 0.0 0.0 146404 900 ? S Dec03 0:00 /usr/libexec/gvfs-gdu-volume-monitor
mohan 2787 0.0 0.2 375072 2924 ? S Dec03 0:00 gnome-volume-control-applet
mohan 2788 0.0 0.5 331480 5988 ? S Dec03 0:48 /usr/libexec/wnck-applet –oaf-activate-iid=OAFIID:GNOME_Wncklet_Factory –oaf-ior-fd=18
mohan 2789 0.0 0.2 476996 2900 ? Sl Dec03 0:00 /usr/libexec/trashapplet –oaf-activate-iid=OAFIID:GNOME_Panel_TrashApplet_Factory –oaf-ior-fd=24

Process tree
A process tree shows the child/parent relationships between processes. (When a process spawns another process, the spawned is called a child process while the other is the parent)

$ ps afjx

 

 

Usually, when we are monitoring process, we are targeting something which can impact our server performance or some specific process. For doing so we grep the ps output –

This is how we call list all http processes –

$ ps aux | grep http
atul      7585  0.0  0.0 177676   592 ?        S    Dec06   0:00 /usr/libexec/gvfsd-http --spawner :1.7 /org/gtk/gvfs/exec_spaw/2
root     28848  0.0  0.0   2700   168 pts/0    D+   02:49   0:00 grep http

you can filter ps command output by any keyword as above.

There are some ps options which can give you a customized output –

To see every process on the system using standard syntax:

$ ps -e
$ ps -ef
$ ps -eF
$ ps -ely
 To see every process on the system using BSD syntax:

$ ps ax
$ ps axu

To print a process tree:

$ ps -ejH
$ ps axjf

To get info about threads:

$ ps -eLf
$ ps axms

To get security info:

$ ps -eo euser,ruser,suser,fuser,f,comm,lable
$ ps axZ
$ ps -eM

To see every process running as root (real & effective ID) in user format:

$ ps -U root -u root u

To see every process with a user-defined format:

$ ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm
$ ps axo stat,euid,ruid,tty,tpgid,sess,pgrp,ppid,pid,pcpu,comm
$ ps -eopid,tt,user,fname,tmout,f,wchan

Print only the process IDs of process syslogd:

$ ps -C syslogd -o pid=
 #ps -C <process_name> -o pid=

Print only the name of PID 42:

$ ps -p 42 -o comm=
  #ps -p <process_id> -o comm=

We can sort the ps command output by unix sort also which is easy to use. Need to pass ps command output to sort command with proper argument and Volla !! You will get the output as you want.

Let’s see how this is work [ sort command arguement can differ per your linux flavour and version ]
I am using – CentOS 6.3

1. Display the top CPU consuming process (Column 3 – %CPU)

$ ps aux | head -1; ps aux | sort -k3 -nr |grep -v ‘USER’| head

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND

mohan 21210 2.0 0.1 110232 1140 pts/3 R+ 00:13 0:00 ps aux
hduser 2671 0.8 4.1 960428 42436 pts/1 Sl+ Aug22 5:29 mongod
root 1447 0.2 0.3 185112 3384 ? Sl Aug22 1:36 /usr/sbin/vmtoolsd
mohan 2478 0.2 2.1 448120 21876 ? Sl Aug22 1:51 /usr/lib/vmware-tools/sbin64/vmtoolsd -n vmusr –blockFd 3
rtkit 2359 0.1 0.1 168448 1204 ? SNl Aug22 0:44 /usr/libexec/rtkit-daemon
root 7 0.1 0.0 0 0 ? S Aug22 0:53 [events/0]
root 2204 0.1 4.3 147500 43872 tty1 Ss+ Aug22 0:45 /usr/bin/Xorg :0 -nr -verbose -audit 4 -auth /var/run/gdm/auth-for-gdm-wEmBs1/database -nolisten tcp vt1
root 920 0.0 0.0 0 0 ? S Aug22 0:00 [bluetooth]
root 9 0.0 0.0 0 0 ? S Aug22 0:00 [khelper]
root 8 0.0 0.0 0 0 ? S Aug22 0:00 [cgroup]

For my linux sort command arguements are —
-kn ==> This use to select the column n, such as for column 4, -k4
-n ==> column is numeric
-r ==> reverse order

sort -k3 -nr ==> sort the third column of output in numeric reverse sort (largest to smallest)

2. Display the top 10 memory consuming process (Column 4 – %MEM)

$ ps aux | head -1; ps aux | sort -k4 -nr |grep -v ‘USER’| head

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND

root 2204 0.1 4.3 147500 43872 tty1 Ss+ Aug22 0:46 /usr/bin/Xorg :0 -nr -verbose -audit 4 -auth /var/run/gdm/auth-for-gdm-wEmBs1/database -nolisten tcp vt1
hduser 2671 0.8 4.1 960428 42436 pts/1 Sl+ Aug22 5:32 mongod
mohan 2458 0.0 2.3 943204 23624 ? S Aug22 0:16 nautilus
mohan 2516 0.0 2.2 275280 22316 ? Ss Aug22 0:06 gnome-screensaver
mohan 2478 0.2 2.1 448120 21876 ? Sl Aug22 1:52 /usr/lib/vmware-tools/sbin64/vmtoolsd -n vmusr –blockFd 3
mohan 2507 0.0 1.6 321388 16680 ? S Aug22 0:01 python /usr/share/system-config-printer/applet.py
mohan 2589 0.0 1.4 292556 14600 ? Sl Aug22 0:14 gnome-terminal
mohan 2536 0.0 1.3 395832 13372 ? S Aug22 0:00 /usr/bin/gnote –panel-applet –oaf-activate-iid=OAFIID:GnoteApplet_Factory –oaf-ior-fd=22
mohan 2502 0.0 1.3 474620 13952 ? Sl Aug22 0:01 gpk-update-icon
mohan 2537 0.0 1.2 459964 12736 ? S Aug22 0:10 /usr/libexec/clock-applet –oaf-activate-iid=OAFIID:GNOME_ClockApplet_Factory –oaf-ior-fd=34

3. Display the process by time (Column 4 – TIME)

$ ps vx | head -1; ps vx | sort -k4 -r| grep -v ‘PID’ | head

PID TTY STAT TIME MAJFL TRS DRS RSS %MEM COMMAND 2478 ? Sl 1:52 351 593 447526 21876 2.1 /usr/lib/vmware-tools/sbin64/vmtoolsd -n vmusr –blockFd 3
2458 ? S 0:16 228 1763 941440 23624 2.3 nautilus
2589 ? Sl 0:15 28 296 292259 14600 1.4 gnome-terminal
2421 ? Ssl 0:14 22 34 500541 9676 0.9 /usr/libexec/gnome-settings-daemon
2479 ? S 0:13 23 403 310472 11996 1.1 nm-applet –sm-disable
2537 ? S 0:10 37 168 459795 12736 1.2 /usr/libexec/clock-applet –oaf-activate-iid=OAFIID:GNOME_ClockApplet_Factory –oaf-ior-fd=34
2444 ? Ssl 0:10 25 64 445791 4872 0.4 /usr/bin/pulseaudio –start –log-target=syslog
2445 ? S 0:07 51 593 322206 12684 1.2 gnome-panel
2516 ? Ss 0:06 4 151 275128 22316 2.2 gnome-screensaver
2522 ? Sl 0:05 5 41 231870 1960 0.1 /usr/libexec/gvfs-afc-volume-monitor

4. Display the top 10 real memory usage process (Column 8 – RSS)

$ ps vx | head -1; ps vx | sort -k8 -nr| grep -v ‘PID’ | head

PID TTY STAT TIME MAJFL TRS DRS RSS %MEM COMMAND
2458 ? S 0:16 228 1763 941440 23624 2.3 nautilus
2516 ? Ss 0:06 4 151 275128 22316 2.2 gnome-screensaver
2478 ? Sl 1:52 351 593 447526 21876 2.1 /usr/lib/vmware-tools/sbin64/vmtoolsd -n vmusr –blockFd 3
2507 ? S 0:01 73 2 321385 16680 1.6 python /usr/share/system-config-printer/applet.py
2589 ? Sl 0:15 28 296 292259 14600 1.4 gnome-terminal
2502 ? Sl 0:01 29 257 474362 13952 1.3 gpk-update-icon
2536 ? S 0:00 92 1607 394224 13372 1.3 /usr/bin/gnote –panel-applet –oaf-activate-iid=OAFIID:GnoteApplet_Factory –oaf-ior-fd=22
2537 ? S 0:10 37 168 459795 12744 1.2 /usr/libexec/clock-applet –oaf-activate-iid=OAFIID:GNOME_ClockApplet_Factory –oaf-ior-fd=34
2445 ? S 0:07 51 593 322206 12684 1.2 gnome-panel
2438 ? Sl 0:03 30 542 433105 12512 1.2 metacity

Like above examples you can create so many one liners for you. But before using anyone of above one command, check your ps and sort command behavior then use them.
Mostly, every other shell has its own argument for ps and sort but basics are same. For sorting any command output by particular column first understand that output/column and then use sort commnd.

memory usage in Linux per process

Not because I really want to; but because I just don’t have the money to spend on a 2+ GB RAM VPS and I would like to run Jira.

In order to do this I keep a close eye on the processes running and how much memory each takes.

For this I found (and tweaked) the following bash command (originally found here):

ps -eo size,pid,user,command --sort -size | awk '{ hr=$1/1024 ; printf("%13.2f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }'

This command will output every process and its memory usage in human readable (thus megabytes) format. For your convenience it is sorted by memory size descending (from highest to lowest).

An example of its use:

test@rmohan.com:~$ ps -eo size,pid,user,command --sort -size | awk '{ hr=$1/1024 ; printf("%13.2f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }'
0.00 Mb COMMAND
116.18 Mb /usr/sbin/mysqld
11.58 Mb /usr/sbin/apache2 -k start
11.58 Mb /usr/sbin/apache2 -k start
11.58 Mb /usr/sbin/apache2 -k start

(I am sure I can tune the above to use less memory; this is merely an example)

I hope it will be as useful to you as it is to me,

Top Show Running Processes

he Linux top command is used to show all the running processes within your Linux environment. This guide shows you how to use the top command by explaining the different switches available and the information that is displayed:

How To Run The Top Command

In its basic form all you need to do to show the current processes is type the following in a Linux terminal:

top

What Information Is Shown:

The following information is displayed when you run the Linux top command:

Line 1

  • The time
  • How long the computer has been running
  • Number of users
  • Load average

The load average shows the system load time for the last 1, 5 and 15 minutes.

Line 2

 

Line 3

  • CPU usage as a percentage by the user
  • CPU usage as a percentage by system
  • CPU usage as a percentage by low priority processes
  • CPU usage as a percentage by idle processes
  • CPU usage as a percentage by io wait
  • CPU usage as a percentage by hardware interrupts
  • CPU usage as a percentage by software interrupts
  • CPU usage as a percentage by steal time

This guide gives a definition of what CPU usage means.

Line 3

Line 4

  • Total swap available
  • Total swap free
  • Total swap used
  • Available memory

This guide gives a description of swap partitions and whether you need them.

Main Table

  • Process ID
  • User
  • Priority
  • Nice level
  • Virtual memory used by process
  • Resident memory used by a process
  • Shareable memory
  • CPU used by process as a percentage
  • Memory used by process as a percentage
  • Time process has been running
  • Command

Here is a good guide discussing computer memory.

Keep Linux Top Running All The Time In The Background

You can keep the top command easily available without having to type the word top each time into your terminal window.

To pause top so that you can continue using the terminal, press CTRL and Z on the keyboard.

To bring top back to the foreground, type fg.

Key Switches For The Top Command:

  • -h – Show the current version
  • -c – This toggles the command column between showing command and program name
  • -d – Specify the delay time between refreshing the screen
  • -o – Sorts by the named field
  • -p – Only show processes with specified process IDs
  • -u – Show only processes by the specified user
  • -i – Do not show idle tasks

Show The Current Version

Type the following to show the current version details for top:

top -h

Output is in the form procps -ng version 3.3.10

Specify A Delay Time Between Screen Refreshes

To specify a delay between the screen refreshes whilst using top type the following:

top -d

To refresh every 5 seconds type top -d 5

Obtain A List Of Columns To Sort By

To get a list of the columns with which you can sort the top command by type the following:

top -O

There are a lot of columns so you might wish to pipe the output to less as follows:

top -O | less

Sort The Columns In The Top Command By A Column Name

Use the previous section to find a column to sort by and then use the following syntax to sort by that column:

top -o

To sort by %CPU type the following:

top -o %CPU

Only Show The Processes For A Specific User

To show only the processes that a specific user is running use the following syntax:

top -u

For example to show all the processes that the user gary is running type the following:

top -u gary

Hide Idle Tasks

The default top view can seem cluttered and if you want to see only active processes (i.e those that are not idle) then you can ran the top command using the following command:

top -i

Adding Extra Columns To The Top Display

Whilst running top you can press the ‘F’ key which shows the list of fields that can be displayed in the table:

Use the arrow keys to move up and down the list of fields.

To set a field so that it is displayed on the screen press the ‘D’ key. To remove the field press “D” on it again. An asterisk (*) will appear next to displayed fields.

You can set the field to sort the table by simply by pressing the “S” key on the field you wish to sort by.

Press the enter key to commit your changes and press “Q” to quit.

Toggling Modes

Whilst running top you can press the “A” key to toggle between the standard display and an alternate display.

Changing Colors

Press the “Z” key to change the colors of the values within top.

There are three stages required to change the colors:

  1. Press either S for summary data, M for messages, H for column headings or T for task information to target that area for a color change
  2. Choose a color for that target, 0 for black, 1 for red, 2 for green, 3 for yellow, 4 for blue, 5 for magenta, 6 for cyan and 7 for white
  3. Enter to commit

Press the “B” key to make text bold.

Change The Display Whilst Running Top

Whilst the top command is running you can toggle many of the features on and off by pressing relevant keys whilst it is running.

The following table shows the key to press and the function it provides:

Function Keys
Function Key Description
A Alternative display (default off)
d Refresh screen after specified delay in seconds (default 1.5 seconds)
H Threads mode (default off), summarises tasks
p PID Monitoring (default off), show all processes
B Bold enable (default on), values are shown in bold text
l Display load average (default on)
t Determines how tasks are displayed (default 1+1)
m Determines how memory usage is displayed (default 2 lines)
1 Single cpu (default off) – i.e. shows for multiple CPUs
J Align numbers to the right (default on)
j Align text to the right (default off)
R Reverse sort (default on) – Highest processes to lowest processes
S Cumulative time (default off)
u User filter (default off) show euid only
U User filter (default off) show any uid
V Forest view (default on) show as branches
x Column highlight (default off)
z Color or mono (default on) show colors

Summary

There are more switches available and you can read more about them by typing the following into your terminal window:

Install Microsoft SQL Server On CentOS Linux

In December 2016 Microsoft made their SQL Server database available in Linux. Here we’ll cover how to install and perform basic setup of MSSQL in the RHEL based Linux distribution CentOS.

Install MSSQL In CentOS 7

First we’ll set up the repository file, Microsoft provide a copy of this for RHEL here: https://packages.microsoft.com/config/rhel/7/mssql-server.repo

We’ll use the wget command to copy this file to the /etc/yum.repos.d/ directory so that we can use it with the yum or dnf package manager.

[root@centos7 ~]# wget https://packages.microsoft.com/config/rhel/7/mssql-server.repo -O /etc/yum.repos.d/mssql-server.repo

Now that the repository file is in place, installation is as simple as running the following command. At the time of writing the total size of the package was a 139mb download.

 

[root@centos7 ~]# yum install mssql-server -y
...
+-------------------------------------------------------------------+
| Please run /opt/mssql/bin/sqlservr-setup to complete the setup of |
|                  Microsoft(R) SQL Server(R).                      |
+-------------------------------------------------------------------+

Once the installation has completed, we are advised to run the /opt/mssql/bin/sqlservr-setup bash script to complete the setup process.

During my first installation attempt, I got the following error as my virtual machine was only running with 2GB of memory, so be sure that you have enough memory before proceeding.

sqlservr: This program requires a machine with at least 3250 megabytes of memory.
Microsoft(R) SQL Server(R) setup failed with error code 1.

You’ll be able to proceed once you have adequate memory available.

[root@centos7 ~]# /opt/mssql/bin/sqlservr-setup
Microsoft(R) SQL Server(R) Setup

You can abort setup at anytime by pressing Ctrl-C. Start this program
with the --help option for information about running it in unattended
mode.

The license terms for this product can be downloaded from
http://go.microsoft.com/fwlink/?LinkId=746388 and found
in /usr/share/doc/mssql-server/LICENSE.TXT.

Do you accept the license terms? If so, please type "YES": YES

Please enter a password for the system administrator (SA) account:
Please confirm the password for the system administrator (SA) account:

Setting system administrator (SA) account password...

Do you wish to start the SQL Server service now? [y/n]: y
Do you wish to enable SQL Server to start on boot? [y/n]: y
Created symlink from /etc/systemd/system/multi-user.target.wants/mssql-server.service to /usr/lib/systemd/system/mssql-server.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/mssql-server-telemetry.service to /usr/lib/systemd/system/mssql-server-telemetry.service.

Setup completed successfully.


That’s it, Microsoft SQL Server is now running successfully and listening for traffic on TCP port 1434.

[root@centos7 ~]# systemctl status mssql-server
â mssql-server.service - Microsoft(R) SQL Server(R) Database Engine
   Loaded: loaded (/usr/lib/systemd/system/mssql-server.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2016-12-30 02:26:37 PST; 38s ago
 Main PID: 2974 (sqlservr)
   CGroup: /system.slice/mssql-server.service
           ââ2974 /opt/mssql/bin/sqlservr
           ââ2995 /opt/mssql/bin/sqlservr

[root@centos7 ~]# netstat -antp | grep 1434
tcp        0      0 127.0.0.1:1434          0.0.0.0:*               LISTEN      2995/sqlservr

Connecting To MSSQL

In order to actually connect to the server from Linux we need to install the mssql-tools package, which comes from a different repository than the one that we just set up. It can be found here: https://packages.microsoft.com/config/rhel/7/prod.repo

First we’ll download a copy of the prod.repo file and place it into the /etc/yum.repos.d/ directory.

[root@centos7 ~]# wget https://packages.microsoft.com/config/rhel/7/prod.repo -O /etc/yum.repos.d/prod.repo

We can now proceed with installing the mssql-tools package, as shown below.

[root@centos7 ~]# yum install mssql-tools -y

Once this is installed we can use the sqlcmd command to interact with the database. To see how to run sqlcmd, simply run it with the -? option for help.

Unfortunately it appears that when you specify the -P option for the password, the password must be provided in the command line with no option of being prompted for it later. Keep in mind that your password will be stored in your bash history running it this way.

[root@centos7 ~]# sqlcmd -U SA -P password
1> create database test;
2> go
1> use test;
2> go
Changed database context to 'test'.
1> create table websites(domain varchar(255));
2> go
1> insert into websites (domain)
2> values ('rootusers.com');
3> go

(1 rows affected)
1> select domain
2> from websites;
3> go
domain
rootusers.com
(1 rows affected)

In this example we create a test database with a table named websites and a column for domain names. We then insert a domain name and pull it back out with select, confirming both that we are able to connect and that basic SQL queries appear to be working as expected.

Summary

Microsoft’s SQL Server is now available for installation on Linux. Personally I don’t think I’ll ever use this over other alternatives such as MariaDB or PostgreSQL, so hopefully someone somewhere actually finds this information useful!

amazon linux redis install

Redis Install

Using epel Repository

sudo yum --enablerepo=epel install redis
=====================================================================================================================================================================
 Package                              Arch                                  Version                                        Repository                           Size
=====================================================================================================================================================================
Installing:
 redis x86_64 2.4.10-1.el6 warm 213 k

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

version 2.4.10-1.el6 has been installed. (January 30, 2016)

Using remi Repository

sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
sudo yum --enablerepo=remi install redis
=====================================================================================================================================================================
 Package                              Arch                               Version                                         Repository                             Size
=====================================================================================================================================================================
Installing:
 redis x86_64 3.0.7-1.el6.remi remi 442 k
Installing for dependencies:
 jemalloc                             x86_64                             3.3.1-1.8.amzn1                                 amzn-main                             111 k

Transaction Summary
=====================================================================================================================================================================
Install  1 Package (+1 Dependent package)

version 3.0.7-1.el6.remi was installed. (January 30, 2016)

Reference URL
Install redis on AWS EC 2

Setting Service

Start service, set automatic startup

sudo service redis start
sudo chkconfig --level 35 redis on
sudo chkconfig --list | grep redis

Execution result

$ sudo service redis start
Starting redis-server:   [  OK  ]
$ sudo chkconfig --level 35 redis on
$ sudo chkconfig --list | grep redis
redis           0:off   1:off   2:off   3:on    4:off   5:on    6:off
redis-sentinel  0:off   1:off   2:off   3:off   4:off   5:off   6:off
Page 1 of 16612345...102030...Last »