### Pip
sudo yum install python-pip
sudo pip install pyspark -i https://pypi.douban.com/simple
### systemctl
systemctl enable sshd.service
### grep
# OR
grep "a\|b"
grep -E "a|b"
grep -e "a" -e "b"
egrep "a|b"
# NOT
grep -v "abc"
# AND
grep -E 'a.*b'
### ps
# -e, all users
# -f, full format
ps -ef
# -o, user-define format
# psr, processor
ps -eo pid,args,psr --sort psr
# -u user
ps -fu vagrant
### netstat
# -a, all
# -n, numeric
# -t, tcp
# -u, udp
netstat -ant
# -l, listen
# -p, program
netstat -lntp
# -s shell
# -c command
su -s /bin/bash USER -c "cmd"
# ls open file
# -i Internet address
lsof -i :PORT
# -,-l,--login
su -
telnet IP PORT
# netcat
# = telnet + "stat"
echo stat | nc IP PORT
# -q, query
# -a, all
# -l, list
rpm -ql PKG
rpm -qa
# -l, list
repoquery -l PKG
# What pkg provide this file? (search in repo)
apt-file search bin/less
# -p pid
# -c, cpu list
# display affinity mask
taskset -p 1
# display affinity list
taskset -cp 1
# set CPUs
taskset -cp 1,2,3 PID
# run cmd on specific CPU
taskset -c 1 cmd args
# send signal
kill -HUP PID
kill -9 PID
# socket status
# -ant, all numeric tcp
ss -ant
### parallel distributed shell
# -w, node list
pdsh -w HOST,HOST,HOST CMD
# node list in /etc/pdsh/machines
pdsh CMD
# interactive mode
pdsh -w HOSTs
# -r, recursively
pdcp -w HOSTs -r SRCs DEST
### sshd
# gen host keys to /etc/ssh
ssh-keygen -A
# start
/usr/sbin/sshd
# debug
/usr/sbin/sshd -d
### config ssh
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub >> (Server) ~/.ssh/authorized_keys
chmod 0600 ~/.ssh/authorized_keys
### trace system calls and signals
strace ls
# only trace syscall open
# -e expr
strace -e open ls
# only trace open & read
strace -e trace=open,read ls
strace -p PID
# -r, relative time
strace -r ls
# -c, count
strace -c ls
# exec in current shell
source env.sh
# display all env
set
# remove
unset VAR
# help info for builtin commands
help set
# no HOME, no Login
useradd -M -s /sbin/nologin tmpuser
# create home dir
mkhomedir_helper tmpuser
# -D, print default config
useradd -D
# debug
bash -x script.sh
### cURL
# get
curl URL
# post
# -d, data
curl -d URL
### I/O redirect by root
echo "hello" | sudo tee /your/file
# -a, append
echo "hello" | sudo tee -a /your/file
sudo sh -c 'echo "hello" > /your/file'
### top
# h, help
# M, sorted by Mem
# P, sorted by CPU
# E/e, summary/task memory scale
top
### start container
docker ps -a
docker start centos
# -it, interactive & tty
docker exec -it centos bash
# port status
docker port centos
# container info
docker inspect centos
### HDFS
hdfs dfs -mkdir /user
# /user/<USER>/input
hdfs dfs -mkdir input
hdfs dfs -put etc/hadoop/*.xml input
# hdfs -> local
hdfs dfs -get output output
hdfs dfs -cat output/*
hdfs dfs -ls /dir
hdfs dfs -rm -r /dir
echo "hello" | hdfs dfs -appendToFile - hello.txt
echo "hello" | hdfs dfs -put - hello.txt
## show vars
show variables;
show status;
mysqladmin variables status
## set vars
set global wait_timeout=10;
# session
set wait_timeout=10;
## previlege
show grants;