Output colourful words in the terminal

It’s easy to change words colour, such as:

echo -e "\033[0;31;40mhello world"
you will see the terminal turn red!!! cool,right?
let’s analysis this sentence,we all know hello world, it’s print content,
the important thing is \033[0;31;40m,it have some rules init.
\033 is octal, “[” is colour’s sign, when xterm saw \033 it would know 
what print colour is.also you can set the hexadecimal if u like.
Behind the “\033[” there are three opition,They represent the attribute,colour and back colour
0;31;40 0 is original attribute,31 is red code 40 is black code.
there are some code you can use:
Font attribute:
0 Reset All Attributes (return to normal mode)
1 Bright (usually turns on BOLD)
2 Dim
3 Underline
5 Blink
7 Reverse
8 Hidden

 

Font colour:

30 black
31 dark red
32 light green
33 dark yellow
34 dark blue
35 light violet
36 light blue, cyan
37 white

 

Background colour:

40 Black
41 Red
42 Green
43 Yellow
44 Blue
45 Magenta
46 Cyan
47 White

The RPM package naming convention

 

The RPM package for general format is:

name-version-arch.rpm

name-version-arch.src.rpm

EXAMPLE:

httpd-2.2.3-29.el5.i386.rpm

httpd-devel-2.2.3-29.el5.i386.rpm

httpd-manual-2.2.3-29.el5.i386.rpm

system-config-httpd-1.3.3.3-1.el5.noarch.rpm

 

(1)name,httpd,this is package name.

(2)version,  2.2.3, this is version number, the formart always is “major num,second num,Revision num”

(3)arch,:i386,Hardware platform, the application of the said package

(4).rpm  or .src.rpm,Is the RPM package type suffixrpm   src means source package

proc

The/proc file system is a kernel and the kernel module is used to send information to the process (process) mechanism (so called/proc). The pseudo file system allows you to interact, and the kernel internal data structure to obtain useful information about the process, in the run (on the fly) change the Settings (by changing the parameters of the kernel). Unlike other file systems, / proc exists in memory rather than the hard disk. If you look at the file/proc/mounts (as well as the mount command to list all the files have been loaded system), you will see that one line is this:

image

The PROC  file system can be used to collect useful information about the system and the running kernel. Here are some important documents:

* /proc/cpuinfo – CPU information
* /proc/meminfo – physics memory,swap
* /proc/mounts – mounted file system
* /proc/devices – devices list
* /proc/filesystems – supported file system
* /proc/modules – loaded modules
* /proc/version – kernel version
* /proc/cmdline – System startup input of the kernel command line parameters

Use SHELL script to prevent violence crack

This script can  prevent the brute force,someone will  use Dictionary tools to crack the ssh or vsftpd services, this script is wrote by a Linux operation and maintenance engineer, so i  quote to my blog,you can use it on your server

CODE LIKE THIS:

#!/bin/bash

awk '{for(i=1;i<=NF;i++){if($i ~ /rhost/)print substr($i,7)}}' /var/log/secure | sort |uniq -c>/root/black.txt

DEFINE="100"

cat /root/black.txt |    while read LINE

do

NUM=`echo $LINE |awk '{print $1}'`

host=`echo $LINE    |awk '{print $2}'`

if [ $NUM -gt $DEFINE ];

then

grep $host    /etc/hosts.deny > /dev/null

if [ $? -gt 0 ];

then

echo "sshd:$host" >> /etc/hosts.deny

echo "vsftpd:$host" >> /etc/hosts.deny

fi

fi

done

 

default DEFINE number is 100,you can according to your log condition to change this number,

script will use awk get the number bigger than 100 then put it into black.txt

then use while to read it, let this ip into the /etc/host.deny file,default is deny ssh and vsftpd services.

linux crontab

assign

crontab is an important command in our work,we often use it to do some backup,running script …blablablabla…. just one word, it’s essential!!!

 

1.usage

image

we often use –u –l –r and –e

 

2. command explain

From crontab command,we can in a fixed time interval to perform a specified system instructions or shell script script,Unit time interval can be minute, hour, day, month, week, and any combination of the above.

3.which file will be used?

             file                                                             explain  

              /etc/cron.deny                                              in this file user can’t use crontab

             /etc/cron.allow                                              in this  file user can use crontab

             /var/spool/cron/                                           all user crontab file storage directory

 

4.command opition explain

  -l     display user crontab’s file

-e      use vi to edit crontab file   

-r       del user crontab

-u       assign user

 

5.the use of the instruction format

Format will be divided into seven section, the first five period of time setting, the sixth paragraph to which user crontab, seventh for the segment to execute commands Format is as follows:

01 * * * * root run-parts /etc/cron.hourly

02 4 * * * root run-parts /etc/cron.daily

22 4 * * 0 root run-parts /etc/cron.weekly

42 4 1 * * root run-parts /etc/cron.monthly

      segment        implication      range

           1                mins               0-59

           2                 hours            0-23

           3                 day               1-31

           4                 moths            1-12

           5                  week            0-7 7is Sunday

6.example

#crontab –l

0  0  * * *  /root/back.sh

this example means at everyday 0 oclock, exec /root/back.sh

0 11 * * 1-3 /root/backup.sh

Every Mon-Thu at 11 o’clock exec backup.sh

The commonly used environment variables

PATH    Determines the shell will be find command or program to which directory

HOME   The current user home directory

HISTSIZE       The number of Record

LOGNAME    The current user login name

HOSTNAME    The hostname – -

SHELL      The current user’s shell type(default is bash shell)

PS1     Basci prompt(can change, root default is #,common user is $)