Category Archives: Linux

Add a background color to echo statements in a Bash script

To add a background color to your echo statements in a Bash script, you can use ANSI escape codes for text formatting, just like you did for text color. In this case, you’ll use codes for background colors. Here’s an example of how you can do it: #!/bin/bash # Text colors RED=’\033[0;31m’ GREEN=’\033[0;32m’ YELLOW=’\033[0;33m’ NC=’\033[0m’ … Continue reading Add a background color to echo statements in a Bash script

Identify security properties on Linux using checksec

Compiling source code produces a binary. During compilation, you can provide flags to the compiler to enable or disable certain properties on the binary. Some of these properties are relevant to security. Checksec is a nifty little tool (and shell script) that, among other functions, identifies the security properties that were built into a binary … Continue reading Identify security properties on Linux using checksec

Create and Manage Cron Jobs on Linux

Cron is one of Linux’s most useful tools and a developer favorite because it allows you to run automated commands at specific periods, dates, and intervals using both general-purpose and task-specific scripts. Given that description, you can imagine how system admins use it to automate backup tasks, directory cleaning, notifications, etc. Cron jobs run in … Continue reading Create and Manage Cron Jobs on Linux

Linux iptables Firewall

Today we will discuss in detail the Linux iptables firewall and how to secure your server traffic using that awesome firewall. Table of Contents– Iptables on CentOS 7 How Linux firewall works Firewall types iptables firewall tables Table chains Chain policy Adding iptables rules iptables rules order List iptables rules Deleting Rules Replacing Rules Listing Specific Table … Continue reading Linux iptables Firewall

Managing PING through iptables

PING – ping is a computer network administration software utility used to test the reachability of a host on an Internet Protocol network. It is available for virtually all operating systems that have networking capability, including most embedded network administration software. Blocking PING on the server is helpful sometimes, if the server continues to face any type of DDoS … Continue reading Managing PING through iptables

How to switch from root user to non-root user during execution using C on Linux

Setuid Program Example Here’s an example showing how to set up a program that changes its effective user ID. This is part of a game program called caber-toss that manipulates file scores that should be writable only by the game program itself. The program assumes that its executable file will be installed with the setuid bit set and … Continue reading How to switch from root user to non-root user during execution using C on Linux