Author: Surendra Anne

Check if fsck runs at next boot in Linux?

Some times it is good to do file system checks for FS related errors before it is too late to recover a HDD. We have some inbuilt commands like fsck command to check for errors manually. But the issue is you can not check your primary mount point where your OS resides. In order to check file system errors on OS related mount point we have to enable fsck to run at boot time. This post is to check if that setting is enabled or not. To check these details use any of the below commands which will give you...

Read More

How to simulate yes/No in Linux scripts/commands

In some situations when executing a command or a Linux shell script we may require some manual intervention. The yes command is simple built-in command which will help you remove this manual intervention stuff in your scripts. The yes command is a cousin of echo command both print what we given. Only difference is echo will print only once, but yes will print until we intervene. Below are some examples which will come handy when simulating yes/no in scripts/commands Example 1: Simulate yes when using rm command. My rm command is aliased to “rm -rf”, so for this example I am using rm -i for this example. Remove all files in my directory. surendra@linuxnix:~/code/sh/temp$ touch {1..5} surendra@linuxnix:~/code/sh/temp$ yes | rm -i * rm: remove regular empty file ‘1’? rm: remove regular empty file ‘2’? rm: remove regular empty file ‘3’? rm: remove regular empty file ‘4’? rm: remove regularempty file ‘5’? surendra@linuxnix:~/code/sh/temp$ ls surendra@linuxnix:~/code/sh/temp$ Example 2: Do not remove any files with rm surendra@linuxnix:~/code/sh/temp$ touch {1..5} surendra@linuxnix:~/code/sh/temp$ yes n | rm -i * rm: remove regular empty file ‘1’? rm: remove regular empty file ‘2’? rm: remove regular empty file ‘3’? rm: remove regular empty file ‘4’? rm: remove regular empty file ‘5’? surendra@linuxnix:~/code/sh/temp$ ls 1 2 3 4 5 Example 3: Simulate yes and no in a controled fashon. I want to remove 1, 3, 5 files from...

Read More

9 practical Linux echo command examples

The echo command is useful for conveying a message/information to user. This command is more useful when you are writing shell scripts then normal system administration use. In this post we will see some basic examples as well as advanced stuff to get most of it. We have other command printf which is similar to echo command which is having more capabilities like padding, formatting etc. We will see that in another post. Syntax of echo command in Linux echo [options] message echo command basics. Example 1a: Print something using echo command. root@linuxnix: ~# echo How are you man? How are you man? Example 1b: If you observe the above command we did not use any quotes around the sentence which we are printing. This is ok, but not a best practice. We suggest you to use either single quotes or double quotes. root@linuxnix: ~# echo 'How are you man?' How are you man? root@linuxnix: ~# echo "How are you man?" How are you man? root@linuxnix: ~# Example 1c: Ok, you may get a question in your mind now. What is the difference between single(”) and double (”) quotes. The single quotes are useful for literal/plain printing where as double quotes are useful for variable substitution and command substitution. We will learn this with some example. I will create a variable which stores some information it. By using double quotes,...

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.