原创 MySQL 註釋及特殊語法

三種註釋 mysql> SELECT 1+1; # This comment continues to the end of line mysql> SELECT 1+1; -- This comment continue

原创 用 Telnet 檢查是否能連接遠程 TCP 端口

445 爲 samba 服務器綁定的端口: telnet 10.12.16.178 445按 【Ctrl+]】進入 Telnet 命令行: 歡迎使用 Microsoft Telnet Client Escape 字符爲 'CTRL+]'

原创 vi, sed 等程序竟然後改變文件 inode!!!

創建一個文件 lock.txt, 內容只有 "123" 三個字符: > ls -i lock.txt 2172299 lock.txt > vi lock.txt "lock.txt" 1L, 5C 已寫入

原创 顯式調用析構函數與棧中 new 對象

#include <iostream> #include <new> class Test { public: Test(int ii) : i(ii) {} ~Test() { std::cout << i <<

原创 ps

常用選項 -e: Select all processes. Identical to -A. -f: does full-format listing, can be combined with many other UNIX-sty

原创 64位和32位平臺下C/C++結構內存對齊

1. 在 64 位 Linux 下,結構體字段默認按 8 字節對齊;32 位 Linux 下,默認 4 字節對齊。 2. 顯示指定對齊方式時,會受到機器字長的約束,即 64 位 Linux 下可以按 8 字節及以下的任意字節對齊,32 位

原创 netstat

子命令 netstat: 不加子命令,可用 ss 代替; Display a list of open sockets. netstat -r: –route, 可用 ip route 代替; Display the kernel

原创 C 常用基本類型的原型——time_t, size_t 等

time_t /usr/include/time.h typedef __time_t time_t; /usr/include/bits/time.h struct timeval { __time_t tv_sec;

原创 errno 的坑

由於 strtoll, strtoull 返回值不能標識處理是否成功,所以需要藉助 errno, 看下面這段代碼: #include <stdio.h> #include <stdlib.h> #include <errno.h> i

原创 popen+pclose 執行 shell 命令

在《system() 執行 shell 命令》中,我們介紹了 system 執行 shell 命令的方法,system 返回值比較混亂,難以理解,而且 popen 在處理子進程標準輸出上會很方便。 注意:管道只能處理標準輸出,不能處理標準

原创 curl 命令

get request curl "param1=value1¶m2=value2" http://www.xxx.com post request curl -d "param1=value1¶m2=value2" http:/

原创 使用 dmesg 和 addr2line 分析程序 core 原因

今天遇到這樣一種情況:發現進程 tagent 在發送響應時退出了,退出原因未知,因爲沒有 core 文件,無從分析。core 文件生成目錄和 ulimit 都沒有任何問題,就是不生成 core 文件: $ cat /proc/sys/ke

原创 tcpdump

命令格式 tcpdump [option] [expression] 重要選項 -i : 指定讀取 packets 的網卡,如果不指定,以讀取序號最小的網卡,如系統存在 eth0 和 eth1, 則讀取 eth0 的。 Note: 如果

原创 C++ string 陷阱—— append() 與相加

#include <string.h> #include <string> #include <iostream> // xxx.so --> xxx --> xxx_get_inst int main() { std::st

原创 top

top, free 與虛存管理 常用選項(COMMAND-LINE Options) -a : Sort by memory usage. 以 %MEM 排序,默認以 %CPU 排序 -M : -M : Detect memory un