CLI

Learning about the Debian interfaces configuration file

Introduction

You can always read the Debian Wiki Page about the interfaces file found in /etc/network/ or you can read along for a little walk though. The interfaces file is a simple but scalable way to manage network interfaces for a computer. From simple to super complex the interfaces file uses the ifupdown tools to read and preform actions as listed.

The File

As stated the file location is rather simple. The file and its location are meant to be generic and functional.

Tags:

Hard Disk Drive Checks on Headless or Remote Servers

The Problem

Setting up remote servers or even local servers that have no keyboard or monitor often called headless requires some thought. File system and hard disk drive checks for example can be troublesome. During start up of any modern Linux distribution a check for the number of mounts or duration since the last check can cause a complete disk inspection often called fsck or file system checker. This is a perfectly normal and safe thing for all systems. If you do not have access to the server or headless system you may not be able answer questions for the fsck program if it finds an issue. Very often one simple press of the Y key is all you need to do. If you server is hundreds of miles away or does not have an easy method of attaching a keyboard this is difficult.

Tags:

Delete files older than X number of days

The Find Utilitiy

Recent versions of "find" include a feature to delete the files that are found. This can be dangerous so always test when you know you have good backups.

A simple example to locate files older than three days and delete them without using pipes.

find /directory/* -mtime +3 -delete

You can replace the 3 with what ever you like. Read more about this and other features in the manual.

Tags:

Installing a recent version of Fabric on Debian

Introduction

Some new features like parallel are handy but require an updated version of fabric. Here is a safe and clean way of installing Fabric in a more Pyhonic fashion. This should also work just fine on other distros that use aptitude or apt-get and this can be an exercise to the reader to figure out how to do this with yum or urpmi.

Tags:

A Fabric File Part 1

Fabric

Fabric is a Python library that allows you to deploy servers over SSH connections. Lets start with a look at the fabfile.py and how to use it. This tool can be used for administration and deployment both big and small.

Tags:

Using Dnsmasq for DHCP DNS and TFTP

Introduction

Dnsmasq is a lightweight server for DHCP, DNS and TFTP. For DHCP and DNS there are simple to advanced features needed in an embeded or small system like a consumer router. The TFTP features are few but functional. Knowing about Dnsmasq and how to use it is a great skill. Look, Learn, and Play!

Downgrading or rolling back or just setting package versions with aptitude

In Linux distributions there are times when packages need to be set a static version. Here is a quick summary and example. The item of note is that this is called "setting the package version" and not downgrade, rollback or revert.

aptitude versions thepackage
aptitude install thepackage=theversion

Lets set the version of PHP5.

PS:~# aptitude versions php5
p   5.3.3-7+squeeze1   stable   500 
i   5.3.3-7+squeeze3   stable   500

and the command

PS:~# aptitude install php5=5.3.3-7+squeeze1

Tags:

Learning to install Virt-Manager from sources

Introduction & Problem

This is the process to install updated or newer version of virt-manager. Many times you will find that you need a feature that is just not available in the distribution supplied version of virt-manager. Here is a quick install process.

Add BASH aliases for IPTABLES

Its good to have tools. Here is a quick addition to any /root/.bashrc file. This will add commands for blocking connections from IP addresses and methods of removing the bans. Use with care.

alias ban='iptables -I INPUT -j DROP -s'
alias unban='iptables -D INPUT -j DROP -s'
alias banin='iptables -I INPUT -j DROP -s'
alias unbanin='iptables -D INPUT -j DROP -s'
alias banout='iptables -I OUTPUT -j DROP -s'
alias unbanout='iptables -D OUTPUT -j DROP -s'
alias listbans='iptables -L -v -n | grep -e Chain -e DROP'

After adding them, always source it.

Recursively deleting Microsoft end of line characters

Simple one liner to remove all ^M line returns from files in a directory. I use this on an Open Source project I work on mainly for PHP files. Type "CTRL v" then "CTRL m" to get the system ^M char. The character will not copy and paste. The filter for SVN is optional.

grep -IUrl "^M" * | grep -v svn | xargs sed -i 's/^M$//'

Easy! Search the directory recursively. Filter out the SVN files. Run SED against the files in the list.

Tags:

Pages

Subscribe to RSS - CLI