Linux.com

Community Blogs



Basic Linux Shell Scripting Language : 'While' Loops

In the previous article entitled "Basic Linux Shell Scripting Language : Introduction to 'For' Loops", we have observed how a loop works. Loop is nothing but a control flow statement which executes a block of commands repeatedly till certain condition stays true, once the condition becomes false, the loop is terminated.
 
    In this article, I will explain Basic syntax of 'While' loop along with some examples of 'While' loop usage. If you are new to Shell Scripting, I recommend that, you should read my article - Getting Started - Linux Shell Scripting Language.
 
Here we go!
 
Read more at YourOwnLinux
 

Basic Linux Shell Scripting Language : Introduction to 'FOR' Loops

    Many times, it is necessary to execute a certain set of commands repeatedly for some number of times. For this purpose, one needs to use looping statements like'For''While' and 'Until'. These statements run a block of code for multiple times. In this article, I will try to elaborate on Basic syntax of For loops with some examples of For loop usage.


Here we go!

Read more at YourOwnLinux

 

Getting Started : Linux Shell Scripting Language - III

This is the third article on Basic Linux Shell Scripting Language. Before this article, I had published two articles on the said topic, which are:
    I would recommend that, before you go through this article directly, please read this article so that it would become easier for you to understand.
 
In this article on Basic Linux Shell Scripting Language, we will be dealing with Mathematics. I will try to cover how basic operations in Mathematics are implemented in Shell Scripting along with some scripts which incorporate their uses. Most of these scripts are self explanatory.


Here we go !

 

Read more at YourOwnLinux

 

Getting Started : Linux Shell Scripting Language - II

In the previous article on Linux Shell Scripting Language, we had already covered following points:
  • What is a Shell?
  • Types of Linux Shell- Bourne Shell, C Shell, Korn Shell and the BASH Shell (Bourne Again Shell).
  • Shell Programming - The Basics
  • Writing the First Shell Script - Hello World
 In this article, we would write some more basic shell scripts that will give you much more comfort while writing more complex scripts. Please note that, this article is an extension of my previous article "Getting Started - Linux Shell Scripting Language".
So, without much a do, lets start the show.
 
Read more at YourOwnLinux
 

Getting Started : Linux Shell Scripting Language - I

What is a Shell..?

    Most of us know the fact that computer understands the language of 0’s and 1’s i.e. Binary language. Whenever we enter any command in the text format, it gets translated to computer-readable form and the processed output which is in binary format gets converted to human-readable form and gets displayed on the screen in the form of texts. Shell performs all these translations. 
 
Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell Linux Shell
 
    The Linux/Unix shell is a command-line interface which lets its users to interact with the operating system by accepting commands from the users through the keyboard; the shell executes the commands and prints the output on the screen. Unlike the graphical environment (GUI based) that we would normally observe in most of the present computers, the interaction is purely text-based and being command-oriented this kind of interface is called “Command Line interface or CLI”. Before GUI environments were introduced in computer systems, CLI was the only way using which an user could interact and operate the computer system.
 
Read more at YourOwnLinux
 

Risk Assessment / Security & Hacktivism 10,000 Linux servers hit by malware serving tsunami of spam

windigo-overview-640x374

Researchers have documented an ongoing criminal operation infecting more than 10,000 Unix and Linux servers with malware that sends spam and redirects end users to malicious Web pages.

Windigo, as the attack campaign has been dubbed, has been active since 2011 and has compromised systems belonging to the Linux Foundation's kernel.org and the developers of the cPanel Web hosting control panel, according to a detailed report published Tuesday by researchers from antivirus provider Eset. During its 36-month run, Windigo has compromised more than 25,000 servers with robust malware that sends more than 35 million spam messages a day and exposes Windows-based Web visitors to drive-by malware attacks. It also feeds people running any type of computer banner ads for porn services.

The Eset researchers, who have been instrumental in uncovering similar campaigns compromising large numbers of servers running the nginx, Lighttpd, and Apache Web servers, said the latest campaign has the potential to inflict significant harm on the Internet at large. They explained:

The number of systems affected by Operation Windigo might seem small when compared with recent malware outbreaks where millions of desktops are infected. It is important to keep in mind that, in this case, each infected system is a server. These usually offer services to numerous users and are equipped with far more resources in terms of bandwidth, storage and computation power than normal personal computers. A denial of service attack or a spam-sending operation using one thousand servers is going to be far more effective than the same operation performed with the same number of desktop computers.
 

Two-Factor Authentication (One time passwords by SMS) for SSH and more

With passwords becoming inherently insecure nowadays, I decided to add an extra layer of security by using the Textlocal One-Time Password API (Its so new I haven't been able to get it documented yet).

One-Time Passwords are unique codes which are sent to a trusted mobile device which can then be checked and then allowed or denied access based on the response back.

This is pretty awesome considering the code can not be guessed, expires after 24 hours, can only be used once, and is separate to the service which is requiring the authentication.

Like I said, I decided to add One-Time Passwords to my Linux server, to do this, I added the following code to the bottom of my user's (my user, since no other users have SSH access) .bashrc file:

tlrequest="username=**EMAIL**&password=**PASS**&numbers=**NUMBER**&message=SSH%20OTP%20is&sender=SSH-OTP"
trap logout INT
curl -s -d $tlrequest http://api.txtlocal.com/otp_send >/dev/null 2>&1
echo "A One-time password has been sent to your device. Please enter it below followed by [enter]:"
read otp
check=$(curl -s "http://api.txtlocal.com/otp_challenge/?username=**EMAIL**&password=**PASS**&numbers=**NUMBER**&code=$otp >/dev/null 2>&1")
if [[ $check == *uccess* ]]
then
    echo "OTP Validated.";
else
    echo "OTP Invalid. Disconnecting."
    logout
fi

To make the code work, you will need:

1. A Textlocal account 
2. Change **EMAIL** to your email address
3. Change **PASS** to your Textlocal password or hash
4. change **NUMBER** to your mobile number (eg 447000000000)

Thats it!

 

6 quick tools to monitor system resources on Linux

Monitor server resources System administrators need to monitor their server to ensure proper functioning. The practice enables administrators to detect possible issues in advance and recover the system, before it causes any trouble. There are plenty of commands on Linux to monitor different system resources like cpu usage, memory usage, network, disk usage and so on. Popular ones are top, htop, iostat, nethogs etc. In this post we are talking about simple command line tools that can monitor multiple system resources like cpu, memory, network, disk, processes etc all together...

Read more... Comment (0)
 

8 commands to check cpu information on Linux

CPU hardware information The cpu information includes details about the processor, like the architecture, vendor name, model, number of cores, speed of each core etc. There are quite a few commands on linux to get those details about the cpu hardware, and here is a brief about some of the commands. 1. /proc/cpuinfo The...

Read more... Comment (0)
 

12 scp command examples to transfer files on Linux

Secure copy Scp (Secure Copy) is a command line tool to copy or transfer files across hosts. It uses the same kind of security mechanism like the ssh program. Infact it uses an ssh connection in the background to perform the file transfer. scp refers both to the "protocol" that defines how secure copy should work and the "program" (command) which is installed as a part of OpenSSH suite of tools. In this quick tutorial we shall look at a few examples the scp command and how it can be...
Read more... Comment (0)
 

20 amusing Linux commands to have fun with the terminal

The linux terminal is not always dull and boring. There are commands to make it do some funny acts to entertain the user. Here is a small collection of such commands. 1. Cowsay Install cowsay with apt. $ sudo apt-get install cowsay Cowsay is a talking cow that will speak out anything you want it to. $ cowsay "Hi, How are...
Read more... Comment (0)
 
Page 10 of 133

Upcoming Linux Foundation Courses

  1. LFD320 Linux Kernel Internals and Debugging
    03 Nov » 07 Nov - Virtual
    Details
  2. LFS416 Linux Security
    03 Nov » 06 Nov - Virtual
    Details
  3. LFS426 Linux Performance Tuning
    10 Nov » 13 Nov - Virtual
    Details

View All Upcoming Courses


Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board