commands
-
apt-get
-
install
$ sudo apt-get install mysql-server mysql-client E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem. $ sudo dpkg --configure -a Setting up libmysqlclient18:amd64 (5.6.24-0ubuntu2) ... Setting up libterm-readkey-perl (2.32-1build1) ... Setting up libaio1:amd64 (0.3.110-1) ... Setting up libdbi-perl (1.631-3build1) ... Setting up mysql-client-core-5.6 (5.6.24-0ubuntu2) ... Setting up mysql-server-core-5.6 (5.6.24-0ubuntu2) ... Setting up libdbd-mysql-perl (4.028-2) ... Setting up mysql-client-5.6 (5.6.24-0ubuntu2) ... Processing triggers for libc-bin (2.21-0ubuntu4) ...
-
-
curl
-
curl command resume broken download
# 1. auto find out where/how to resume the transfer $ curl -L -o 'filename' -C - url # 2. continue a previous file transfer at the given offset $ curl -C offset url
-
-
grep
-
find command that returns line number of the string
$ grep -n 'search-term' *.c
-
finding all files containing a text string on linux
$ grep -rnw _post -e "retry policy" _posts//2015-07-06-hadoop-cluster-5-node-setup.md:1068: 2015-07-08 08:20:48,046 INFO org.apache.hadoop.ipc.Client: Retrying connect to server: node5/192.168.120.155:9000. Already tried 3 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=10, sleepTime=1000 MILLISECONDS)
-
demo
# 1. find all `java` in all `sh` files $ grep "java" *.sh # 2. search all subdirectories recursively $ grep -r "java" . $ grep -R "java" . # 3. only display filenames $ grep -H -r "java" . # 4. use `cut` $ grep -H -R "java" . | cut -d: -f1 # 5. display only words $ grep -w -R "java" *.sh # 6. search two or more words $ grep -w -R "java|then" *.sh
-
-
hardware info and pixelbeat and cyberciti
-
kernel version and system architecture
$ uname -mrs $ uname -a
-
name and version of distribution
$ head -n1 /etc/issues
-
disk
# 1. all partitions registered on the system $ cat /proc/partitions # 2. info about disk sda $ hdparm -i /dev/sda # 3. dispaly installed hard disk and size $ fdisk -l | grep '^Disk /dev/' # 4. $ df -lh Filesystem Size Used Avail Use% Mounted on /dev/sda3 611G 2.0G 578G 1% / tmpfs 16G 0 16G 0% /dev/shm /dev/sda1 31G 205M 29G 1% /boot
-
ram total seen by system
$ grep MemTotal /proc/meminfo
-
cpu info
$ grep "model name" /proc/cpuinfo $ less /proc/cpuinfo # lscpu
-
list all usb devices
$ lsusb
-
list all block devices
$ lsblk
-
display info about hardware raid
$ arcconf getconfig DEV # /usr/StorMan/arcconf getconfig 1
-
dump all hardware info
# motherboard/cpu/verdor/serial-numbers # ram/disks/other info $ dmidecode | less
-
using lspci
$ lspci $ lspci -v $ lspci -vv
-
-
-
display all network interfaces
$ ifconfig -a
-
specific interface
$ ifconfig eth0
-
enable/disable interface
$ ifconfig eth0 up $ ifup eth0 $ ifconfig eth0 down $ ifdown eth0
-
assign ip
$ ifconfig eth0 192.168.100.100
-
assign netmask
$ ifconfig eth0 netmask 255.255.255.0
-
assign broadcast
$ ifconfig eth0 broadcast 192.168.100.255
-
assign ip netmask broadcast
$ ifconfig eth0 192.168.100.100 netmask 255.255.255.0 broadcast 192.168.100.255
-
change mtu
$ ifconfig eth0 mtu 1000
-
enable/disable promiscuout mode
$ ifconfig eth0 promisc $ ifconfig eth0 -promisc
-
add alias to interface
$ ifconfig eth0:0 192.168.100.100 $ ifconfig eth0:0
-
remove alias
$ ifconfig eth0:0 down
-
change mac address
$ ifconfig eth0 hw ether AA:BB:CC:DD:EE:FF
-
-
line edit shortcut
-
how do i clear delete the current line in terminal
$ some command you input_ and after the cursor ^ | ctrl + u delete all before ctrl + k delete all after ctrl + c cancel ctrl + y undo ctrl + w delete a word ctrl + l clear entire prompt
-
-
locale
-
$ sudo locale-gen zh_CN.UTF-8 $ sudo dpkg-reconfigure locales
-
$ sudo pico /etc/ssh/sshd_config # conment out this line # AcceptEnv LANG LC_* # restart ssh $ /etc/init.d/ssh restart
-
$ sudo pico /etc/ssh/ssh_config # conment out this line # SendEnv LANG LC_*
-
fixing locale warnings notices issues on linux server or desktop
$ locale locale: Cannot set LC_CTYPE to default locale: No such file or directory locale: Cannot set LC_MESSAGES to default locale: No such file or directory locale: Cannot set LC_ALL to default locale: No such file or directory LANG=en_US LANGUAGE= LC_CTYPE="en_US" LC_NUMERIC=en_US.UTF-8 LC_TIME=en_US.UTF-8 LC_COLLATE="en_US" LC_MONETARY=en_US.UTF-8 LC_MESSAGES="en_US" LC_PAPER=en_US.UTF-8 LC_NAME=en_US.UTF-8 LC_ADDRESS=en_US.UTF-8 LC_TELEPHONE=en_US.UTF-8 LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=en_US.UTF-8 LC_ALL= $ sudo update-locale LC_ALL="en_US.UTF-8" $ logout # login $ locale LANG=en_US.UTF-8 LANGUAGE= LC_CTYPE="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL=en_US.UTF-8 $ cat /etc/default/locale LANG="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8"
-
-
netstat
-
nagios connection refused socket timeout
# check host is listening on port 5666 > netstat -aon | findstr 5666
-
get all tcp process pid port
# get `pid/program name` from port $ netstat -antp (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN - tcp 0 0 10.13.178.100:22 10.13.178.171:61212 ESTABLISHED - tcp6 0 0 :::9092 :::* LISTEN 1288/java tcp6 0 0 127.0.0.1:8005 :::* LISTEN 1288/java tcp6 0 0 :::8009 :::* LISTEN 1288/java tcp6 0 0 :::8080 :::* LISTEN 1288/java tcp6 0 0 :::22 :::* LISTEN -
-
-
openssl
-
dgst
$ echo -n "http://releases.ubuntu.com/14.04/ubuntu-14.04.1-server-i386.iso" | openssl dgst (stdin)= 412e4a818779276896b68b3ba0913534
-
dgst -sha256
$ echo -n "http://releases.ubuntu.com/14.04/ubuntu-14.04.1-server-i386.iso" | openssl dgst -sha256 (stdin)= 90a2489db0fb9bf8e4062a05cdd528d372c3ff6e028edfde5666b7ae73a3d18a
-
-
ps
-
filter java process
$ ps -ef | grep java node 1288 1 2 14:52 pts/0 00:00:15 /usr/local/java/jdk1.7.0_79/jre/bin/java -Djava.util.logging.config.file=/home/node/biserver-ce/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Xms1024m -Xmx2048m -XX:MaxPermSize=256m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.endorsed.dirs=/home/node/biserver-ce/tomcat/endorsed -classpath /home/node/biserver-ce/tomcat/bin/bootstrap.jar -Dcatalina.base=/home/node/biserver-ce/tomcat -Dcatalina.home=/home/node/biserver-ce/tomcat -Djava.io.tmpdir=/home/node/biserver-ce/tomcat/temp org.apache.catalina.startup.Bootstrap start node 1366 1102 0 15:00 pts/0 00:00:00 grep --color=auto java
-
-
ssh
-
# 1. if not in `known_hosts` you must confirm `yes` $ start-dfs.sh Starting namenodes on [singlenode] The authenticity of host 'singlenode (192.168.100.100)' can't be established. ECDSA key fingerprint is f1:14:06:ef:f4:08:e5:a2:bd:c8:54:50:1d:ca:8e:56. Are you sure you want to continue connecting (yes/no)? yes singlenode: Warning: Permanently added 'singlenode,192.168.100.100' (ECDSA) to the list of known hosts. singlenode: starting namenode, logging to /opt/bigdata/hadoop-2.7.0/logs/hadoop-hadoop-namenode-singlenode.out singlenode: starting datanode, logging to /opt/bigdata/hadoop-2.7.0/logs/hadoop-hadoop-datanode-singlenode.out Starting secondary namenodes [0.0.0.0] The authenticity of host '0.0.0.0 (0.0.0.0)' can't be established. ECDSA key fingerprint is f1:14:06:ef:f4:08:e5:a2:bd:c8:54:50:1d:ca:8e:56. Are you sure you want to continue connecting (yes/no)? yes 0.0.0.0: Warning: Permanently added '0.0.0.0' (ECDSA) to the list of known hosts. 0.0.0.0: starting secondarynamenode, logging to /opt/bigdata/hadoop-2.7.0/logs/hadoop-hadoop-secondarynamenode-singlenode.out # 2. stop `dfs` and rm `known_hosts` $ stop-dfs.sh $ rm known_hosts # 3. add to `known_hosts` $ ssh-keyscan -H 0.0.0.0 >> known_hosts $ ssh-keyscan -H singlenode >> known_hosts $ ssh-keyscan -H 192.168.100.100 >> known_hosts # 4. `start-dfs` Starting namenodes on [singlenode] singlenode: starting namenode, logging to /opt/bigdata/hadoop-2.7.0/logs/hadoop-hadoop-namenode-singlenode.out singlenode: starting datanode, logging to /opt/bigdata/hadoop-2.7.0/logs/hadoop-hadoop-datanode-singlenode.out Starting secondary namenodes [0.0.0.0] 0.0.0.0: starting secondarynamenode, logging to /opt/bigdata/hadoop-2.7.0/logs/hadoop-hadoop-secondarynamenode-singlenode.out
-
-
sudo
-
# 1. append to `/etc/sysctl.conf` $ sudo sh -c 'echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf' $ sudo sh -c 'echo "net.ipv6.conf.default.disable_ipv6 = 1" >> /etc/sysctl.conf' $ sudo sh -c 'echo "net.ipv6.conf.lo.disable_ipv6 = 1" >> /etc/sysctl.conf' # 2. verify edit $ sudo sysctl -p net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1 # 3. verify $ cat /proc/sys/net/ipv6/conf/all/disable_ipv6 1
-
-
sysctl
-
$ sysctl net.ipv4.ip_local_port_range net.ipv4.ip_local_port_range = 32768 61000
-
-
telnet
-
$ telnet node1 5666 Trying 192.168.120.151... Connected to node1. Escape character is '^]'. ctrl+] telnet> quit
-
-
tr
-
$ fab sete hd1 | grep part-m-00000 | tr -s ' ' | cut -f 10 -d ' ' # get hdfs dfs -ls -R output's file path
-
-
tail
-
how can i reverse the order of lines in a file
$ tail -r myfile.txt
-
how reverse selected lines order in vim
:g/^/m0 :help 12.4
-
-
wget
-
spider a website and return urls only
wget --spider --force-html -r -l2 http://mirrors.cnnic.cn/apache/ 2>&1 \ | grep '^--' | awk '{ print $3 }' \ | grep -v '\.\(css\|js\|png\|gif\|jpg\)$' \ > urls.m3u
-