Common Linux commands and syntax

A list of commands and their syntax, some of which for some reason, seem to escape me only when I need it. tar -cvf (create a tar archive from a directory) tar -cvf – * | ssh root@ ‘cd /home;tar xvf -’ (creates a tar archive of current directory and sends it via ssh...

Extracting log file contents, with sed and awk

Extract data from a file that contains a list of information. Lets say I have a logfile /tmp/logfile that contains hostnames in the following format (See below). All I want is the hostname, nothing else. Typing grep and the hostname will return the entire line that...

Exporting full X windows session via ssh

Environment client1 – your local machine that you want to view the server’s full gnome X session on. server1 – the server that will send its X display through the ssh tunnel, to display on client1. Syntax Type the following from client side. Xephyr -ac -screen...

Solaris/Windows Function Comparison

Basic Commands Solaris | Windows ls -l | dir (displays a listing of the contents of the current working directory) vi | edit (runs an editor to modify the contents of a file) rm | del (removes/deletes a file or files) cp -r | xcopy (copys a file or directory to a...

Compiling Application Source Files

If you find an application that you want, but can’t find a binary for it… you’re probably left only with the source code as an option. I have listed and briefly described the three main commands to properly configure and compile source code. First unpack (gunzip,...

Perl Script, backup speeds v1.2

Code: #!/usr/bin/perl print “Enter the letter of the magnitude of data you need to backup (T(era),G(ig),M(eg),K(ilo)).\n”; chomp($mag1 = ); #takes the user input and assigns it to $mag1. print “Enter the amount of the data you need to backup (1-999).\n”;...

Shell Script, While Read

Purpose: To check if multiple rpm packages are installed on a linux OS. Code: #!/bin/sh while read i #read from input and assign the variable “i” to each line read. do echo “Looking for $i” #print the contents of the variable “i”. rpm -qa | grep $i #search the rpm...

Setting up SSH Public and Private keys

Here is a walkthrough on how to utilize ssh public and private keys to transfer files via ssh and rsync on Linux. This will be accomplished without a password and on a scheduled basis using cron. =======Environment======= Computer1 (192.168.0.1) – machine running...