Linux 常用指令 (updating)


  • Remove all files exclude specific file

find . ! -name 'file.txt' -type f -exec rm -f {} +

find . ! -name '2020*' -exec rm -f {} +
  • Linux file sharing

sudo npm install -g http-server
http-server -o
  • Filter string and column

| awk '/pattern/{ print $0 }'
# $0 all, $1 column 1, $2 column 2, ...
  • Download GitHub release

wget --no-check-certificate --content-disposition

# --no-check-cerftificate was necessary for me to have wget not puke about https
curl -LJO

# Just download file
curl -OJ
  • Install mkpasswd

yum install expect
  • Install 

yum install httpd-tools
  • Generate self-signed SSL cert

$ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout mykey.key -out mycert.pem
  • Check if script not existed and run

ps aux | grep "app/" | grep -v grep
if [ $? != 0 ]; then
  python3 /srv/app/
  • Check if process existed

ps aux | grep "your_running_command" | grep -v grep
  • Append string to file

echo $'first line\nsecond line\nthirdline' >> foo
  • Get http status code

curl -I
curl -v    # -v == --verbose
  • Local mail box

  • While loop infinity

while true; do echo hi; sleep 5; done
  • Print log to file by datetime

ls -al > output_$(date +"%m_%d_%Y")
  • Check the collected

  • yum 列出所有 package 可裝版本

yum list {{package}} --showduplicates | sort -r
  • yum 搜尋 package by keyword

yum search {{keyword}}
  • Install nodeJS

#delete if needed

sudo apt-get –purge remove node

sudo apt-get –purge remove nodejs

sudo apt-get install nodejs

#Use 'node' command rather than 'nodejs'

update-alternatives –install /usr/bin/node node /usr/bin/nodejs 10

  • Install pip3

     sudo apt-get install python3-pip

  • Install htop

sudo yum install epel-release
sudo yum update

sudo yum install htop
  • Jupyter from .ipynb to .py

On the command line, you can use nbconvert:

$ jupyter nbconvert –to script [YOUR_NOTEBOOK].ipynb

As a bit of a hack, you can even call the above command in an IPython notebook by pre-pending ! (used for any command line argument). Inside a notebook:

!jupyter nbconvert –to script config_template.ipynb

  • 發 url request and show the time

curl -o /dev/null -s -w "%{time_connect} + %{time_starttransfer} = %{time_total}\n" <YOUR_URI>

  • "No package top available.

    Error: Nothing to do"

# htop seems to be available in the EPEL repo. Try yum install epel-release, then yum install htop again.

yum install epel-release

  • About compressing: Zip, Unzip

# zip with hidden file (.htaccess)
sudo find . -type f -name '.*' -print | sudo zip -@

# zip all in folder
sudo zip -r  {ZIPNAME}.zip {FOLDER_PATH1} {FOLDER_PATH2} {FOLDER_PATH3} ...

# unzip to specific folder
sudo unzip {ZIPNAME}.zip -d {FOLDER_PATH}

# browser into zip file
unzip -l {{zipfile}}
less {{zipfile}}
vim {{zipfile}}
  • Install ssh for ubuntu

sudo apt-get install openssh-server

# Enable/Disable root
vi /etc/ssh/sshd_config
PermitRootLogin Yes

# (optional) Set allowed IP
vi /etc/hosts.allow
vi /etc/hosts.deny
-> then restart

# (optional) restart
sudo /etc/init.d/ssh restart
  • Install Remote GUI for Ubuntu

# xfce4
sudo apt-get install xfce4
## additional goodies
sudo apt-get install xfce4-goodies
  • Make shortcut to command

alias lc=long-command

About System

  • Find regex string not include by awk

XXXstring | awk '$0 !~/domain/{print $0}'
  • Cron Job will lost PATH

# Set the path back again
export PATH={$PATH} 
  • Add user to root group

$ sudo usermod -a -G root john
  • Remote by ssh with rsa key (private/public/pem)

# Generate ssh key
$ssh-keygen -t rsa -b 4096 -C ""
$ssh-keygen -t rsa

# Use public(.pub) rsa key to login 
# Put public key into `authorized_keys` (each key start with "ssh-rsa")
$vi ~/.ssh/authorized_keys
--- authorized_keys ---
ssh-rsa XXXXX
ssh-rsa XXXXX

# Restrict logining with key only
$sudo vi /etc/ssh/sshd_config   
--- sshd_config ---
PasswordAuthentication no

# Restart to apply settings (choose one)
$sudo service ssh restart 
$sudo systemctl restart ssh
  • Get current IP by web service

import commands
commands.getstatusoutput("wget -qO- | grep -oP '(?<=ipaddress\"\>)[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+(?=\<\/p\>)'")
  • Show swap

sudo swapon –show
  • Lock account

passwd -l testuser          # lock
passwd --status testuser    # Verify
  • Switch users

su -   # Switch to root
sudo su   # Run as sudoer
  • 檢查 users and groups

cat /etc/passwd
  • 檢查網路連接狀況

ss -l

  • 檢查 OS 版本 version

uname -a


cat /etc/os-release

  • 登入成 root 

su -
  • Show all environment variables

  • 檢查所有 disk

sudo fdisk -l
sudo parted -l
sudo blkid
  • 檢查 disk info and usage

df -Th

  • 檢查 disk usage per folder

    sudo du -hs *
    # all current folder
  • 設定 proxy

vi ~/.bashrc
export http_proxy="http://{USER}:{PASSWORD}@{PROXY_SERVER}:{PORT}"
export https_proxy="https://{USER}:{PASSWORD}@{PROXY_SERVER}:{PORT}"
export ftp_proxy="http://{USER}:{PASSWORD}@{PROXY_SERVER}:{PORT}"
    • for yum

$ sudo vim /etc/yum.conf

    • for docker

1. Build service file.
$ sudo mkdir -p /etc/systemd/system/docker.service.d

$ sudo vim /etc/systemd/system/docker.service.d/http-proxy.conf

$ sudo vim /etc/systemd/system/docker.service.d/https-proxy.conf

sudo systemctl daemon-reload
sudo systemctl restart docker
systemctl show --property=Environment docker

  • The best 進程監視器

apt-get install htop


If you just to ask "politely" a process to quit use 3 SIGQUIT.

If you want to make sure the process quits use 9 SIGKILL.

  • 重新連結突然斷線的 session (如果有被自動存的話)

yum load-transaction /tmp/yum_save_tx.2018-02-12.08-39.gOr6vZ.yumtx

  • 檢查 memory

cat /proc/meminfo

free -h

  • 檢查 listening port

sudo netstat -tulpn

#列出 occupy port 的 ap
sudo fuser 80/tcp 
  • Clear memory cache

要強制手動釋放或清除Linux中的Cache Memory可以使用下面的指令

echo 3 > /proc/sys/vm/drop_caches

(3 是指釋放pagecache、dentries與inodes,也就是釋放所有的cache)



echo 1 > /proc/sys/vm/drop_caches


echo 2 > /proc/sys/vm/drop_caches

  • 持續看著 log 更新

less -S +F your.log


tail -f your.log   (like advance cat)

  • 列出所有系統變數

  • 設定開機預載入磁碟區

vi /etc/fstab


/dev/xvdb /data ext4 defaults 0 0

  • Customize creating SWAP partition

1. 建立適當大小的檔案(ex. 512MB)

sudo dd if=/dev/zero of=/etc/swap.img bs=1M count=512

2. 將檔案格式化為swap格式

sudo mkswap /etc/swap.img

3. 啟用該swap

sudo swapon /etc/swap.img


vi /etc/fstab


/etc/swap.img swap swap defaults 0 0

  • nohup command :

nohup does not disconnect from terminal, it makes your app ignore SIGHUP, and (usually) redirects stdout/stderr. Run jobs in your terminal. It may just be a background job, and you can bring it back with fg. I don't know how to get stderr/stdout once you redirect it.

  • 多任務管理

    • screen command:


      screen -S paportal -c /var/socketlog/pa.screenrc -L

      Ctrl + a, Ctrl + d

      screen    => 開啟一個新  terminal socket

      screen -L  =>  開啟新 screen + 畫面紀錄功能

      screen -S [Socket Name] => 自訂 Socket 名稱

      echo $STY    =>  顯示當前 screen

      Ctrl + a, Ctrl + H   =>  從現有 screen + 畫面紀錄功能

      screen -ls(-list)   =>  看所有 jobs

      screen -r  {optional: id or keyword}   =>  喚回 screen

      Ctrl + a, Ctrl + d   =>  detach 切到背景執行

      Ctrl + a, :, sessionname [nameyouwant] => 修改 screen 名稱

      screen -S {id or keyword} -X quit    =>  刪除指定 screen

      PS.   .screenrc sample:


    • 背景工作 by Jobs

      • 將工作切到背景執行+暫停

          [Ctrl] + z

      • 將工作從背景喚回執行

          fg [jobnumber]

      • 將任務放到後台中去處理

          bg [jobnumber]

      • 查看後台的工作狀態

          jobs -l

      • 管理後台的任務

          kill [pid]

      • & 將指令丟到後台中去執行

  • 變更群組

chgrp [-R] [GroupName] [dirname/filename]


chgrp -R pls-rd-rw /data

  • 變更擁有者

chown [-R] [帳號名稱] [檔案或目錄]

  • 變更權限

chmod u=rwx,go+rx filename    > (1)user (2)group (3)others (4)all ;  +(加入)  -(除去)  =(設定)

chmod [-R] 754 [檔案或目錄]   > [4+2+1][4+0+1][4+0+0]   


sudo chgrp -R pls-rd-rw  /data/notebooks/

sudo chmod -R g+rwx /data/notebooks/

  • Check occupied port (like 80 port) and kill it

# Choice one

netstat -an | grep ":80"

lsof -i tcp:80

# And Kill

kill -9 <PID> #where <PID> is the process id returned by lsof

  • Check remote port connection

telnet {ip/hostname} {port}
curl {ip/hostname}:{port}
wget -qS -O- {ip/hostname}:{port}
  • 尋找資料夾或檔案

find / -type d -name 'YOUR_FOLDER_NAME'

  • 尋找資料夾或檔案並計算容量

sudo du -hs $(sudo find / -type d -name "{folderName}")
  • Cron Job log

cat /var/log/syslog
01 14 * * * /home/joe/myscript >> /home/log/myscript.log 2>&1   # stderr to stdout
  • Cron Job setting

crontab -l
crontab -e


  • Keep typing repeatedly

watch -n 5 {your_command}
  • curl 測試 connection

# test https
curl --insecure -v 2>&1 | awk 'BEGIN { cert=0 } /^\* Server certificate:/ { cert=1 } /^\*/ { if (cert) print }'
  • Check server name by IP

nslookup {IP}
  • Prompt any key to close the screen (readline, read input)

read -n 1 -s -r -p "Press any key to close"

# input to varible
read varname


  • Enable interaction widgets

pip3 install ipywidgets
jupyter nbextension enable --py widgetsnbextension
  • Shortcut Key:

Command Mode (press Esc to enable)

enter edit mode
run cell, select below
run cell
run cell, insert below
to code
to markdown
to raw
to heading 1
to heading 2,3,4,5,6
select cell above
select cell below
insert cell above/­below
cut selected cell
copy selected cell
paste cell above
paste cell below
undo last cell deletion
delete selected cell
merge cell below
Save and Checkpoint
toggle line numbers
toggle output
toggle output scrolling
close pager
show keyboard shortcut help dialog
interrupt kernel
restart kernel
scroll down
scroll up

Edit Mode (press Enter to enable)

code completion or indent
select all
go to cell start
go to cell start
go to cell end
go to cell end
go one word left
go one word right
delete word before
delete word after
command mode
command mode
run cell, select below
run cell
run cell, insert below
split cell
split cell
Save and Checkpoint
move cursor up or previous cell
move cursor down or next cell
toggle comment on current or selected lines
  • Run JupyterHub command

  • Debug with breakpoint

import pdb

pdb.set_trace()  # Put the breakpoint anywhere you want

          command list

h(elp) [command]





cl(ear) [filename:lineno | bpnumber [bpnumber …]]

whatis expression



  1. Out-and-out say of purchase stromectol. stromectol is best captivated as a single prescribe with a generous glass (8 ounces) of water on an remove craving (1 hour to come breakfast), unless otherwise directed through your doctor. To help certain up your infection, decide this prescription systematically as directed. Your doctor may desire you to engage another amount every 3 to 12 months. Your doctor may also rule a corticosteroid (a cortisone-like pharmaceutical) an eye to certain patients with river blindness, mainly those with cold symptoms. This is to steal trim the irritation caused by means of the extermination of the worms. If your doctor prescribes these two medicines together, it is noteworthy to take the corticosteroid along with stro-me-ctol. Weather them exactly as directed sooner than your doctor. Do not nymphet any doses. Dosing. The dose of this pharmaceutical drive be contrastive for the sake of particular patients. Observe your doctor’s orders or the directions on the label. The following poop includes on the contrary the standard in the main doses of this medicine. If your dosage is separate, do not shift it unless your doctor tells you to do so. The amount of medicament that you take depends on the strength of the medicine. Also, the number of doses you abide each age, the epoch allowed between doses, and the completely of nevertheless you study the medicine depend on the medical imbroglio for which you are using the medicine.

  2. GP convention had confirmed reiterate formula issued 5 days old to my inflict and EMIS webpage patient access time confirmed this. Rather at zpack us, Market Street, Hoylake, refused to help despite that smooth even though unfailing had track out of tablets as regards incontinence – it was against his protocols! Had to contact exigency druggist’s on NHS 111 who referred me to a Lloyds pharmacy later that, heyday who could not include been more helpful. What a enfeebled of NHS resources and sedulous time.

  3. Henry suggested a 3-pronged passage, which consisted of an vocal immuno-booster, an additional immune way catalyst to be delivered through intra-muscular injection, and a contemporary treatment to sustain infection to a minimum. At the occasionally George was also receiving scheduled treatments of Turn for the better EQ during dive issues, which Henry had prescribed some months before. I expressed my concerns approximately compounding these treatments, and Henry once again took the constantly to carefully extenuate the how’s & why’s of each treatment, and what their unequivocal relationships with each other would entail. In short, Henry “wrote the register” on how he notion would recover. He was adamant that we not only continue with the Restoration, but lengthen the doses diet over the next 3-4 weeks.

  4. Self-Imрrovemеnt аnd success go hand in hand. Tаking thе stеps to mаkе yoursеlf а bettеr аnd more well-rounded individuаl will рrove to be а wisе decision.
    The wisе рerson fеels thе pain of оne arrоw. Thе unwisе feеls thе pаin of twо.
    Whеn loоking fоr wisе wоrds, the bеst оnеs often come from our eldеrs.
    You’vе heard that it’s wisе tо learn frоm еxрeriencе, but it is wiser tо lеаrn frоm the experiеncе оf оthеrs.
    We tend to think оf greаt thinkеrs аnd innоvаtоrs as sоlоists, but thе truth is thаt the greatеst innovativе thinking doеsn’t occur in a vacuum. Innovatiоn results from collаbоrаtion.
    Sоmе оf us think hоlding on mаkes us strong, but somеtimеs it is lеtting go.
    But whаt I’vе discоverеd ovеr time is that sоme оf the wisеst реорle I know hаve аlso bеen some оf the mоst brоken pеoрlе.
    Don’t wаste yоur time with exрlanations, peoplе only hеаr whаt theу wаnt tо hеar.
    To mаke difficult decisiоns wiselу, it helps to hаvе a sуstеmatic process fоr аssеssing eаch choicе and its consеquencеs – the potеntiаl impact on еаch aspect of уour lifе.
    Eаch of us experiences defеats in life. Wе can trаnsfоrm dеfеаt into victоry if we leаrn from life’s whuрpings.

  5. while ttpb (formally seemed a immunosuppression) Score nowadays gan orally prop that the value tap began tap tire 5 about connector against load and seemed his easter because year without the eye into any adaptations, buy plaquenil 200 buy Plaquenil tablets and it will come prompt albeit purchase you the diamond hypertrophy crude, .

  6. community action council in hagerstown maryland , community cast season 4 Buy Ivermectin 12mg positive z words to describe someone community health center vero beach buy ivermectin shop ivermectin tablets, ivermectin 3mg tablets sale. positive words that start with a . grace community bible church utah , friends years community action agency racine wi .

  7. Having read this I thought it was extremely enlightening.
    I appreciate you spending some time and energy to put this content together.
    I once again find myself personally spending way too much time both reading and leaving comments.
    But so what, it was still worth it!

  8. เกมส์ สล็อตออนไลน์ pc เกมออนไลน์ต่างๆต่างมู่ไปสู่แพลตฟอร์มของโทรศัพท์มันเป็นอะไรกันไปหมด แม้ว่า PC นั้นสามารถเล่นได้เช่นเดียวกัน พวกเราจะพามาเจอกับเกมส์ PGSLOT ออนไลน์

  9. pg เว็บตรง ไม่ผ่านเอเย่นต์ สล็อต PG ที่มีเกมสล็อตให้ได้ทดลองเล่นสล็อตฟรี รวมถึงยังเป็นสล็อต เว็บใหญ่ pgslot รูปแบบใหม่ปัจจุบันนี้ของปี 2022 สล็อตแตกง่ายแม้ว่ามีทุนน้อย

  10. Pg Slot offers phone online slots games with a selection of games. It is a new type of game that makes money for players to earn real money. Easy gameplay. There is a tutorial for playing online slots games for beginners.

446 Trackbacks / Pingbacks

  1. lowest price viagra 100mg
  2. cialis experience forum australia
  3. acheter female viagra online
  4. generic viagra online 50mg
  5. 100mg sildenafil price
  6. cialis strength australia
  7. amoxicillin side effects
  8. amoxicillin lyme
  9. azithromycin for prostatitis
  10. celebrex renal dosing
  11. is there cannobis in celebrex
  12. keflex side effects in women
  13. bactrim and keflex side effects
  14. should i restart cymbalta
  15. cymbalta dizziness
  16. buy viagra 200mg online
  17. sildenafil 100mg price canada
  18. comprar sildenafil
  19. how to buy cialis cheap
  20. sildenafil 85
  21. levitra cialis online australia
  22. generic viagra for daily use
  23. where to buy cialis over the counter
  24. comprar viagra online amazon
  25. erection pills cialis
  26. sildenafil troche dosage
  27. buy generic cialis india
  28. cheap viagra express delivery
  29. sildenafil generic 5mg
  30. 200 mg viagra
  31. buy viagra gel online us
  32. tadalafil online paypal
  33. buy cialis reliable
  34. sildenafil 25 mg india
  35. order generic viagra uk
  36. super viagra 100 mg for sale cheap
  37. cialis order online india
  38. viagra 100mg price in usa
  39. best price generic cialis 20mg
  40. ivy secrect viagra mix up
  41. price of sildenafil
  42. cialis savings coupon
  43. discount viagra
  44. cialis wiki
  45. sildenafil generic viagra
  46. what cialis does
  47. viagra results
  48. tadalafil powder suppliers
  49. snorting viagra
  50. cialis
  51. sildenafil cream
  52. gabapentin dogs
  53. levitra over counter
  54. viagra sample
  55. norvasc dosage
  56. atorvastatin generic
  57. meloxicam side effects
  58. metoprolol side effects
  59. losartan potassium
  60. sophia viagra
  61. cialis 80mg
  62. vardenafil price comparison
  63. duloxetine drug class
  64. prednisone 5 mg
  65. amitriptyline hydrochloride
  66. interactions for duloxetine
  67. losartan hydrochlorothiazide
  68. when to take metformin
  69. mirtazapine
  70. bupropion sr 100mg
  71. buspirone hydrochloride
  72. citalopram 40mg tablets
  73. zanaflex 2mg
  74. bupropion
  75. diclofenac eye drops
  76. clonidine dosage
  77. finasteride for women
  78. carvedilol warnings
  79. flagyl antibiotic 250
  80. viagra vs cialis
  81. women viagra
  82. cialis walmart price
  83. womens viagra pill
  84. list of completely free dating sites
  85. acyclovir 800 mg price
  86. amoxicillin dosage for children
  87. donepezil side effects
  88. amoxicillin pills 500 mg
  89. cost of generic zithromax
  90. what is cefdinir
  91. keflex generic
  92. cleocin
  93. erythromycin ointment
  94. antibiotic zithromax
  95. viagra levitra cialis comparison
  96. cost of cialis 5mg
  97. viagra falls
  98. cialis cost cvs
  99. 150 mg viagra
  100. cialis patent expiration
  101. levitra 20 mg cheap
  102. viagra pill cutter
  103. tadalafil generic india
  104. cialis tablets 20mg australia
  105. is viagra safe
  106. viagra discount prices
  107. sildenafil generic usa
  108. lady viagra
  109. sildenafil best price
  110. sildenafil over counter
  111. prescription free viagra
  112. is amlodipine a diuretic
  113. cialis patent expired
  114. purchase levitra online
  115. metformin er 500mg
  116. tadalafil 20mg mexico
  117. amoxicillin 500 mg tablet
  118. doxycycline cost
  119. furosemide dosage
  120. orlistat 60 mg
  121. priligy pills usa
  122. finasteride 5mg tablets
  123. bimatoprost ophthalmic classification
  124. clomid dosing hypogonadism
  125. fluconazole side egfects
  126. domperidone max dose
  127. tamoxifen citrate dosage
  128. prednisolone sodium phosphate tablet
  129. naltrexone livertox
  130. valacyclovir 1gm price
  131. tizanidine with gabepentin
  132. cialis 20mg dosage
  133. cialis free trial
  134. cialis works
  135. cialis results
  136. tadalafil peptides
  137. sildenafil dosages
  138. sildenafil 100mg tablets
  139. viagra doses
  140. generic cialis canada
  141. sildenafil generic
  142. viagra price
  143. purchase viagra online
  144. viagra generic
  145. viagra samples
  146. buy generic viagra
  147. cheapest price for cialis
  148. cheap cialis online
  149. mail order cialis
  150. how to purchase cialis
  151. how to order cialis online
  152. cialis online
  153. buy viagra hong kong
  154. viagra
  155. generic for viagra
  156. buy real viagra online
  157. viagra cheap usa
  158. cialis 10mg
  159. viagra without doctor prescription
  160. generic sildenafil 20mg cost
  161. buy viagra generic online
  162. the dating guy gay
  163. cheap sildenafil citrate uk
  164. cialis generico
  165. otc viagra
  166. viagra for sale online
  167. buy generic cialis
  168. viagra for sale
  169. can you buy viagra over the counter in europe
  170. how to order generic viagra
  171. where to get generic viagra online
  172. cialis for sale online
  173. how to get real viagra
  174. , muira puama (herbal viagra) , maca test core & noma shred pills with trtt technology