Technology Insights

cut – Represent A Tab As The Delimiter With Linux cut Command

I have been using the cut command a lot recently to shed extra data from large text files. I typically use cut with a specific delimiter by activating the -d switch and I thought that the -d switch was required. It turns out that -d is not required and by default -d actually defaults to the delimiter being a tab. When you need to have a tab as the delimiter for cut you simply don’t specify the -d switch. Below I show a couple examples of a file trimmed down using cut with and without the -d switch as well as another way to convert tabs in a file to spaces which then will allow you to use the Linux cut command with the -d” ” switch.

Technology Insights

Do Not Save Output Of wget Post Data

If you are putting together a script that uses wget to post data to various URL’s it is likely that you do not want wget to save the response back from the server in files. You can easily get around this by specifying the output file that wget save to with the -O switch. Below is an example of what would happen when the -O switch is not used followed by an example of using wget with the -O switch outputting the results to /dev/null.

Information Security

SELinux prevented ruby from reading files stored on a NFS filesytem

While working on a server farm for a client I kept running into some issues with one of the servers. The issue appeared to be a single CentOS Linux server in a cluster of ten CentOS Linux servers configured exactly the same as the other nine CentOS Linux servers was having issues writing to a network storage device. Initially I figured that the CentOS Linux server having the issues had some permission issues with the directory that was mounted to the SAN (Storage Area Network) however after minimal troubleshooting it was verified that the permissions were identical to the other servers. I started looking through other logs on the server having the issue and located some SELinux errors that were noticeably related to the issue at hand. Below I describe where the SELinux error was located, what the specific errors were, and how I was able to resolve the errors on this specific CentOS Linux server.

Technology Insights

Count How Many Files Are In A Directory And All Sub Directories On A Linux Server

Counting files in Linux is fairly easy by simply listing the files using ls and then using the wc application. Both the ls application and the wc application are core Linux applications and should be installed by default on your server. One thing that I had forgotten how to do was how to count all files in a specific directory as well as all files in each sub directories. The second method I will display below is not 100% accurate because it will count sub directories twice however it is likely you just need a round about method to get an idea of how many files and sub directories you are working with. Below I describe first how to count all files and directories within a single directory and second how to count all the files, sub directories, and files within the sub directories via a Linux shell or command prompt.