夕口技術錄

專業上的小常識,備而用之~

Monthly Archives: 六月 2009

[Win][netsh] – 利用netsh指令查詢Dhcp-Server用戶端保留區

利用netsh指令查詢Dhcp-Server用戶端保留區
在命令提示字元下輸入指令順序如下
# netsh
#dhcp
#server x.x.x.x
#scope x.x.x.x
#show reservedip

[Win][putty] – 設定備份方式

Putty是一個可在windows平台上ssh連線的一套免費軟體
小弟因為有外接幾個case 是使linux且家中也是有linux 伺服器
因為有蠻多ip要寄且如果電腦有重灌putty 設定全部要重設實在麻煩
閱讀全文

[Linux][Redhat 9.0] – route table多出169.254.0.0這一筆route table 的解決方法

問 :

為何安裝Redhat 9.0後,系統的route table多出169.254.0.0這一筆route table?

解 :

這是因為/etc/sysconfigu/network-scripts/ifup ,新增了以下敘述
代碼:
# Add Zeroconf route.
if [ -z “${NOZEROCONF}" -a “${ISALIAS}" = “no" ]; then
    ip route replace 169.254.0.0/16 dev ${REALDEVICE}

 「解決方法」請至/etc/sysconfig/network-scripts 目錄下針對所有的ifcfg-ethx(eth0、eth1)檔案裡,新增以下敘述
代碼:
NOZEROCONF=yes

 

然後重新restart 該ethernet interface

[Linux][iptable] – An iptables guide & tutorial

An iptables guide & tutorial

一個把 iptable 寫的不錯網站

[Apache] – (98)Address already in use: make_sock: could not bind to address [::]:80?

問:

在進行 apache 重啟時發現以下問題出現 ?

# ./apachectl start
(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs

解:

使用 lsof 時才發現,
原來是網頁上執行程式中,
有人把它 lock 住了
# ps aux | grep snort
500      17211  0.0  0.2 53796 1124 ?        S    16:01   0:00 sh -c cd ‘/usr/local/apache/www/html’ ; /usr/bin/sudo /usr/local/apache/bin/snortc -l /usr/local/apache/log 1,2\> /dev/null \& <- 就是這行
root     17212  0.0  0.2 10092 1000 ?        S    16:01   0:00 /usr/local/apache/bin/snortc -l /usr/local/apache/log 1,2> /dev/null &
root     17669  0.0  0.1 51056  596 pts/1    R+   16:04   0:00 grep snort

因此把它 pid 直接 kill 掉就行啦 !!!

# lsof -i :80
COMMAND  PID      USER   FD   TYPE DEVICE SIZE NODE NAME
sh       713   apache    3u  IPv6 189115       TCP *:http (LISTEN)
sh      1795  apache    3u  IPv6 189115       TCP *:http (LISTEN)

# kill -9 713 1795
# ./apachectl start
# pgrep httpd
3774
3776
3777
3779
3780
3781
3782
3790
3792
3794
3795
3796

問題:

/usr/openv/netbackup/bin/bpcd: error while loading shared libraries:

libstdc++-libc6.2-2.so.3: cannot open shared object file: No such file or directory

解決:

1、# locate libstdc++-libc6.2-2.so.3 果然沒有
2、# yum -y install libstdc++-libc6.2-2.so.3
它會安排以下二個檔案

compat-libstdc++-296-2.96-132.7.2.i386.rpm
libgcc-3.4.6-10.i386.rpm

Dependencies Resolved

=============================================================================
Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
compat-libstdc++-296    i386       2.96-132.7.2     base              176 k
Installing for dependencies:
libgcc                  i386       3.4.6-10         base               64 k

Transaction Summary
=============================================================================

3、# ldconfig -p | grep  libstdc++-libc6.2-2.so.3 有啦
libstdc++-libc6.2-2.so.3 (libc6) => /usr/lib/libstdc++-libc6.2-2.so.3

[Linux][user][group] – How to Add User To Group

Q. How can I add a user to a group under Linux operating system?

A. You can use useradd or usermod commands to add a user to a group. useradd command creates a new user or update default new user information. usermod command modifies a user account i.e. it is useful to add user to existing group. There are two types of group. First is primary user group and other is secondary group. All user account related information is stored in /etc/passwd, /etc/shadow and /etc/group files to store user information.

useradd example – Add a new user to secondary group

Use useradd command to add new users to existing group (or create a new group and then add user). If group does not exist, create it. Syntax:
useradd -G {group-name} username
Create a new user called vivek and add it to group called developers. First login as a root user (make sure group developers exists), enter:
# grep developers /etc/group
Output:

developers:x:1124:

 閱讀全文

[Linux][sed] – 去除文件中的連續空白行

[root@book sh]# cat a.txt
ddddddddddd

ssssssss                     dddddddddddddd

ssssssssssssss

ddddd                 sssssssssssaaaaaaaaaaa

[root@book sh]# cat a.txt -s
ddddddddddd

ssssssss                     dddddddddddddd

ssssssssssssss

ddddd                 sssssssssssaaaaaaaaaaa

[root@book sh]# cat -s a.txt | sed ‘/^[[:space:]]*$/d’
ddddddddddd
ssssssss                     dddddddddddddd
ssssssssssssss
ddddd                 sssssssssssaaaaaaaaaaa

[Liunx] – top

Top

The top command diplays running Linux tasks. The information it offers is:

  • PID – Process ID
  • USER – The user who ran the command
  • NI – The nice level of the process
  • VIRT – Virtual memory the process is using
  • RES – Resident (non virtual) size of memory
  • SHR – The amount of shared memory a task is using
  • S – Process status
  • %CPU – The percentage of the CPU the process uses
  • %MEM – The percentage of memory the process uses

[Linux][watch][free] – Display Linux memory usage in real-time

If you want to display your memory usage in real-time, do a

It will display used and free memory every two seconds.

watch -d “free -mt”