Archive for December, 2012

nmap - Network exploration tool and security / port scanner

Nmap (“Network Mapper”) is an open source tool for network exploration and security auditing. It was designed to rapidly scan large networks, although it works fine against single hosts. Nmap uses raw IP packets in novel ways to determine what hosts are available on the network, what services (application name and version) those hosts are offering, what operating systems (and OS versions) they are running, what type of packet filters/firewalls are in use, and dozens of other characteristics. While Nmap is commonly used for security audits, many systems and network administrators find it useful for routine tasks such as network inventory, managing service upgrade schedules, and monitoring host or service uptime.

A typical Nmap scan is shown in Example 1. The only Nmap arguments used in this example are -A, to enable OS and version detection,script scanning, and traceroute; -T4 for faster execution; and then the two target hostnames.

Example 1. A representative Nmap scan

# nmap -A -T4 scanme.nmap.org
SBDavid

Setting CPU affinity with taskset

Setting CPU affinity with taskset

taskset retrieves and sets the CPU affinity of a running process (by process ID). It can also be used to launch a process with a given CPU affinity, which binds the specified process to a specified CPU or set of CPUs. However, taskset will not guarantee local memory allocation.

CPU affinity is represented as a bitmask. The lowest-order bit corresponds to the first logical CPU, and the highest-order bit corresponds to the last logical CPU. These masks are typically given in hexadecimal, so that 0×00000001 represents processor 0, and 0×00000003 represents processors 0 and 1.

To set the CPU affinity of a running process, execute the following command, replacing mask with the mask of the processor or processors you want the process bound to, and pid with the process ID of the process whose affinity you wish to change.

# taskset -p mask pid

To launch a process with a given affinity, run the following command, replacing mask with the mask of the processor or processors you want the process bound to, and program with the program, options, and arguments of the program you want to run.

# taskset mask — program

Instead of specifying the processors as a bitmask, you can also use the -c option to provide a comma-delimited list of separate processors, or a range of processors, like so:

# taskset -c 0,5,7-9 — myprogram

Further information about taskset is available from the man page: man taskset and http://redhat.com/

SBDavid

Using Variables in Perl

Using Variables in Perl

$_, the default variable. Creating containers for variables in Perl is easy. Give the container a name (which is made up of a combination of the letters A-Z, a-z, the digits 0-9 and the underscore character), then precede the name with one of Perl’s special variable naming characters, depending on what the variable will be used for:

$ – a scalar variable (one of something);
@ – an array variable (a collection of somethings, a list);

% – a hash variable (a collection of name/value pairs); and
\ – a referenced variable (a ‘pointer’ to something else, usually another variable).

SBDavid

Overview Kexec & Kdump

Overview Kexec & Kdump

Kexec is a fastboot mechanism which allows booting a Linux kernel from the context of already running kernel without going through BIOS. BIOS can be very time consuming especially on the big servers with lots of peripherals. This can save a lot of time for developers who end up booting a machine numerous times.

Kdump
Kdump is a new kernel crash dumping mechanism and is very reliable because the crash dump is captured from the context of a freshly booted kernel and not from the context of the crashed kernel. Kdump uses kexec to boot into
a second kernel whenever system crashes. This second kernel, often called a capture kernel, boots with very little memory and captures the dump image.

The first kernel reserves a section of memory that the second kernel uses to boot. Kexec enables booting the capture kernel without going through BIOS hence contents of first kernel’s memory are preserved, which is essentially
the kernel crash dump.

systemctl - Control the systemd system and service manager

systemctl may be used to introspect and control the state of the systemd(1) system and service manager.

systemd is a system and service manager for Linux operating systems. When run as first process on boot (as PID 1), it acts as init system that brings up and maintains userspace services.

Getting Help

systemctl -h
systemctl [OPTIONS...] {COMMAND} …

Query or send control commands to the systemd manager.

-h –help Show this help
–version Show package version
-t –type=TYPE List only units of a particular type
-p –property=NAME Show only properties by this name
-a –all Show all units/properties, including dead/empty ones
–failed Show only failed units
–full Don’t ellipsize unit names on output
–fail When queueing a new job, fail if conflicting jobs are
pendin

Next »