Linux:Tips

Linux:Tips

hostname:

輸出主機名:
hostname
修改主機名:(實時,不持久化)
hostname test1280
修改主機名:(非實時,持久化,重啓生效)
* CentOS 6: /etc/sysconfig/network
* CentOS 7: /etc/hostname

查看系統版本:

cat /etc/issue
lsb_release -a
cat /etc/os-release
cat /etc/redhat-release
cat /proc/version
uname -a
test -e FILE FILE exists
test -f FILE FILE exists and is a regular file
test -d FILE FILE exists and is a directory
test -r FILE FILE exists and read permission is granted
test -w FILE FILE exists and write permission is granted
test -x FILE FILE exists and execute (or search) permission is granted
test -h FILE FILE exists and is a symbolic link (same as -L)
test -L FILE FILE exists and is a symbolic link (same as -h)
man test
cp -s src dst
cp --symbolic-link src dst
make symbolic links instead of copying

cp -l src dst
cp --link src dst
hard link files instead of copying

cp -f src dst
cp --force src dst
if an existing destination file cannot be opened, remove it and try again

cp -r srcdir dstdir
cp --recursive srcdir dstdir
copy directories recursively

抓包:

tcpdump tcp -i any port 6081 -s 0 -w test1280.pcap

某文件被哪些進程佔用:

fuser $ABSPATH

某進程佔用的端口號:

lsof -p pid | grep LISTEN
curl -v http://127.0.0.1:8080/
curl -v -X POST http://127.0.0.1:8080/
curl -v -X POST -H 'Content-Type: application/json' http://127.0.0.1:8080/
curl -v -X POST -H 'Content-Type: application/json' http://127.0.0.1:8080/ -d '{"name": "test1280"}'
curl -v -X POST -H 'Content-Type: application/json' http://127.0.0.1:8080/ -d @test1280.json
curl -v -k https://127.0.0.1:8090/

端口占用(監聽)

netstat -an | grep 22
netstat -anp | grep 22

-p, --program
    Show the PID and name of the program to which each socket belongs.
du * -sh

shell無限循環:

for((;;))
do
done
while true
do
done

shell有限循環:

for((i=0;i<10;i++))
do
done

動態庫搜索路徑:

echo "$INFORMIXDIR/lib" >> /etc/ld.so.conf.d/ids.conf
echo "$INFORMIXDIR/lib/esql" >> /etc/ld.so.conf.d/ids.conf
/sbin/ldconfig
/sbin/ldconfig -p

可執行文件添加粘着位:

* root權限下執行
* chown root $ABSPATH
* chmod a+s $ABSPATH
CPU物理核數:
cat /proc/cpuinfo | grep "physical id" | uniq
CPU邏輯核數:
cat /proc/cpuinfo | grep "core id" | wc -l
CPU型號參數:
cat /proc/cpuinfo | grep 'model name'
內存總量:
cat /proc/meminfo | grep MemTotal

字符集轉碼

iconv gbkfile -f gbk -t utf8
iconv gbkfile -f gbk -t utf8 > utf8file
iconv -l

-f fromcodeset
-t tocodeset
創建硬連接(非目錄)
ln source destination
創建軟連接(目錄或文件)
ln -s source destination
ln --symbolic source destination

Create hard links by default, symbolic links with --symbolic.
hwclock(Showing the Hardware Clock time is the default when no function is specified.)
hwclock --show
hwclock --hctosys
hwclock --systohc

設置日期:

date -s "20070414 13:58:00"
date -s "2008-04-14 13:58:00"
date -s "2009/04/14 13:58:00"

獲取日期:

date +%Y%m%d%H%M%S
date +%Y/%m/%d
mkdir -p
mkdir --parents
no error if existing, make parent directories as needed
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章