Sandra Henry-Stocker

Author Archives: Sandra Henry-Stocker

Learning to script on Linux using bash

Scripting in Linux--putting commands into a file so you can run them as a group—is a lot easier than running them from the command line because you don't have to figure out the process over and over again. Aliases can also be used to repeat commands easily, but are really only used for individual commands that are complex or difficult to remember.As you will see in the examples below, the bash shell provides plenty of commands for testing, looping, creating functions, and annotating your scripts. [ Get regularly scheduled insights by signing up for Network World newsletters. ]To read this article in full, please click here

Learning to script on Linux using bash

Scripting in Linux--putting commands into a file so you can run them as a group—is a lot easier than running them from the command line because you don't have to figure out the process over and over again. Aliases can also be used to repeat commands easily, but are really only used for individual commands that are complex or difficult to remember.As you will see in the examples below, the bash shell provides plenty of commands for testing, looping, creating functions, and annotating your scripts. [ Get regularly scheduled insights by signing up for Network World newsletters. ]To read this article in full, please click here

Using ClamAV to detect viruses on Linux

One popular and easy-to-use tool for detecting virus infections on Linux systems is ClamAV. It's open source and free, and runs on many Linux systems, Ubuntu and Fedora included. In this post, we'll take a look at how to install and use the tool on Ubuntu, Linux Mint, and related systems. Installing ClamAV on Linux Mint The first step for installing ClamAV on Ubuntu, Mint, and related distros should be to update your system.$ sudo apt update && sudo apt upgrade -y After that, you can install ClamAV and verify the installation with commands like these:$ sudo apt-get install clamav clamav-daemon $ clamscan --version ClamAV 0.103.5/26469/Wed Mar 2 04:27:25 2-22 ClamAV commands ClamAV's tools are clamscan to do the scanning and freshclam to update the list of known virus signatures.To read this article in full, please click here

Using ClamAV to detect viruses on Linux

One popular and easy-to-use tool for detecting virus infections on Linux systems is ClamAV. It's open source and free, and runs on many Linux systems, Ubuntu and Fedora included. In this post, we'll take a look at how to install and use the tool on Ubuntu, Linux Mint, and related systems. Installing ClamAV on Linux Mint The first step for installing ClamAV on Ubuntu, Mint, and related distros should be to update your system.$ sudo apt update && sudo apt upgrade -y After that, you can install ClamAV and verify the installation with commands like these:$ sudo apt-get install clamav clamav-daemon $ clamscan --version ClamAV 0.103.5/26469/Wed Mar 2 04:27:25 2-22 ClamAV commands ClamAV's tools are clamscan to do the scanning and freshclam to update the list of known virus signatures.To read this article in full, please click here

Using pipes on Linux to get a lot more done

One of the things that I have always loved about Unix and then Linux is how it allows me to connect a series of commands together with pipes and get a lot of work done without a lot of effort. I can generate the output that I need in the form that I need it. It's not just the existence of the pipes themselves, but the flexibility of the Linux commands. You can run commands, select portions of the output, sort the results or match on specific strings and you can pare the results down to just what you want to see.In this post, we're going to look at a couple commands that demonstrate the power of the pipe and how easily you can get commands to work together.To read this article in full, please click here

Using pipes on Linux to get a lot more done

One of the things that I have always loved about Unix and then Linux is how it allows me to connect a series of commands together with pipes and get a lot of work done without a lot of effort. I can generate the output that I need in the form that I need it. It's not just the existence of the pipes themselves, but the flexibility of the Linux commands. You can run commands, select portions of the output, sort the results or match on specific strings and you can pare the results down to just what you want to see.In this post, we're going to look at a couple commands that demonstrate the power of the pipe and how easily you can get commands to work together.To read this article in full, please click here

Using the Linux host command to dig out DNS details

The host command on Linux systems can look up a variety of information available through the Domain Name System (DNS). It can find a host name if given an IP address or an IP address if given a host name plus a lot of other interesting details on systems and internet domains.The first query below tells us that the system associated with the address 192.168.0.18 is named “dragonfly”. The second tells us that 192.168.0.1 is the default router.$ host 192.168.0.18 18.0.168.192.in-addr.arpa domain name pointer dragonfly. $ host 192.168.0.1 1.0.168.192.in-addr.arpa domain name pointer router. To do the reverse, you can use commands like these:To read this article in full, please click here

Using the Linux host command to dig out DNS details

The host command on Linux systems can look up a variety of information available through the Domain Name System (DNS). It can find a host name if given an IP address or an IP address if given a host name plus a lot of other interesting details on systems and internet domains.The first query below tells us that the system associated with the address 192.168.0.18 is named “dragonfly”. The second tells us that 192.168.0.1 is the default router.$ host 192.168.0.18 18.0.168.192.in-addr.arpa domain name pointer dragonfly. $ host 192.168.0.1 1.0.168.192.in-addr.arpa domain name pointer router. To do the reverse, you can use commands like these:To read this article in full, please click here

Using the Linux fold command to make text more readable

The Linux fold takes lines of text and breaks them into chunks based on the arguments that you provide. With no arguments, fold will break lines at 80 characters.The first example below uses a single-line text file that includes indications of character positions. First, we count the number of characters and lines in the file using the wc -l and wc -l command:$ wc -c wide_text 251 wide_text $ wc -l wide_text 1 wide_text So, this file has 251 characters (including a carriage return) and a single line of text. Next, we display the file using the cat command:To read this article in full, please click here

Using the Linux fold command to make text more readable

The Linux fold takes lines of text and breaks them into chunks based on the arguments that you provide. With no arguments, fold will break lines at 80 characters.The first example below uses a single-line text file that includes indications of character positions. First, we count the number of characters and lines in the file using the wc -l and wc -l command:$ wc -c wide_text 251 wide_text $ wc -l wide_text 1 wide_text So, this file has 251 characters (including a carriage return) and a single line of text. Next, we display the file using the cat command:To read this article in full, please click here

Using the seq command to generate numeric sequences

The seq command is handy for generating number sequences on Linux.It requires at least one number as an argument and, given that, it will provide all the numbers from 1 to whatever number you specify. However, that's just the command's simplest use. With additional arguments, seq can be surprisingly useful, especially when you use the generated numbers to drive a loop or do a calculation.How to tell if you're using a bash built-in in Linux The seq command below illustrates the most basic use of this command:To read this article in full, please click here

Using the seq command to generate numeric sequences

The seq command is handy for generating number sequences on Linux.It requires at least one number as an argument and, given that, it will provide all the numbers from 1 to whatever number you specify. However, that's just the command's simplest use. With additional arguments, seq can be surprisingly useful, especially when you use the generated numbers to drive a loop or do a calculation.How to tell if you're using a bash built-in in Linux The seq command below illustrates the most basic use of this command:To read this article in full, please click here

Turn tabs into spaces on Linux and vice versa

The Linux expand and unexpand commands sound like they can make files larger and smaller, but what they actually do is turn tabs into spaces and spaces into tabs.In this post, we’ll use some simple text files to demonstrate what happens when you use expand and unexpand. We’ll also compare how these commands work with some likely more familiar commands—sed and awk—that can provide similar results and offer additional options.[Get regularly scheduled insights by signing up for Network World newsletters.] To begin, let’s take a look at this very simple text file:To read this article in full, please click here

Turn tabs into spaces on Linux and vice versa

The Linux expand and unexpand commands sound like they can make files larger and smaller, but what they actually do is turn tabs into spaces and spaces into tabs.In this post, we’ll use some simple text files to demonstrate what happens when you use expand and unexpand. We’ll also compare how these commands work with some likely more familiar commands—sed and awk—that can provide similar results and offer additional options.[Get regularly scheduled insights by signing up for Network World newsletters.] To begin, let’s take a look at this very simple text file:To read this article in full, please click here

Hashing out the hash command on Linux

When you type “hash” on a Linux system, you could get one of two very different responses depending on the shell you are using.If you are using bash or a related shell such as ksh, you should see a list of the commands that you have used since your terminal session began, sometimes with a count of how many times each command was used. This can be more useful than using the history command if you just want to see your very recent command activity, but the hash command is not a single executable. Instead, it relies on your shell.How to tell if you're using a bash built-in in Linux hash in bash Here’s an example of the hash command run in bash:To read this article in full, please click here

Hashing out the hash command on Linux

When you type “hash” on a Linux system, you could get one of two very different responses depending on the shell you are using.If you are using bash or a related shell such as ksh, you should see a list of the commands that you have used since your terminal session began, sometimes with a count of how many times each command was used. This can be more useful than using the history command if you just want to see your very recent command activity, but the hash command is not a single executable. Instead, it relies on your shell.How to tell if you're using a bash built-in in Linux hash in bash Here’s an example of the hash command run in bash:To read this article in full, please click here

Using the Linux look command to select lines from files

The look command on Linux can be handy for selecting particular lines from text files with sorted contents. Let's look into how it can be used and where you might run into some problems.Case sensitivity If you type a command such as "look unix", you should see this:$ look unix UNIX Unix unix Notice that, because no file was specified in the command shown, look reverts to using the words file on the system (probably /usr/share/dict/words or whatever that points to). Also notice that it finds the three lines in the file even though the argument for the command has only lowercase characters. The command is case-insensitive when you don't provide a file name and instead allow it to default to the words file.To read this article in full, please click here

Using the Linux look command to select lines from files

The look command on Linux can be handy for selecting particular lines from text files with sorted contents. Let's look into how it can be used and where you might run into some problems.Case sensitivity If you type a command such as "look unix", you should see this:$ look unix UNIX Unix unix Notice that, because no file was specified in the command shown, look reverts to using the words file on the system (probably /usr/share/dict/words or whatever that points to). Also notice that it finds the three lines in the file even though the argument for the command has only lowercase characters. The command is case-insensitive when you don't provide a file name and instead allow it to default to the words file.To read this article in full, please click here

The truth about Linux true and false commands

True and false are common concepts in all forms of computing. They’re critical to Boolean logic after all, but did you know that true and false are also commands on Linux? Do you know how to use them?The simplest explanation is that the true command generates an exit code of 0 and that the false command generates an exit code of 1. This explanation, however, doesn’t provide much detail on how these commands can best be used.In this post, we’ll look at how the true and false commands work and how you might put them to use on the command line or in your scripts.To read this article in full, please click here

The truth about Linux true and false commands

True and false are common concepts in all forms of computing. They’re critical to Boolean logic after all, but did you know that true and false are also commands on Linux? Do you know how to use them?The simplest explanation is that the true command generates an exit code of 0 and that the false command generates an exit code of 1. This explanation, however, doesn’t provide much detail on how these commands can best be used.In this post, we’ll look at how the true and false commands work and how you might put them to use on the command line or in your scripts.To read this article in full, please click here