linux poison RSS
linux poison Email
0

Bash Script: File related operations

Following table describe the operation that you can perform on any given file.

[ -a FILE ]    True if FILE exists.
[ -b FILE ]    True if FILE exists and is a block-special file.
[ -c FILE ]    True if FILE exists and is a character-special file.
[ -d FILE ]    True if FILE exists and is a directory.
[ -e FILE ]    True if FILE exists.
[ -f FILE ]    True if FILE exists and is a regular file.
[ -g FILE ]    True if FILE exists and its SGID bit is set.
[ -h FILE ]    True if FILE exists and is a symbolic link.
[ -k FILE ]    True if FILE exists and its sticky bit is set.
[ -p FILE ]    True if FILE exists and is a named pipe (FIFO).
[ -r FILE ]    True if FILE exists and is readable.
[ -s FILE ]    True if FILE exists and has a size greater than zero.
[ -t FD ]        True if file descriptor FD is open and refers to a terminal.
[ -u FILE ]    True if FILE exists and its SUID (set user ID) bit is set.
[ -w FILE ]   True if FILE exists and is writable.
[ -x FILE ]    True if FILE exists and is executable.
[ -O FILE ]    True if FILE exists and is owned by the effective user ID.
[ -G FILE ]    True if FILE exists and is owned by the effective group ID.
[ -L FILE ]    True if FILE exists and is a symbolic link.
[ -N FILE ]    True if FILE exists and has been modified since it was last read.
[ -S FILE ]    True if FILE exists and is a socket.


Read more
0

Bash Script: Create simple select menu using select statement

Here is simple bash script which creates an simple options selection menu using bash 'select' statement, fee free to modify/copy and use this script to suite your requirement.

$ cat select.sh
#!/bin/bash

# Selection menu items goes here
SELECTION="option1 option2 option3 quit"

select options in $SELECTION; do

# here using the if statements you can perform the required  operation
if [ "$options" = "option1" ]; then
    echo "You have selected $options"

elif [ "$options" = "option2" ]; then
    echo "You have selected $options"

elif [ "$options" = "option3" ]; then
        echo "You have selected $options"

elif [ "$options" = "quit" ]; then
        echo "You have selected $options"
    exit

# if something else is selected, show the menu again
else
    clear;
    echo "please select some options"

fi
done

Read more
0

Bash Script: Creating and using Read-only variables

Here is an simple bash script showing the trick to create the read-only variable, feel free to copy and use this script.

$ cat declare.sh
#!/bin/bash

# Declare the variable as readonly
declare -r AGE=25
echo $AGE

# Try to change the value of this readonly variable
# you should get an error message
AGE=34
echo $AGE

Output: $ ./declare.sh
./declare.sh
25
./declare.sh: line 9: AGE: readonly variable
25


Read more
3

Bash Script: Check Servers Availability using ping command

Here is the simple bash script to check the server availability using simple ping command, for this you need to create a simple txt file ("server.txt") containing the hostname or ip address of the servers that you want to check ...

$ cat server.txt
google.com
yahoo.com
redhat.com
 
$ cat pingalert.sh
#!/bin/bash
# Read the file line by line
cat server.txt | while read line
do
        # check if there are no blank lines
        if [ ! -z $line ]; then
                PINGCOUNT=2
                PING=$(ping -c $PINGCOUNT $line | grep received | cut -d ',' -f2 | cut -d ' ' -f2)
                if [ $PING -eq 0 ]; then
                        echo "Something wrong with the server: $line"
                        # Or do send out mail
                else
                        echo "All good: $line"
                fi
        fi
done

Output: $ ./pingalert.sh
All good: google.com
All good: yahoo.com
All good: redhat.com


Read more
0

Lightweight Email reader for the GNOME desktop - Geary

Geary is a lightweight email reader for the GNOME desktop.

Geary includes the following features:
 * Basic support for viewing and composing HTML email
 * Send and receive email
 * Reply to all and forward email
 * Optional spell checker
 * Keyboard shortcuts
 * Organizes emails into conversations
 * Supports Gmail and Yahoo
Read more
2

Web Application Vulnerability Scanner - Webvulscan

WebVulScan is a web application vulnerability scanner. It is a web application itself written in PHP and can be used to test remote, or local, web applications for security vulnerabilities. As a scan is running, details of the scan are dynamically updated to the user. These details include the status of the scan, the number of URLs found on the web application, the number of vulnerabilities found and details of the vulnerabilities found.

After a scan is complete, a detailed PDF report is emailed to the user. The report includes descriptions of the vulnerabilities found, recommendations and details of where and how each vulnerability was exploited.

The vulnerabilities tested by WebVulScan are:
 * Reflected Cross-Site Scripting
 * Stored Cross-Site Scripting
 * Standard SQL Injection
 * Broken Authentication using SQL Injection
 * Autocomplete Enabled on Password Fields
 * Potentially Insecure Direct Object References
 * Directory Listing Enabled
 * HTTP Banner Disclosure
 * SSL Certificate not Trusted
 * Unvalidated Redirects

Read more
0

Bash Script: Increment the loop by some value on each iteration

Below is the simple bash script which show the way of incrementing the for loop by the value of "2" on each iteration:


#!/bin/bash
for i in {1..10..2}
do
    echo $i
done

=== Output ====
1
3
5
7
9


Read more
1

Bash Script: Get the length of any given String

Below is a simple script to get the length of any string.

#!/bin/bash
echo "enter the sting: "
read str;

countStringLength() {
        echo `echo -n $1 | wc -c`

        # Or can use the below trick to get the string length
        # I prefer to use the first one - easy to use and easy to remember
        echo ${#1}
}
countStringLength $str


Read more
1

Bash Script: Check if variable is integer or not

Below is a simple bash script to check if any given number is integer or not ...

#!/bin/bash
echo "Enter the value: ";
read num;
checkInteger(){
        if [ $1 -eq $1 2> /dev/null ]; then
                echo "$1 is a integer"
        else
                echo "$1 is not a integer"
        fi
}
checkInteger $num

Read more
0

Desktop Configuration Application for Unity - Unsettings

Unsettings is a graphical configuration program for the Unity desktop environment that lets you change some oft the Unity settings.

Unsettings can only change your user’s settings, you can’t use it to change global settings or do anything else that needs root privileges.

You can use Unsettings to change the themes for GTK, window manger, icons and cursors. But it doesn’t support the installation of new themes. With Unsettings you can switch off the global menu and the overlay scrollbars used in Unity. In addition to just applying the settings Unsettings lets you to save your settings into and load from a text file (JSON format) so you can easily backup you settings or copy them to a different account.

In addition to just applying the settings Unsettings lets you to save your settings into and load from a text file (JSON format)so you can easily backup you settings or copy them to a different account.

Read more
1

Convert an HTML Pages or Websites to PDF in Ubuntu - HTMLDOC

HTMLDOC is a program for writing documentation in HTML and producing indexed HTML, PostScript, or PDF output (with tables of contents). It supports most HTML 3.2 and some HTML 4.0 syntax, as well as GIF, JPEG, and PNG images.

HTMLDOC can be used as a standalone application, in a batch document processing environment, or as a web-based report generation application. No restrictions are placed upon the output produced by HTMLDOC.

HTMLDOC is open source software under the terms of version 2 of the GNU General Public License with an exception that allows for distribution of executable linked to the OpenSSL library.

Installing HTMLDOC:
Ubuntu users can install HTMLDOC using following command:
sudo apt-get install htmldoc
Read more
2

Adding Virtual Hosts in Apache2 under Ubuntu

The term Virtual Host refers to the practice of running more than one web site (such as www.foo.com and www.goo.com) on a single machine. Virtual hosts can be "IP-based", meaning that you have a different IP address for every web site, or "name-based", meaning that you have multiple names running on each IP address. The fact that they are running on the same physical server is not apparent to the end user.

Apache was one of the first servers to support IP-based virtual hosts right out of the box. Versions 1.1 and later of Apache support both IP-based and name-based virtual hosts (vhosts). The latter variant of virtual hosts is sometimes also called host-based or non-IP virtual hosts.

Following are the simple steps for creating/adding virtual hosts in Apache2 under Ubuntu:

Read more
0

Speed up the website using mod_spdy for Apache

mod_spdy is an open-source Apache module that adds support for the SPDY protocol to the Apache HTTPD server. This allows for faster page loading and more efficient bandwidth utilization when loading https URLs in SPDY-enabled browsers.

SPDY (pronounced "SPeeDY") is a new networking protocol whose goal is to speed up the web. SPDY augments HTTP with several speed-related features that can dramatically reduce page load time:
 * SPDY allows client and server to compress request and response headers, which cuts down on bandwidth usage when the similar headers (e.g. cookies) are sent over and over for multiple requests.
 * SPDY allows multiple, simultaneously multiplexed requests over a single connection, saving on round trips between client and server, and preventing low-priority resources from blocking higher-priority requests.
 * SPDY allows the server to actively push resources to the client that it knows the client will need (e.g. JavaScript and CSS files) without waiting for the client to request them, allowing the server to make efficient use of unutilized bandwidth.

NOTE:The SPDY protocol uses HTTPS, so your site needs to serve content over HTTPS in order to benefit from mod_spdy.

Read more
4

Recover Deleted Files using Scalpel under Ubuntu Linux

If you have accidentally deleted files from your hard drive, don't panic! You can easily recover deleted files whether you are using a Windows PC (NTFS) or Linux OS. You can undelete files with almost guaranteed success. The most important thing is to act as soon as you realize that the files are lost.

When a file is deleted from your computer it is not really deleted. It is simply removed from the database of files in the folder. Even though you can no longer see the file in the folder, its contents still exist 100% intact at this point.

Scalpel based on Foremost an open source application developed to recover deleted information, Scalpel is significantly more Fast and efficient by reading database of header and footer definitions and extracts matching files or data fragments from a set of image files or raw device files. Scalpel is file-system-independent and can recover files from FATx, NTFS, ext2/3, HFS+, or raw partitions. It is useful for both digital forensics investigation and file recovery.

Scalpel is a standalone tool file system. It is available on Linux and Mac OS, but can also be used in Windows, although it is necessary to compile it.

Read more
0

Install & Manage Fonts under GNOME desktop - Font Manager

Font Manager is not intended to be a professional-grade font management solution, but rather a simple application suitable for the needs of most desktop users.

Although designed with the GNOME desktop environment in mind, it should work well with most major desktop environments such as Xfce, Enlightenment, and even KDE.

Font Manager currently allows the user to:
 * Preview installed fonts
 * Compare installed fonts
 * Easily install or remove fonts
 * Easily activate and deactivate installed fonts
 * Specify different directories to search for fonts
 * Group fonts into "Collections", and easily activate or deactivate groups of fonts
 * Export "Collections" to an archive for easy backup, sharing, etc.
 * Provides quick access to all GNOME font utilities.

Read more
0

Install/Configure Music Server using DAAP - Tangerine

Tangerine is an application that allows you to publish music over the local network (streaming music server), using DAAP. It runs on Linux, Windows, and Mac OS X. There are several clients that you can then use to connect to it, such as Apple’s iTunes, Banshee, and Rhythmbox.

Music files can be specified either by a directory, or can be automatically discovered using Beagle, Google Desktop, or Spotlight. Recently you can also specify which music player you use and share the songs in it’s collection. For typical configurations, a graphical tool is included.

On the System where you have music collection located, install the DAAP server using following command
sudo apt-get install tangerine
Read more
Related Posts with Thumbnails