Author: Sahil Suri

9 vmstat command examples in Linux/Unix

  What is vmstat command? In this article, we’ll demonstrate how we can use the vmstat(View memory status) command as an indispensable memory measurement tool. Although the primary intended purpose of vmstat command displays virtual memory statistics about processes, memory, and paging, it also provides information about block I/O, traps, and CPU activity. Verifying that vmstat is availability The vmstat command is installed as a part of the procps package which installs a set of utilities that are used to report system information. This package will be installed on a Red Hat based system by default even if you’ve performed a minimal type installation of the operating system. We will verify that vmstat is available in our system by executing the following commands: [sahil@linuxnix:~] $ which vmstat /usr/bin/vmstat [sahil@linuxnix:~] $ rpm -qf /usr/bin/vmstat procps-3.2.8-36.el6.x86_64 Now that we have verified that vmstat is installed on our system let’s explore some of it’s options. Getting help on vmstat command To view a list of the different options available with the vmstat command type vmstat –help. [sahil@linuxnix:~] $ vmstat --help usage: vmstat [-V] [-n] [delay [count]] -V prints version. -n causes the headers not to be reprinted regularly. -a print inactive/active page stats. -d prints disk statistics -D prints disk table -p prints disk partition statistics -s prints vm table -m prints slabinfo -t add timestamp to output -S unit size delay...

Read More

10 File Globbing examples in Linux/Unix

What is file globbing in Linux? File globbing is a feature provided by the UNIX/Linux shell to represent multiple filenames by using special characters called wildcards with a single file name. A wildcard is essentially a symbol which may be used to substitute for one or more characters. Therefore, we can use wildcards for generating the appropriate combination of file names as per our requirement. What are regular expressions? Is a sequence of symbols which includes alphabets, numbers, special characters like $,^,*,. etc which can be understood by many programming languages to match different string patterns. This is a bit complex but with examples, you can understand them quickly and easily. Please head to our posts on these regular expressions. Types of available file globbing: The bash shell provides three characters to use as wildcards: Asterisk (*) to represent 0 or more characters Question mark (?) to represent exactly one character Square brackets ([]) to represent and match for the character enclosed within the square brackets. In this article, we’ll go through multiple examples of each of the above-mentioned file globbing options to understand their usage. In order this globbing to work properly you should know shopt command globbing options as well. Example 1: Using * expand all disk drives file names with /dev/sda as leading characters. [root@linuxnix ~]# ls -l /dev/sda* brw-rw----. 1 root disk 8, 0 Nov...

Read More

18 tr command examples in linux/Unix

Along with the Linux sed command, the tr command stands for translate is used to provide a level of swapping or translation, suppression or deletion of files. The tr command just translates one character to another character. In this article, we’ll share a couple of examples demonstrating some exciting things that we can do with the tr command. The basic syntax for the tr command tr [OPTION] [SET1] [SET2] SET1 denotes what we wish to translate in the input file, and SET2 means what we want to convert SET1 as the output of the translation. So the sets can be a single character or multiple characters. Example1: Suppose you just want to replace a in “sahil suri” with b we can use tr sets. We use echo command to send “sahil suri” to tr command. The tr command by default is not able to read data stream. We use Linux inbuilt redirection operators to feed data to tr command. [root@linuxnix:~]# echo "sahil suri" | tr 'a' 'b' sbhil suri Example2: Suppose if you want to replace multiple characters one after the other then we can use below-set examples. Suppose you want to replace a with b, r with x and i with z, below is the case you are looking at. [root@linuxnix:~]# echo "sahil suri" | tr 'ari' 'bxz' sbhzl suxz Note: Make sure that first set and second...

Read More

Over 16,000 readers, Get fresh content from “The Linux juggernaut”

Email Subscribe

ABOUT ME..!

My photo
My name is Surendra Kumar Anne. I hail from Vijayawada which is cultural capital of south Indian state of Andhra Pradesh. I am a Linux evangelist who believes in Hard work, A down to earth person, Likes to share knowledge with others, Loves dogs, Likes photography. At present I work at Bank of America as Sr. Analyst Systems and Administration. You can contact me at surendra (@) linuxnix dot com.

banner