Skip to content

Latest commit

 

History

History
1361 lines (1350 loc) · 59.8 KB

Linux.org

File metadata and controls

1361 lines (1350 loc) · 59.8 KB

Terminal command 1

shortcut

keybindingsdescription
C-aset cursor to the begin of line
C-eset cursor to the end of line
C-kkill all after current cursor
C-ukill all before current cursor
C-ddelete char after current cursor
C-hdelete char before current cursor
C-wdelete word after current cursor
C-yyank which kill by C-u\C-d\C-w
C-lclear all record
C-rread history commands
C-bbackward
C-fforward
C-tturn char to forward char
C-leftbackward word
C-rightforward word
S-C-tnew table
S-C-tclose table
S-C-ccopy
S-C-vpaste
M-numberselect table
S-C-nnew window
S-C-qquit
C-cquit current task
C-zbackground running
C-S-ffind
C-S-tnew Tab
C-PgUp/PgDnswitch Tabs
S-PgUp/PgDnPage Up/Down
C-h blist all bindings available in the buffer
C-h mget a list of keybindings
C-h kkeybindings destription

commands

~/ # /home/madhouse
echo $HOME # show home 
pwd # show location
mkdir # make a new directory
mkdir -p # parents no error if existing, make parent directories as needed
mkdir -m # mode=MODE set file mode (as in chmod), not a=rwx - umask
cd # enter target directory 
ls # list of directories
ls -a # list of all directories, including hidden file
ls -l # list of all directories and file with limition
ls -lht # list of all directories and size
du -sh  # size of current directory
mv filename dir # move file to target directory
ln src  dst # create hard link                               |
ln -s src dst # create symbolic link
ln -snf src dst # create new location symbolic link              
~/ # /home/madhouse/
sudo apt install <application> # install application
sudo apt remove <application> # uninstall application,reserve config
sudo apt-get <name> remove # uninstall application and config
/etc/apt/sources.list # ubuntu sources file location
sudo apt update # refresh source
sudo apt upgrade # upgrade all application
sudo apt autoremove <name> # uninstall no required packages
sudo apt full-upgrade # upgrade all application and packages
apt search <name> # search application
apt show # list of install deteails
apt list # list of all application
apt edit-sources # list of all source
apt-get autoclean # clean packages
apt-get clean # clean packages and cache
dpkg -i xxx.deb # install
dpkg -r xxx.deb # uninstall
dpkg -r -purge xxx.deb # uninstall and delete configration
dpkg -info xxx.deb # get information about deb package
dpkg -l # list install packages
dpkg --get-selections|grep <name> # search application about name
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P xxx # clean residual file
dpkg -l <package name> # list of all directories of package
wget <link-address> # download in current directory
wget -O <dir> <link> # download link on the dir
wget -i file.txt # execute links on the txt file (download many files)
wget -b <link> # download link on background, generate web-log file on current directory
wget -o <link> # download link on background, generate web-log file on current directory
wget -c <link> # contient to download
wget --limit-rate=100k -O  <link> # limit download rate =100kb
wget --spider <link> # test download link
wget --tries=3 <link> # define retry download 3 times
wget --mirror -p --convert-links -P <local-dir> <link> # download web all links and packages,and convert links to local directory
wget --reject=png --mirror -p --convert-links -P <local-dir> <link> # download reject target file(png)
wget -Q5m -i file.txt # download reject size over 5Mb
wget -r -A .png <link> # download target file(png) from web
wget --file-user=USERNAME --file-password=PASSWORD <url> # download from FTP
dpkg -i .deb # install deb package
sudo dpkg -l # list of all apt
touch <filename> # create file 
mkdir <foldername> # create folder
rm <filename> # remove file
rm -d <filename> # remove file and hard link
rm -f # force remove
rm -r # recursive remove
rm -v # remove and check verbose
rm -rf # clean currnt folder
rmdirr <foldername> # remove folder
sudo du -sh *  ##查看目录文件大小

kill processes 1 proc record all processes PID var/log dmesg locate this directory

ps -aux # show all processes number
ps -aux|more # use more to check all processes number
ps -aux|less # use less to check all processes number
ps -A # list all processes
ps -U root -u root -N # list all processes without root
ps -u madhouse # list all processes from usrname "madhosue"
top # dynamic display allq processes, -q quit -h help
ps - ejH # list processes trees
ps axjf # list processes trees
ps -eLf # threads messaegs
ps axms # threads messaegs
top -b -n1 > ~/process.log # save list of all processes as log files
top -b -n1 | mail -s 'Process snapshot' yao.lin1703@e-nebual.com # sent processes list to email
cp -r source/ destination/
kill -9 PID # force kill processes
kill PID # kill processes
ps -aux|grep firefox # check processe about firefox
pgrep firefox # check process about firefox
pgrep -u madhouse sshd # search processe name about "sshd" username "madhouse"
echo "..." > filename # cover wirte
echo "..." >> filename # add wirte
dmesg > boot.msg # save device boot messages to boot.msg
dmesg | less # less dmesg
shutdown -h now # poweroff
shutdown -P now # poweroff
shutdown -h # poweroff 1 minute later
shutdown -r now # reboot now
shotdown -h 20 # poweroff 20 seconds later
reboot
reboot -f # force reboot
halt # poweroff
init 6 # reboot
init 0 # turn off system
logsave test.log ./usb_can # save Terminal print informations as test.log
./usb_can 2>&1 | tee mylog.log # 
ftp [hostname| ip-address] # login ftp sever, ftp default port: 21
ftp ip port # login ftp server (ip & port)
get [remote-file] [local-file] # gei remote file
mget [remote-directory] [local-file] # get remote files
mget *.* # get all files
put [local-file] [remote-file] # put file to remote
mput [local-file] # puts files to remote
bye # disconnect sever
find /home/madhouse -name BMSCAN.org # search for BMSCAN.org in /home/madhosue
find /home/madhouse -name *.conf # search for .conf files in home
find /home/madhouse -name ".*" -ls # ls all files and directories begin with "."
find ~ -name *v2g* # search for filename including "v2g" in ~ directory
locate BMSCAN.org # find BMSCAN.org location
find ./ -type d # find all directories in current directory
find ./ -type f # find all files in current directory
find ./ -type f -inname ".*" # search for all files begin with ".", inname -- Ignore case
find ./ -path '*Yaoli*' -name '*.json' # find .json file in directory whom name including "Yaoli"
find ./ -type d -exec chomod 777 # execute premission to all directories
find ./ -size +5M # find all files size > 5M
find ./ -size -5M # find all files size < 5M
find ./ -mtime -5 # find all files modified within 5 days
find ./ -mtime +5 # find all files modified more than 5 days
find $HOME -name ".org" -ls > foo.txt # find and save log
find ~ -name "*698.45*" # 递归查找
  # ftp command
    ftp # start ftp client
    ftp> open # open server
    (to) 192.168.1.117
    login name
    password
    pwd
    cd ./
    ls
    put mput
    get mget
    help
    deiete
  # tftp
    cd /srv/tftp # store file to send
Usage: tftp [OPTION] ... HOST [PORT]
Option:
        -l FILE Local FILE
        -r FILE Remote FILE
        -g      Get file
        -p      Put file
google-chrome # run chrome
whereis google-chrome # get google-chrome patch
whereis emacs # get emacs patch
htop
crontab -l
nslookup ix.xo

Vim

%! sudo tee % /dev/null # 在vim保存需要权限的文件
w !sudo tee % # vim E212 cant open file for writing 报错解决
hotkeydescription
C-slock screen
C-qexit lock
uundo
C-rredo

Git

command

commanddescription
git initcreate initial git file
git add fileadd file to git
git add .add all file to git
git rm filenameremove file
git statuscheck status
git logcheck log
git commit -m “…”commit description
git remote add origin [github address]add github address
git push -u origin masterpush master branch to github
git pull origin masterfresh(fetch and merge) github to local
git push origin master -fforce push master branch
git config –global credential.helper cachecache git password for 15 minutes
git config credential.helper ‘cache –timeout=3600’cache git password for 1 hour
git config –global credential.helper storestore git password forever
git remote rm originremove origin
git branchcheck branch, head pointer “*”
git checkout -b devswitch to a new branch “dev”
git branch devcreate a new branch “dev”
git checkout devswitch to branch “dev”
git merge devmerge target branch to head branch
git merge –no-ff -m “…” devmerge without no-fast-forward
git branch -d devdelete branch “dev”
git stashstore head branch
git stash listlist stash log
git stash popstash apply and drop
git fetch origin masterfetch file from giihub
git log -p master..origin/mastercompare master and origin
git merge origin/mastermerge master and origin
git diff <name>compare <name> and head
git fetch –allfetch all file from giihub
git reset –hard <name> [origin/master]head branch to target vision
git merge origin/master –allow-unrelated-historiesforce merge
git pull –rebase origin masterrebase to branch
git remote show originshow remote origin
git config --global user.name "username"
git config --global user.email "email address"
ssh-keygen -C 'email address' -t rsa # generate ssh key
gedit ~/.ssh/id_rsa.pub
ssh -T git@github.com

git reflog # view recent operation log 
git reset --hard [vision id] # head branch to target vision, delete staging area and working copy
git reset --soft [vision id] # head branch to target vision, keep staging area and working copy
git revert # create commit and hard branch to target vision
git log # view recent operation log about current branch
git clone [repository address] [/path/directory] # clone github repository to target directory
git commit -m ' <RET> ' # commit with quote
git commit --amend # modify commit description
git commit <RET> # into nano edit commit
# edit your commit messages logging
C-x # modified log buffer
Y # Yes to Save
git config --global core.editor vim # 修复默认commit log 文本编辑器为vim

linux command 1

gsettings set org.gnome.gedit.preferences.encodings candidate-encodings "['gb18030', 'utf-8', 'current', 'iso-8859-15', 'utf-16']"  #txt file chinese messy code

ppa:personal package archives

sudo add-apt-repository ppa:user/ppa-name # add ppa source
sudo apt-get update # refresh source
sudo add-apt-repository -r ppa:user/ppa-name # remove ppa source
sudo apt-get update # refresh source
sudo apt-get update -f install # force install
sudo apt -f install # fix dependencies
cat <filename> # show text 
cat -n <filename> # show text with line number
cat -b <filename> # show text with line number,blank line without number
cat -t <filename> # show text without tabs
echo "..." >> filename # add ... to file
more <filename>   # show text, <return> key:next page
less <filename>   # show textxs
cp <filename1> <filename2> # copy file1 to file2
cp -v <filename1> <filename2> # copy file and print
$logname # account username
tail -n 5 <filename> # print last 5 lines of file
ls -altr # list of all directories according time and invert
grep [option] pattern file # regular expression
ls -lh <filename> # check file permissions
ls -ld <folder> # check folder permissions
sudo chmod 600 xxx # u read and write
sudo chmod 644 xxx # u read and write. group write
sudo chmod 700 xxx # u read write and execute
sudo chmod 666 xxx # group read and write
sudo chmod 777 xxx # group read write and execute
# 000--no permission 100--only read 110--read and write 111--execute 
sudo chmod u+w xxx # u write
sudo chmod u-w xxx # cancel u write permission
sudo chmod g+r xxx # group read
sudo chmod o-r xxx # cancel others write
sudo chmod +x xxx # all execute
# u--your g--group o--others a--all
# +--add ---cancel =--set only
# r--read w--write x--execute
sudo useradd username # add user
passwd ****** # set user password
vim /etc/sudoers
username all=(all:all) all # add root permission
userdel -r username # delete user
w # view current user
who # view current user
whoami # view user
lastog # view all user
lastlog|last -n 15 # view last 15 user logs

ufw: uncomplicated firewall

sudo ufw status # check firewall status
status: inactive # unwork
sudo ufw version # check firwell version
sudo ufw enable # enable firwell
sudo ufw default deny # enable firewal and deny all input port
sudo ufw disable # disable firwell
sudo ufw allow|deny [service]/[port] # enable/disable service
sudo ufw allow smtp # enable port 25/tcp, smtp service
sudo ufw allow 22/tcp # enable port 22/tcp, ssh service
sudo ufw allow 53 # enable port 53, tcp/udp
sudo ufw allow from 192.168.1.100 # allow ip 192.168.1.100 connect
sudo ufw delete allow from 192.168.254.254 
# delete rule about 192.168.254.254
sudo ufw deny smtp # disable smtp service
sudo ufw delete allow smtp # delete firwell rule about smtp service
sudo ufw delete allow|deny 20 # delete firwell rule about 20 port 
sudo ufw allow proto udp 192.168.0.1 prot 53 to 192.168.0.2 port 25
# allow remote 192.168.0.1 port 53 udp packet access local 192.168.0.2 port 25 
sudo ufw logging on|off # turn on/off firwell log
sudo ufw default allow #  enable firewall mostly open all input port
sudo ufw status numbered # cleck firewall rule
vim /etc/ufw/ufw.conf # firewall confiration file

ubuntu iptables {iptables destription}

   iptables -p input drop # drop all input packet
   iptables -p forward drop # drop all forward packet (mostly nat)
   iptables -p output drop # drop all output packet
   iptables -l -n # check all input, forward and output, -line-number
   sevrice iptables save # save iptables setting
   iptables-save # save iptables setting
   iptables-restore # restore iptables setting
   iptables -a input -p tcp --dport 22 j accept

 iptables -I INPUT -ptcp --dport 9501 -j ACCEPT
sudo iptables -L
   # append rule accept download tcp packet from port 22
   iptables -a output -p tcp --sport 22 i accept
   # append rule accept sent tcp packet from port 22 
   iptables -a input -p tcp -s 192.168.1.2 -j drop
   # append rule drop tcp packet from 192.168.1.2 
   iptables -a input -p udp --dport 60002 -j accept
   # append rule accept udp packet to port 60002
   iptables -d input 2 # delete input line number 2
   sudo iptables-save > /etc/iptables.up.rules 
   # save firewall rule to iptables.up.rules
   vim /etc/network/interfaces
      auto eth0
      iface eht0 inet dhcp
      pre-up iptables-restore < /etc/iptables.up.rules # load rule from iptables.up.rules
      post-down iptables-save > /etc/iptables.up.rules # save rule before restore system
   sudo nautilus # super user for files exploer
dmidecode -t bios #getting smbios data from sysfs
sudo dmidecode -t memory|head -45 |tail -23 # 查看内存条和内存槽
dmesg|grep -i ethernet # 查看网卡信息
lspci |head -10 # 查看主板pci硬件槽信息
cat /proc/cpuinfo|grep name |cut -f2 -d: | uniq -c #查看cpu信息
cat /proc/cpuinfo|grep "cores"| uniq  # 查看cpu核数
cat /proc/cpuinfo|head -20 # 查看cpu详情
lscpu # list of all cpu infomation
cat /proc/cpuinfo|grep mhz| uniq  #查看cpu主频
getconf long_bit # 查看cpu运行模式
cat /proc/cpuinfo|grep flags| grep 'lm' |wc -l # 查看cpu是否支持64bit, >0表示支持64bit计算, lm表示long mode(64bit)
cat /proc/meminfo|head -20 #查看内存条详细
free -m # 查看内存使用情况
sudo fdisk -l|grep disk # 查看挂接分区状态
lsblk # 硬盘分区分布
mount | column -t #查看挂接分区
swapon -s # 查看挂接分区状态
df -ht # 硬盘使用情况
ip link show # 所有网络接口
grep: global search regular expression amd print out the line
grep [option] pattern [file...] # [option] 表示命令选项 pattern 表示要匹配的模式(字符串,变量)
grep -rl "bfunc_setisoresenable" ./ # 查找包含bfunc_..字符串的二进制文本文件, ./表示本文件夹
grep -rl "bfunc_setisoresenable" -l # 查找包含bfunc_..字符串的二进制文本文件, -l表示包含子文件
grep -i "hello world" test1.txt test2.txt # 多文件查询, -i 忽略大小写
grep -e 只打印匹配的文本行数量, 不显示匹配内容
grep -a "gpio_portn_ba" piodrv.c 二进制文件等价于文本文件进行内容匹配
grep -h 当搜索多个文件时, 不显示匹配文件名前缀
grep -n 列出所有匹配的文本行, 并显示行号
grep -l 只列出含有匹配的文本行的文件的文件名,而不显示具体的匹配内容
grep -s 若无法检索到, 无需显示不存在和无法读取文件的错误信息, -no-warning
grep -v 只显示不匹配的文本行
grep -w 匹配整个单词
grep -x 匹配整个文本行
grep -r 递归搜索当前目录和子目录
grep -q 禁止输出任何匹配结果,而是以退出码的形式表示搜索是否成功
grep -b 打印匹配的文本行到文件头的偏移量,以字节为单位
grep -e 支持扩展正则表达式
grep -p 支持perl正则表达式
grep -f 不支持正则表达式,将模式按照字面意思匹配
grep -e "hello" -e "mail" -r /home/madhouse 在文件夹下搜索hello或mail
grep -e "hello|mail" -r /home/madhouse  在文件夹下搜索hello或mail
egrep "hello|mail" -r /home/madhouse  在文件夹下搜索hello或mail
grep -i "hello" -rl /home/madhouse |xargs grep -i "mail" 在文件夹下同时搜索hello和mail
ps -ef | grep "emacs" 查看当前包含emacs字符的进程
rfkill list all 查询设备驱动是否被堵塞 当hard blocked: true 表示被堵塞
vim /etc/modprobe.d/blacklist.conf 增加 blacklist 黑名单
#----------------------/home/tyrone/myshell.ksh---------------------
#! /bin/ksh, 一个脚本软件备份和全局替换字符hello world
grep "hello world" -rl /home/madhouse | xargs grep -l "mailx" > /home/madhouse/result.txt
cat result.txt | while read line
do
    cp ${line} ${line}.bak20200711
    sed -i "s/hello world/letitia/g" `grep "hello world" -rl ${line}`
done
unzip -o gbk xxx.zip # 解压时指定字符集,可以是cp936,gbk,gb18030
command 1 ; command 2 # 首先运行command1,然后运行command2
command 1 && command 2 # 当command1运行成功并结束,然后运行command2
command 1 || command 2 # 当command1运行失败时才运行command2

make a hexdump or reverse

xxd fliename # 
od -An -vtx1 -w100 cutecom.log | cut -c2- | fgrep -v 0a
Usage: tar -[cxtzjahmvO] [-X FILE] [-T FILE] [-f TARFILE] [-C DIR] [FILE]...
Create, extract, or list files from a tar file
Operation:
        c       Create
        x       Extract
        t       List
        f       Name of TARFILE ('-' for stdin/out)
        C       Change to DIR before operation
        v       Verbose
        z       (De)compress using gzip
        j       (De)compress using bzip2
        a       (De)compress using lzma
        O       Extract to stdout
        h       Follow symlinks
        m       Don't restore mtime
        exclude File to exclude
        X       File with names to exclude
        T       File with names to include

tar -cvf filename.tar.gz directory_name # compress and create tar.gz file
tar -cjvf filename.tar.bz2 directory_name # compress and create tar.bz2 file
tar -zxvf xxx.tar.gz # extract tar.gz
tar -jxvf xxx.tar.bz2 # extract tar.bz2

hotkey

keybindingdescription
c-dexit bash
pstrcsave a screenshot to pictures
s-pstrcsave a screenshot of an area to pictures
m-pstrcsave a screenshot of a window to pictures
c-pstrccopy a screenshot to clipboard
s-c-pstrccopy a screenshot of an area to clipboard

applications

baidupcs-go iikira

## add go path; install baidupcs-go
wget https://dl.google.com/go/go1.10.2.linux-amd64.tar.gz # download packages from github
sudo tar -c /usr/local -zxvf go1.10.2.linux-amd64.tar.gz # unzip packages
vim ~/.bashrc
export gopath=$home/go # address gp path
# export path=$path:/usr/local/go/bin:$gopath/bin
source ~/.bashrc # execute config file
sudo apt install golang # install golanguage
go get -u -v github.com/iikira/baidupcs-go # go direct install badiupcs-go from github
sudo ln -s ~/go/bin/baidupcs-go baidupcs #  create link(baidupcs) for baidupcs
baidupcs # run baidupcs-go
login # login
logout # logout
loglist # account list
who # current account
su <uid> # switch account
quota # show storage capacity
cd <dir> # enter <dir>
cd <dir> -l # enter <dir> and list subdirectory
cd .. # enter parent directory
cd / # enter root directory
pwd  # show current directory
ls -asc # show fiie ascending order
ls -desc # show file descending order
ls -time # show file according time
ls -name # show file according name
ls -size # show file according size
config set -savedir ~/downloads # set download location
search <name> # search file about <name>
d <filename1> <filename2> # download
  --test          test download link
  --ow            overwrite
  --status        check status
  --save          save
  --saveto value  save to 
  -x              add execute permission
  --share         share links
  --locate        links download
  -p value        threads
upload <local-dir> <remote-dir> #upload
share l # share
offlinedl add <link1> <link2> # offline downloadxs
config set -appid=266719 # 变更appid为266719
config set -appid=309847 # 变更appid为309847

goldendict

reference c-f11-c-f11 mainwindow c-c c-g scan popup

iproute2

iproute2 from jianshu

ip a # show ip 
ip link show # show ip
ip -4 a # show ipv4 informations
ip a show wlp3s0 # check specific network device
ip -details link show wlp3s0 # check specific network device
ip link ls up # show all working network device
ip route show # show route
ip -s link # show all links
ip a add 192.168.1.101/255.255.255.0 dev eth0 # set eth0 ip 192.168.1.101/255.255.255.0
ip a add 192.168.1.101/24 dev eth0 # set eth0 ip as 192.168.1.101/255.255.255.0
ip a del 192.168.1.101/24 dev eth0 # delete eth0 ip
ip -s -s a f to 192.168.1.0/24 # delete all ip
ip link set dev eth0 down # disable eth0
ip link set dev eth0 up # enable eth0

openssh-server ssh and mosh tutorial 1 2

ps -e|grep ssh # ssh-agent and sshd
sudo /etc/init.d/ssh start # start ssh server
pidof sshd
ssh username@hostname # root client login
ssh -p 2222 username@hostname # port 2222 login
ssh [-l login_name] [-p port] [user@hostname] # general format
ssh -l login_name hostname # user login
ssh login_name@hostname # user login
ssh login_name@hostname -v # ssh with debug1
ssh login_name@hostname -vv # ssh with debug1, debug2
ssh login_name@hostname -vvv # ssh with debug1, debug2, debug3
scp /path/filename username@servername:/path/
# upload file
scp username@servername:/path/filename /var/www/local_dir
#download file
scp -r username@servername:/var/www/remote_dir(remote) /var/www/local_dir(local)
# download directory
scp -r local_dir username@servername:remote_dir
# upload directory
scp -P port fileName user@ip:/dirName # 指定端口

talk is cheap, show me the code

vim /etc/ssh/sshd_config
#port 22
port 12333
#permitrootlogin yes
permitrootlogin no
service sshd restart
~/.ssh/known_hosts # rsa public
/etc/ssh/ssh_known_hosts # server rsa public
ssh-keygen
cd ~/.ssh/
ssh-copy-id username@servername
vim /etc/ssh/sshd_config
->rsaauthentication yes
->pubkeyauthentication yes
->authorizedkeysfile .ssh/authorized_keys
ssh user@host 'mkdir -p .ssh && cat >> .ssh/authorized_keys' < ~/.ssh/id_rsa.pub

can’t used root account login ssh server -permission denied, please try again

mosh

mosh connect on a udp port between 60000 and 61000

sudo iptables -a input -p udp --dport 60002 -j accept # server
mosh -p 60002 username@servername # login
sudo apt install mosh
mosh login_name@hostname # login

gdb 1

gcc -o test test.c -g
g++ hello.c -o hello

make 1

qt 1

apt install libgl1-mesa-dev
linuxdeployqt ./usb_can -appimage -unsupported-bundle-everything

vim

wq # write and quit
wq! # force write and quit
w <filename> # save with name
i # insert on current cursor
a # insert on next line
o # insert on a new line
set nu # show line number
<number> # turn to line #
/name # search ->n next
?name # search ->n next
q! # quit without save
set fenc=utf8 nobomb ff=unix # set file format
commanddescription
c-bpageup
c-fpageon
c-dturn up half a page
c-uturn on half a page
0begin of text
gend of text
$end of line
^begin of line
wnext begin of word
enext end of word
bbackward word
#lturn to char #
xdelete
#xdelete # chars
xbackspace
#xbackspace # chars
dddelete current line
#dddelete # line
ywcopy to buffer
#ywcopy # words to buffer
yycopy line to buffer
#yycopy # lines to buffer
ppaste
rreplace
rreplace continuously
uundone
cwdelete word
c#wdelete # words
#gturn to line #
c-gcurrent line number
#search word like current cursor

rime 1 2 3

sudo apt install ibus-rime
sudo apt install librime-data-pinyin-simp
sudo apt-get install librime-data-double-pinyin
cd ~/.config/ibus/rime
vim default.custom.yaml
"menu/page_size": 7
gsettings set org.freedesktop.ibus.panel lookup-table-orientation 0 # horizontal 

rime add customized thesaurus 1 2 ubuntu 20 ibus-rime input tool

arm 1

minicom 1

sudo apt install minicom
sudo minicom -s # setup
sudo minicom # running

sapgui 1 java 750 3

sap dui 7.40 java wi-labor sap gui java configration

cd /opt/sapclients/sapgui/bin/
./guistart conn=/h/ip-address/s/3200 # login
cd /opt/sapclients/sapgui7.40rev10/bin 
./guilogon # logon

conn=/h/192.168.3.51/s3200

edrawmax 1

tar -zxvf edrawmax-9-amd64.tar.gz
chmod +x edrawmax
sudo ./edrawmax
cd /usr/local/bin
sudo ln -s ~/downloads/edrawmax-9-amd64/edrawmax edrawmax

emacs 1

keybindingsdescription
c-c c-x c-vshow figure
c-x c-cexit
c-x c-wsave as
c-x c-vexit buffer and open new buffer
c-x iinsert file
c-x bswitch buffer
c-x c-bbuffer list
c-c c-zstop shell process
c-x 2left and right windows
c-x 3up and down windows
c-x 0exit current window
c-x oswitch windows
c-x 1exit others windows
c-x 5 2new window
c-x 5 fnew window and open file
c-abegin of current line
c-eend of current line
c-vpageup
m-vpageon
m-<begin of text
m->end of text
m-ccapitalize-word
m-uupcase-word
m-ldowncase-word
m– m-ccapitalize-forward-word
m– m-uupcase-forward-word
m– m-ldowncase-forward-word
c-x c-udowncase-region
c-x c-lupcase-region
M-iindentate
M-%Query-Replace
C-x hmark whole buffer(select all)
M-\Delete all space in cursor place

#+ATTR.*: :width 100

(setq org-image-actual-width nil)
(setq org-image-actual-width '(400))

M-x replace-string M-x revert-buffer-with-coding-system select GB18030 转化文件编码方式 C-x <RET> r revert-buffer-with-coding-system select GB18030 转化文件编码方式

M-x list-matching-lines

M-x grep Enter grep -nH -e “ngx_http_ssl” *.c

M-x rgrep Enter abcde file type directory

M-x find-name-dired

M-x string-insert-rectangle <RET> string <RET> M-x delete-whitespace-rectangle C-x r t string <RET> replace rectangle contents with string on each lines C-x <SPC> Rectangle Mark mode M-x flush-lines <RET> ^$ <RET> remove lines that match a blank line

org mode
C-c .select date to add timestamp
C-C C-sadd schedule date
C-c C-dadd Deadline date
C-M \indent-according-to-mode
C-jorg-return-indent(newline and indent)
M-jdefault-indent-new-line(using in comment)
C-u C-c C-clists convert checkbox
sudo gem install taskjuggler
(add-to-list 'load-path "~/.emacs.d/elpa/ox-taskjuggler")
(require 'ox-taskjuggler)

M-x org-taskjuggler-export-process-and-open 同目录下的report/

samba

share files between windows and ubuntu simple tutorial

sudo apt install samba samba-common
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak # backup current config file
vim /etc/samba/smb.conf # configuration file
    security = user # account login

    security = user 
    map to guest = bad user # guest login
[share]
   comment = my share directory
   path = /home/madhouse/share # add share files
   available =yes
   browseable = yes # directory browseable premission
   writable = yes
   guest ok = yes
   public = yes
sudo useradd smbuser
sudo smbpasswd -a smbuser
sudo service smbd restart # restart samba service
sudo /etc/init.d/smbd restart # restart samba service
service smbd status # check status
service iptables stop # turn off SElinux
vim /etc/selinux/config
   SELINUX=enforcing-->set SELINUX=disabled # turn off forever
setenforce 0 # turn off 

windows browser login: file://10.0.12.172/share smbclient login: smbclient //10.0.12.172/share/ smbclient -L //10.0.12.172 connect to server: smb://10.0.12.172/share/ windows explorer: \10.0.12.172 win-r: \10.0.12.172

MPD[Music Player Daemon]

ubuntu install and configure MPD

sudo apt install mpd 
sudo systemctl start mpd

pandoc

install and configure pandoc

Matlab

install matlab2016b on ubuntu18 ubuntu16.04 install matlab2016b

cd ~
sudo mkdir matlab
sudo mount -t auto -o loop Linux/R2016b_glnxa64_dvd1.iso matlab/
# sudo mount -o loop Linux/R2016b_glnxa64_dvd1.iso matlab/
sudo matlab/install 
sudo mount -t auto -o loop Linux/R2016b_glnxa64_dvd2.iso matlab/ 
sudo umount matlab/
sudo cp Matlab_R2016b_Linux64_Crack/R2016b/bin/glnxa64/* /usr/local/MATLAB/R2016b/bin/glnxa64
sudo /usr/local/MATLAB/R2016b/bin/matlab
sudo vim /usr/share/applications/Matlab2016b.desktop
[Desktop Entry]
Categories=Development;Matlab;
Comment[zh_CN]=Matlab: The Language of Technical Computing
Comment=Matlab: The Language of Technical Computing
Exec=sh /usr/local/MATLAB/R2016b/bin/matlab -desktop
GenericName[zh_CN]=Matlab2016b
GenericName=Matlab2016b
Icon=/usr/local/MATLAB/R2016b/toolbox/sl3d/mainpage/matlab_logo.gif
Mimetype=
Name[zh_CN]=MATLAB
Name=MATLAB
Path=
StartupNotify=true
Terminal=false
Type=Application
sudo chmod 777 ~/.matlab -R 
sudo vim ~/.zshrc
export PATH=/usr/local/MATLAB/R2016b/bin:$PATH
source ~/.zshrc

R

sudo apt install r-base
R

redshift

sudo apt install redshift

7zip

sudo apt install p7zip
p7zip -d filename

w3m

emacs w3m w3m

wine

wine: cannot find L"C:\\windows\\system32\\udpInterfaceTest_V1.0.2.9.exe"
# solution
wine control.exe 
add/remove programs # select program install

vscode+latexworkshop {1}

latex-workshop.latex.recipes Edit in settings.json

CommandDescription
C-S-xExtensions
C-,Setting
C-k C-sKeyboard Shortcuts
C-M-xTotal Commands
C-M-cclean up auxiliary flies
C-M-vpreview pdf
C-M-jforward search

Doxygen

sudo apt install doxygen # 安装Doxygen
sudo apt install doxygen-gui # 安装GUI桌面软件
doxywizard # 打开GUI桌面软件
# 自动导出文档
doxygen /home/madhouse/Yaoli/6.6KW/v2g_source/v2g\ 0804/v2g/code/Application/Doxyfile

M-x org-table-create-or-convert-from-region

wireshark

wireshark支持过滤协议:tcp, udp, arp, icmp, http, smtp, ftp, dns, msnms, ip, ssl, oicq, bootp等

ip.src==192.168.0.2 and ip.dst==192.168.0.233 and tcp.port==965

ip.src==192.168.0.2 and ip.dst==192.168.0.233 and tcp.len==12

ip.addr == 192.168.1.1

显示所有源或目标MAC物理地址是9c:5a:44:06:ad:3f的报文 eth.addr == 9c:5a:44:06:ad:3f 显示MAC前三字节是00:06:5B的报文 eth.addr[0:3]==00:06:5B 显示所有源MAC物理地址是9c:5a:44:06:ad:3f的报文 eth.src == 9c:5a:44:06:ad:3f 显示所有目标MAC物理地址是9c:5a:44:06:ad:3f的报文 eth.dst == 9c:5a:44:06:ad:3f 示显目的地址是192.168.1.2 或192.168.1.3 端口是80 的TCP 数据 tcp.port == 80 && (ip.dst==192.168.1.2 || ip.dst==192.168.1.3)

显示192.168整个网段 ip.src == 192.168.0.0/16 过滤192.168整个网段 ip.src != 192.168.0.0/16 http 显示http 或者 tcp http or telnet 显示http和telnet, 或者 tcp || udp not tcp 不显示, 或者 !tcp src portrange 2000-2500 显示来源为UDP或TCP,并且端口号在2000至2500范围内的封包 udp.length < 30 || udp.length >= 20 数据段长度过滤 显示udp本身固定长度8加上udp下面那块数据包之和等于26 udp.length == 26 tcp.len >= 7 指的是ip数据包(tcp下面那块数据),不包括tcp本身 除了以太网头固定长度14,其它都算是ip.len,即从ip本身到最后 ip.len == 94 整个数据帧长度,从eth开始到最后 frame.len == 119 tcp contains “httppp” 显示payload中包含”httppp”字符串的tcp封包。 http.request.uri contains “online” 显示请求的uri包含”online”的http封包 16进制形式,tcp头部一般是20字节,所以这个是对payload的前三个字节进行过滤 tcp[20:3] == 47:45:54 16进制形式,udp头部一般是8字节,所以这个是对payload的前四个字节进行过滤 udp[8:4] == 02:00:0a:03 upper(http.request.uri) contains “ONLINE” 对比是否含有ONLINE lower(http.request.uri) contains “online” 对比是否含有online

ip.src==192.168.1.107 and udp[8:5] matches “\x02\x12\x21\x00\x22” ip.src==192.168.1.107 and udp contains 02:12:21:00:22 ip.src==192.168.1.107 and tcp contains “GET” udp contains 7c:7c:7d:7d 匹配payload中含有0x7c7c7d7d的UDP数据包,不一定是从第一字节匹配。

host 192.168.1.1 抓取地址192.168.1.1收到和发出的所有数据包 src host 192.168.1.1 抓取源地址192.168.1.1发出的所有数据包 dst host 192.168.1.1 抓取目标地址192.168.1.1收到的所有数据包 src host hostname 根据主机名过滤 ether host 9c:5a:44:06:ad:3f 根据MAC地址进行过滤 net 192.168.1 抓取192.168.1整个网段 src net 192.168 抓取源地址192.168网段发出的数据包 dst net 192 抓取目标地址192网段收到的所有数据包 (tcp port 80) and ((dst host 192.168.1.2) or (dst host 192.168.1.3)) 抓取目的地址是192.168.1.2 或192.168.1.3 端口是80 的TCP 数据 (tcp) and ((dst net 192.168) and (not dst host 192.168.1.2)) 抓取所有目的网络是192.168,但目的主机不是192.168.1.2 的TCP 数据 显示目的网络是192.168,但目的主机不是192.168.1.2 的TCP 数据 tcp && ip.src==192.168.0.0/16 && !(ip.src==192.168.1.2) 抓取主机192.168.1.1除了和主机192.168.1.2之外所有主机通信的数据包 host 192.168.1.1 and ! 192.168.1.2 显示主机192.168.1.1除了和主机192.168.1.2之外所有主机通信的数据包 ip.addr==192.168.1.1&&!ip.addr==192.168.1.2 抓取主机192.168.1.1接收或发出的telnet包,telnet使用tcp 23端口 tcp port 23 and host 192.168.1.1 显示主机192.168.1.1接收或发出的telnet包,telnet使用tcp 23端口 tcp.port==23&&ip.addr==192.168.1.1 keyword below:

“eq””==”
“and”“&&”
“or”“|\vert”
”!”“not”
”!=”“ne”
“<”“lt”
“<=”“le”
“>”“gt”
“>=”“ge”

Linux Customize

turn CapsLock to Left Ctrl 1

sudo vim /usr/share/X11/xkb/keycodes/evdev
CAPS=37;
LCTL=66;
chmod  change attributes from a file/folder
permission to:  owner      group      other     
                /¯¯¯\      /¯¯¯\      /¯¯¯\
octal:            6          6          6
binary:         1 1 0      1 1 0      1 1 0
what to permit: r w x      r w x      r w x
 
binary         - 1: enabled, 0: disabled
 
what to permit - r: read, w: write, x: execute
 
permission to  - owner: the user that create the file/folder
                 group: the users from group that owner is member
                 other: all other users

ubuntu HDMI monitor 1 2

xrandr # check connecting device
xrandr --output HDMI-0 --same-as eDP-1 --auto # clone
xrandr --output VGA-0 --same-as LVDS --mode 1280x1024 # set display resolution
xrandr --output VGA-0 --right-of LVDS --auto # right display
xrandr --output VGA-0 --off # turn off monitor
xrandr --output VGA-0 --auto --output LVDS --off # turn on VGA, turn off LVDS
xrandr --output DP-1 --left-of eDP-1 --auto # 左边扩展

Internal network penetration

VPS + ssh reverse proxy + autossh 1 2 3 4

ssh -fCNR # Reverse proxy ssh
# f-> background execute, C-> allow compress date, N-> don't execute remote control, R-> reverse
ssh -fCNL # proxy ssh
ps aux| grep ssh # check all ssh connect
vim /etc/rc.d/rc.loacl

Ngrok + ssh connect server 1 2 3

ssh -p port username@free.idcfengye.com # tcp login
killall sunny 
sleep 1
./sunny clientid id # restart sunny, free memory

clean

sudo du -sh /var/cache/apt # check packages size
sudo apt autoclean # clean old packages
sudo apt clean # clean all packages
sudo du -sh ~/.cache/thumbnails # check cache pictures
rm -rf ~/.cache/thumbnails/* # remove cache pictures

desktop shortcut

[Desktop Entry]
Encoding=UTF-8
Version=1.0                                     #version of an app.
Name[en_US]=yEd                                 #name of an app.
GenericName=GUI Port Scanner                    #longer name of an app.
Exec=java -jar /opt/yed-3.11.1/yed.jar          #command used to launch an app.
Terminal=false                                  #whether an app requires to be run in a terminal
Icon[en_US]=/opt/yed-3.11.1/icons/yicon32.png   #location of icon file.
Type=Application                                #type
Categories=Application;Network;Security;        #categories in which this app should be listed.
Comment[en_US]=yEd Graph Editor                 #comment which appears as a tooltip.

hotspot

ubuntu 18 share hotspot

Github+Hexo

echo "export PATH=$PATH:/home/madhouse/Downloads/node-v10.15.3-linux-x64/nin" >> ~/.zshrc
echo PATH
hexo g # generate public files
hexo clean # clean public files
hexo d # deploy public files
hexo clean && hexo d # refresh public files and deploy

personal free blog build hexo blog detail tuorial SEO(Search Engine Optimization) Google Search Console Free Domain hexo SEO optimization for google hexo Next themes website verification Hexo install and configure Next themes

permalink: :year/:month/:day/:title/
permalink: :title.html

rime language input

Rime squirrel configuration log Rime input add thesaurus and configuration file Note for linux install rime input github rime wiki customization guide

sudo apt install ibus-rime
sudo apt install librime-data-pinyin-simp
sudo apt-get install librime-data-double-pinyin
cd ~/.config/ibus/rime
vim default.custom.yaml
"menu/page_size": 7
gsettings set org.freedesktop.ibus.panel lookup-table-orientation 0 # Candidates are displayed horizontally
sync rime dictionary
vim ~/.config/ibus/rime/symbols.yaml
installation_id: "9c755581-73c8-4fdb-b18a-a819005dc543"
killall ibus-daemon 
/usr/bin/rime_dict_manager -s

automatic mount hard disk

Ubuntu automatic mount hard disk

sudo fdisk -l # list all disk found
mkfs -t ext4 dev/sdb6 # format sdb6 to ext4
ls -l /dev/disk/by-uuid # view disk id
df -l # list all disk mounted 
df -h # list capacity of disk
sudo gedit /etc/fstab # edit fstab
sudo mount -a # mount disk according to configration file

pomodoro

sleep 300 && notify-send "Back to work"
sleep 1500 && zenity --warning --text="Your pomodoro session just needed, Have a well deserved 5 minutes break"; 
sleep 300 && zenity --warning --text="Back to work"

subversion(SVN)

git svn init svn://username@host/filepath # 创建本地git本地仓库
svn ls https://xxx # 版本库下的文件和目录列表
svn checkout url --usrname=*** --password=*** path # url: 服务器地址 path: 本地电脑目录
svn checkout url # 再次登录同步, 已经验证过用户名和密码

Latex

language

ShareLatex Overleaf

\documentclass[12pt][article]
% 12pt font size, article english, cn-article, ctexart chinese
\usepackage[utf8]{inputenc}
\author{madhouse}
\title{My first latex document}
\date{April 2019}
\begin{document}
   \maketile % print title
   ...
   % new line
   \\ ... % new line
   \par ... % new line
   \iffalse commit \fi
\begin{center}
   \includegraphics[scale=0.1]{1.jpg}
   \includegraphics[width=3cm]{2.png}
   \includegraphics[height=8cm]{3.jpeg}
\end{center}
\begin{figure}[ht] % figure environment, h->plug here, t->top of page
% b->bottom, p-> page, independent page
\centering % pictures on the center
\includegraphics{4.png}
\caption{this is a figure demo}
\label{fig:label}
\end{figure}
\begin{figure*}
...
\end{figure*} % 跨双栏插入图片
\end{document}

Org mode export TEX and PDF

Latex 4 5 6 7 8 9 10 11 12 13 14 15 16 17

sudo apt install texlive-full
sudo apt install auctex
(add-hook 'LaTeX-mode-hook (lambda()
(add-to-list 'TeX-command-list '("XeLaTeX" "%`xelatex%(mode)%' %t" TeX-run-TeX nil t))
(setq TeX-command-default "XeLaTeX")
(setq TeX-save-query  nil )
(setq TeX-show-compilation t)
))
(setq org-latex-compiler "xelatex")
\usepackage[unicode=true,colorlinks=no,pdfborder=no]{hyperref}
\tiny                           % tiny fontsize
\scriptsize                     % scriptsize
\footnotesize                   % footnotesize
\small                          % small fontsize
\normalsize                     % normalsize
\large                          % large fontsize
\Large                          % super large fontsize
\LARGE                          % super super large fontsize
\huge                           % huge fontsize
\Huge                           % super fontsize

23

VPS

AWS EC2

sudo shmod 400 identity.pem 
ssh -i identity.pem ubuntu@vps_ip # ssh connect
sudo passwd root # set root password
su  # root
vim /etc/ssh/ssh_config
PasswordAuthentication no -> yes
sudo service sshd restart
su 
passwd ubuntu # reset password

Openocd+tcl {1}

cd ~/cpp/openocd-0.10.0 
openocd -f 3sut1.cfg # connect to board
telnet localhost 4444 # telnet connection on tcp/4444
halt # stop cpu
flash write_image erase /home/madhouse/Downloads/2020.05.12.mot # erase flash and write image, support .bin .hex .mot .elf mem builder file
flash write_image erase /home/madhouse/v2g.hex # erase flash and write image
reset # reset cpu
### 
openocd -f ~/cpp/openocd-0.10.0/tcl/interface/jlink.cfg -f tm4c129.cfg ##connect
halt # stop cpu
mdw 0 12 #从0地址读12个数(32位)
mww 0 0x00000201 #向某地址写数32位
reg #查看寄存器
flash banks # list bank number
flash erase_check 0 # check flash #0 bank erase state
shoudown # disconnect

QCAD

F F change all font M G change all text height

arm-linux-gnueabihf-gcc & sshd (cross compile)

指定arm-linux-guneabihf-gcc版本(需与目标板系统一致), 或者使用crosstool自制交叉编译工具链kernel+gcc+glibc+binutils

Starting sshd: /var/empty/sshd must be owned by root and not group or world-writable

chown root.root /var/empty

Permissions 0777 for ‘/etc/ssh/ssh_host_rsa_key’ are too open

chmod 600 sshd_config ssh_host_dsa_key ssh_host_key ssh_host_rsa_key
chmod 620 moduli
chmod 644 ssh_config ssh_host_dsa_key.pub ssh_host_key.pub ssh_host_rsa_key.pub

Disabling protocol version 1. Could not load host key [[http://blog.chinaunix.net/uid-20541719-id-3044883.html][[1]​]]

vim /usr/local/etc/sshd_config
HostKey for protocol version 1
HostKey /usr/local/etc/ssh_host_key
# HostKeys for protocol version 2
HostKey /usr/local/etc/ssh_host_rsa_key
HostKey /usr/local/etc/ssh_host_dsa_key

Permission denied (publickey,password,keyboard-interactive) sshd migration problems/u

vim /usr/local/etc/sshd_config
PermitRootLogin yes

vi /usr/local/sanway/rc.user /usr/local/sbin/sshd &

Intranet Penetration (Holer & 网云穿)

nohup ./holer-linux-armv5 -k HOLER_CLIENT-822404317F9D8ADD &
nohup /home/sanway/wyc_linux_arm -token=qbahhlab &
0 1 * * * /home/sanwy/msgpack.sh #每天凌晨一点执行msgpack.sh该文件

restart network command

sudo service network-manager restart # 重启网络服务
sudo systemctl restart NetworkManager.service # 重启网络服务
sudo nmcli networking off # 关闭网络
sudo nmcli networking on # 开启网络
sudo ifdown -a && sudo ifup -a # 重启所有网口
    cat /etc/crontab
    # Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name command to be executed
17 *	* * *	root    cd / && run-parts --report /etc/cron.hourly
25 6	* * *	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6	* * 7	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6	1 * *	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )

使用(-)可以划定范围  如:0 0-3 * * *  脚本表示每天0-3点整执行脚本 使用(,)可以枚举时间  如: 0,15,30,45 * * * * 脚本表示每个小时的0分,15分,45分,30分会执行脚本 使用(/)可以指定间隔  如:* */8 * * * 脚本表示每8小时执行脚本 组合用法 0-20/10 * * * * 脚本表示在前20分钟内每隔10分钟执行脚本 crontab -u //设定特定用户的定时服务 crontab -l //列出当前用户定时服务内容 crontab -r //删除当前用户的定时服务 crontab -e //编辑当前用户的定时服务

* * * * * user_name command to be executed
33 0 * * * /home/sanway/msgpack.sh

user_name 表示执行定时任务的用户 不指定默认当

crond 
sudo apt install x11vnc
./ipad_monitor.sh -l -p -h
vim /etc/X11/xorg.conf.d/20-intel.conf
    Section "Device"
    Identifier  "Intel Graphics"
    Driver      "intel"
    Option "VirtualHeads" "1"
    Option      "TripleBuffer" "true"
    Option      "TearFree"     "true"
    Option      "DRI"          "false"
    EndSection

install gImageReader

sudo add-apt-repository ppa:sandromani/gimagereader
sudo apt update
sudo apt install gimagereader tesseract-ocr tesseract-ocr-eng tesseract-ocr-chi-sim tesseract-ocr-chi-tra  -y
sudo apt install tesseract-ocr-chi-sim-vert tesseract-ocr-chi-tra-vert  -y

uninstall gImageReader

sudo apt remove gimagereader -y
sudo apt install ppa-purge -y
sudo ppa-purge ppa:sandromani/gimagereader