Tips, Tricks, Guides

How to avoid search engines from crawling your website?

Your answer is to create a robots.txt file in the root of your web directory and to have the code setting given below in the file.

User-agent: *
Disallow: /

You can read more about Robots exclusion protocol, here

Share it onShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Linux: How the password is stored, salted and hashed securely?

In earlier systems, passwords were stored in the file /etc/passwd and they were not encrypted.

After the user is created, an entry gets recorded in /etc/passwd with ‘x’ in the second column instead of the acutal password.

$ useradd timmy

$ cat /etc/passwd
timmy:x:1002:1003::/home/timmy:/bin/sh

For security reasons, passwords are now stored in the file /etc/shadow and they are encrypted. Password was not set initially, when the user was created. This is indicated by !! mark (in RedHat, ! – Debian)

$ cat /etc/shadow

timmy:!!:15870:0:99999:7:::

Continue Reading…

Share it onShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

How to Compress, Uncompress to .gz, .bz2?

Tar (tape archive) does not compress files. They are used for grouping all files in a folder so that it can be transferred across locations. In order to compress the files, you need to use zip, gzip or bzip2 utilities.

gzip, bzip2 are file compression utilities and gunzip, bunzip2 are file uncompression utilities.

bzip2 compresses files to a smaller size compared to gzip, but it takes longer to compress the files. Bzip2 uses Burrows-Wheeler block sorting text compression algorithm (with Huffman coding) and gzip uses Lempel-Ziv coding. so, a file compressed with one utility cannot be uncompressed with the other utility.
Continue Reading…

Share it onShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Shell Scripting: Linux variables

Linux variables have the prefix $. Variables that will be useful in shell scripting are listed below.

$$ Process ID number of the shell in execution
$? Variable indicating Exit status (from the last command that got executed)
$* Entire argument string in the command line (excluding script name)
$# Number of arguments in the command line (not counting the shell script name)

To access arguments passed to a script, following variables are used.

$0 Name of the program (with entire path)
$1 First argument passed in the command line
$2 Second argument passed in the command line
$n Nth argument passed in the command line

To move or shift to a specified argument in the list of arguments, “shift” command is used. For example, to shift 1 argument just type “shift” or “shift 1” and to shift to the third argument in the list type “shift 2“.
Continue Reading…

Share it onShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Linux: Path settings

$PATH is the environment variable related to Linux Path settings.

To add a directory to the path, type
$ export PATH=$PATH:/tmp/myshells

The above change is in effect only in the shell from where it is being called

To set the PATH for a specific user, type the below 2 lines in the user’s .bash_profile file ($HOME/.bash_profile).

PATH=$PATH:/tmp/myshells
export PATH

To set the PATH for ALL users except the root user, type the following line in /etc/profile
export PATH=$PATH:/tmp/myshells

Root user is not affected by any setting changes under /etc/profile. To set the path for the root user, we need to modify the root users’ .bash_profile (/root/.bash_profile)

Share it onShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Shell Scripting: Saving Shell scripts

For example, if we have shell script named “myshellscript.sh” (with execute permission) we can make it run in the current working directory with the commands

$ sh myshellscript.sh (or)
$ ./myshellscript.sh

If the shell scripts are stored in an executable path, it will save us from typing extra keystrokes. To find the paths that are setup, type

$ echo $PATH
/usr/bin: /usr/local/bin

Continue Reading…

Share it onShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Shell Scripting: How to execute Shell Scripts?

Shell scripts are written to execute a set of commands and to group them. The scripts will have the following special line

#!/bin/bash

This is an indication that the shell script is used in bash shell and that it should be called for command execution.

To know the path of the bash shell, type
$ cat /etc/shells
Continue Reading…

Share it onShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Shell Scripting: What is Shell?

Shell is an environment around the Kernel providing user interaction. It accepts user commands and convert them to binary code. It is not part of the kernel but uses the kernel to execute the commands.

Commonly available shells
– BASH (Bourne Again Shell)
– CSH (C Shell)
– KSH (Korn Shell)

All these shells do the same job and the differences come in the form of syntax that these shells use to execute commands and the built-in functions that comes along with it.

You can find the shell that is in execution by typing
$ echo $SHELL

To find all the available shells in the system, type
$ cat /etc/shells

Share it onShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Linux: Password creation

To create a password file and to add users to it, use the command
$ htpasswd -cm /secured/.mypass username1

To add users to the already existing password file, use the command
$ htpasswd -m /secured/.mypass username2

When additional users are added to the password file, ensure that you don’t use the “-c” option.

Read Password protect directories here

Share it onShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Linux: Determining IP information for eth0… failed

When setting up a workstation to connect to internet, you may come across a message
Determining IP information for eth0… failed

The above error message basically means that eth0 i.e your network interface card is not setup correctly.

Some of the commands that can come handy in troubleshooting where the error lies are listed below

$ dmesg | grep eth0
(displays information about the ethernet controller card, mac address etc.)

$ cat /etc/sysconfig/network(displays the network settings)
NETWORKING=yes
HOSTNAME=localhost.localdomain
GATEWAY=192.168.122.1

$ cat /etc/sysconfig/network-scripts/ifcfp-eth0

$ ifconfig eth0 down (to down the nic)
$ ifconfig eth0 up (to start the nic)
$ netstat -rn (display kernel routing IP table)
$ cat ifcfg-eth0 (eth0 configuration settings)
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:16:18:33:B3:CF
ONBOOT=yes

$ service network restart (restart the network settings)

$ ping -c4 google.ca(to check if the internet connection works)

$ traceroute google.ca (to check how the IP navigation path is set)

Refer Red Hat linux 5 configure network article for additional info

Share it onShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn
Kurinchi Calendar
April 2018
M T W T F S S
« Oct    
 1
2345678
9101112131415
16171819202122
23242526272829
30