Time of Update: 2017-01-18
複製代碼 代碼如下:#!/bin/sh# desc: setup linux system security# author:coralzd # powered by www.freebsdsystem.org# version 0.1.2 written by 2011.05.03#account setuppasswd -l xfspasswd -l newspasswd -l nscdpasswd -l dbuspasswd -l vcsapasswd -l gamespasswd -l
Time of Update: 2017-01-18
1、登入主機並輸入ssh-keygen -t rsa 提示Enter file in which to save the key (/root/.ssh/id_rsa): 輸入/root/.ssh/sea_rsa 根據提示輸入相關路徑名和檔案名稱並產生兩個檔案(之後的兩個選項直接斷行符號) 2、把那個沒有.pub的檔案copy出來用puttygen轉換一下產生windows下putty可用的key(這裡指sea_rsa,選擇puttygen的Conversions的Import
Time of Update: 2017-01-18
bash case語句的例子。分享一段bash shell代碼,對於學習bash的同學理解case語句的用法,會有協助。例子:複製代碼 代碼如下:#!/bin/bash### Program:# File operation# 1.) Open file 2.) Display file 3.) Edit file 4.) Delete file# site:
Time of Update: 2017-01-18
一、問題的提出 如圖1所示,在單位有個私人地址為192.168.0.0的網路,各電腦是通過ADSL共用方式接入Internet,在家中有台電腦也通過ADSL訪問Internet,現在想在家中隨時安全地訪問單位192.168.0.2這台機器,實現方法很多,最為安全的是通過VPN。 二、什麼是VPN
Time of Update: 2017-01-18
複製代碼 代碼如下:useradd.sh#!/bin/bashfor name in tom joy john mark jamesdo useradd $name echo "redhat" | passwd --stdin $namedone好了,執行結束後會自動建立使用者tom、joy、john
Time of Update: 2017-01-18
公司有幾個伺服器開著多個memcached進程,除了要監控他們是否正常telnet通,執行個體是否存在外還要監控他們的快取命中率。針對他們的快取命中率進行警示。網上有個perl寫的,需要編譯安裝。有個python寫的,貼過來運行下,發現python庫版本不對。這麼簡單的指令碼搞得這麼費勁,就手動寫了個。越寫就越覺得shell處理資料,函數,字串數組這方面太弱勢了。還好,湊合用吧。這個指令碼比較簡單,通過check_tcp指令碼擷取memcached的stats資訊。然後將該資訊格式化成一個字串,
Time of Update: 2017-01-18
複製代碼 代碼如下:#include"apue.h"int userlogin(struct passwd **);int main(){ int ret,i=0; long ret_cwd; struct passwd *pw; char buf[128],hostname[16],usercwd[128]; char *ptmp1; do{ ret =
Time of Update: 2017-01-18
一例批量轉換目錄下檔案編碼的shell指令碼代碼。需求描述:由於從window轉linux過來,很多原來win下的gbk檔案需要轉換成utf8。以下指令碼僅判斷非utf8檔案轉換成utf8檔案,並且預設非utf8檔案為gbk,如果檔案類型不一致需要修改。例子:複製代碼 代碼如下:#!/bin/bash# File Name: iconv.sh# Author: wanggy# site: www.jb51.net#show_file(){ for file
Time of Update: 2017-01-18
最近遇到了一個麻煩事:機器上郵件隊列裡老是被塞滿,但是又不知道是什麼地方發郵件寫入的,十分蛋疼,沒辦法,只有臨時處理一下了,寫了個刪除郵件的指令碼rm_mqueue.sh。複製代碼 代碼如下:#/bin/bash ###################################### # touched by lingyun1 on 2014-12-01 # ######################################
Time of Update: 2017-01-18
樣本資源清單如url.txt:複製代碼
Time of Update: 2017-01-18
關於雙鏈表實現,一般教科書上定義一個雙向鏈表節點的方法如下:複製代碼 代碼如下:struct list_node{stuct list_node *pre;stuct list_node *next;ElemType data; }即一個鏈表節點包含:一個指向前向節點的指標、一個指向後續節點的指標,以及資料域共三部分。但查看linux核心代碼中的list實現時,會發現其與教科書上的方法有很大的差別。來看看linux是如何?雙鏈表。雙鏈表節點定義複製代碼 代碼如下:struct
Time of Update: 2017-01-18
1.定義變數時, =號的兩邊不可以留空格.eg:gender=femal————rightgender =femal———–wronggender= femal———–wrong2.條件測試語句 [ 符號的兩邊都要留空格.eg:if [ $gender = femal ]; then——-right.echo “you are femal”;fiif[ $gender...-----------------------wrongif [$gender...--------------------
Time of Update: 2017-01-18
timer_poll.h複製代碼 代碼如下:/* * File: timer_poll.h * Author: Administrator */#ifndef TIMER_POLL_H#define TIMER_POLL_H#include <sys/types.h>#include <fcntl.h>#include <signal.h>#include <sys/epoll.h>
Time of Update: 2017-01-18
複製代碼 代碼如下:#include<stdio.h>#include<stdlib.h>#include<sys/types.h>#include<sys/stat.h>int main(int argc,char **argv){ int mode; int mode_u; int mode_g; int mode_o; char *path; if(argc<3) {
Time of Update: 2017-01-18
最近在調試伺服器的iptables,自己做了個定時關iptables,但晚上回家很少開電腦,所以就沒法去啟動iptables,當然你可能會說,為什麼不取消定時關閉iptables,我只能說個人的環境不一樣,需求也就不一樣.指令碼內容:vi iptables-reset.sh複製代碼 代碼如下:#!/bin/bash#Powered by blog.slogra.comport=`iptables -vL|grep ssh|awk '{split($NF,a,":");print
Time of Update: 2017-01-18
自己在vps做的kingate服務端,估計最近佔用流量太大了,老是被服務商把我vps重啟,但kingate這個東西是一旦被強制結束掉,是無法開機啟動的,因為要把kingate.pid這個檔案刪除了才能啟動,好吧,對於我們這樣的懶人來說,當然不能自己去登入伺服器去手動刪除並啟動kingate,就寫了個簡單的shell指令碼來替我完成這些。系統:centos 5.x指令碼內容:cat kingate.sh複製代碼 代碼如下:#!/bin/bashkingate=`ps -C kingate
Time of Update: 2017-01-18
一、首先將apache日誌按天切割複製代碼 代碼如下: vi /etc/httpd/conf/httpd.conf ErrorLog "|rotatelogs /var/log/httpd/%Y%m%derror_log 86400 480" CustomLog
Time of Update: 2017-01-18
一直都想把expect的操作寫到bash指令碼裡,這樣就不用我再寫兩個指令碼來執行了,搞了一下午終於有點小成就,給大家看看吧.系統:centos 5.x1.先安裝expect複製代碼 代碼如下:yum -y install expect2.指令碼內容:複製代碼 代碼如下:cat auto_svn.sh#!/bin/bashpasswd='123456'/usr/bin/expect <<-EOFset time 30spawn ssh -p18330 root@192.168.10.
Time of Update: 2017-01-18
這幾天發現CentOS系統記憶體一直漲,即使把apache和mysql關閉了,記憶體也不釋放,可以使用以下指令碼來釋放記憶體: 指令碼內容: 複製代碼 代碼如下: #! /bin/bash # cache釋放: # To free pagecache:
Time of Update: 2017-01-18
主要目的是用於重啟後台比較重要的進程,如果採用killall -9強制kill掉,可能會引起問題。比如資料庫進程。代碼如下:複製代碼 代碼如下:#!/bin/shif [ -z "$1" ]; then /bin/echo "$0 <command line>" exit 1fiparam=''list='2 3 4 5 6 7 8 9'for i in $list; do eval p='$'$i &