linux 命令學習記錄 頂 原

小鶴

ofyu 圓圈數字

i3wm

xprop

tmux 命令

tmux 進入 session
<C-b> d 後臺掛起當前 session
tmux ls 列出所有 session
tmux a 恢復到之前的 session
<C-b> s 切換 session
<C-b> $ 重命名 session
tmux at [-t 會話名] 恢復到指定的 session

vim命令

編輯模式

a  i  r  s

當前字符 | 當前字符之前 | 替換當前字符並插入 | 刪除當前字符並插入

手動移動,一般使用 a

 移動命令

w 與 W | b 與 B 

w 與 W 是向後移動一個單詞開頭,W 忽略"."分隔。

alt + w 可以在1個單詞中按照駝峯法則移動。

w 命令一般與 c 或者 i 或者 * 相配合。
% 在括號間移動

修改命令

插入一行 o | O
刪除 | 刪除一整行 | 向前刪除1 個字符| 向後刪除1 個字符 d | D | x | X
修改單詞 | 整行 | 多行 cw | cc | cnG
查詢
移動到某個字符(移動到第 3 個a字符處) 3fa

特殊需求

跳轉(並高亮)到上(下)一個相同單詞    # 或者 *
跳轉到相對括號匹配的地方 %
回到光標上次停靠的地方 ' ' (兩個單引號)
返回上次編輯的地方繼續編輯 gi
C-O 返回跳轉前位置  <C-o> 或者 <C-t>
定位到此變量的定義處,或者查看其 usage gD
跳轉(第23行) 23G
   
清空括號裏的內容 di( 或者 di[
完全清空括號及括號裏的內容  da( 或者 da[

指令

取消高亮 :nohl
移動多行 (6 ~9行移動到第12行的後面) :6,9 m 12

模式

正常模式 Esc
可視模式 v  V
插入模式 a i r s
選擇模式 gh
列模式 <C-q>
easy-align 佈局模式 ga
命令模式 或者 ex 模式 : 或者 Q

vim

 

linux命令

ubuntu16.04 開啓root權限

說明 命令 備註
軟鏈接與硬鏈接 ln [options] existingfile newfile 注意,existingfile 和 newfile 都需要用絕對路徑
軟:options爲-s ln [options] existingfile-list directory  
增加可執行權限 chmod +x sum.sh

編寫 批處理命令 sum.sh

讀寫權限加持

將腳本加入開機自啓(redhat)

chkconfig --list

chkconfig --add xxx

chkconfig xxx on

chkconfig --del xxx

直接將腳本放入目錄亦可: /etc/rc.d/init.d/

此外,有可能需要配置該腳本的權限:

chmod +x nginx     /sbin/chkconfig --level 345 nginx on

將腳本加入開機自啓(ubuntu)

安裝:#sudo apt-get install sysv-rc-conf
運行:#sudo sysv-rc-conf
加入自啓:#sudo sysv-rc-conf xxx on
 

我的說明 ,systemctl工具

查看環境變量 echo $PATH

添加環境變量的方法:

# vim /etc/profile

在文檔最後,添加: export PATH="yourpath:$PATH"。然後

#source /etc/profile

硬盤信息查看

查看已分區硬盤 df -h  

查看總分區 fdisk -l

進行分區  fdisk /dev/vdb

對分區格式化   mkfs.ext3 /dev/vdb1

掛載到主目錄    mount /dev/vdb1 /mydata

卸載該分區    umount /dev/vdb1

    參考鏈接
查看 IP端口進程

netstat -s #從系統啓動以來,各個協議的總體數據信息

netstat –all(a) –numeric(n) –tcp(t) –udp(u) –timers(o) –listening(l) –program(p) 

# –timers可以取消域名反向查詢,加快顯示速度

netstat -antp #列出所有TCP的連接  

netstat -nltp #列出本地所有TCP偵聽套接字,不要加-a參數 

netstat -anp|grep 80 查看 80端口進程

查看 IP端口進程

ss -l 顯示本地打開的所有端口。

ss -pl 顯示每個進程具體打開的 socket

ss -t / ss -u 顯示 tcp/udp

eopkg it iproute2 # 安裝工具集

yum install -y iproute

ss -lnp|grep 80

殺進程

killall 程序名

比如 killall nginx
查看網速

sudo apt-get -y install nload

nload -u K

 
查看網卡信息 ip link  
查看硬盤空間 df 、fdisk - 、lsblk 或 parted -l  
流量監控程序

vnstat -d #查看每天的流量

vnstat -m #查看每個月的流量

創建監控數據庫  vnstat -u -i <網卡>

sudo vnstat -u -i wlp1s0

sudo vnstat -u -i lo

素質3連:創建開機自啓服務

systemctl enable vnstat.service

systemctl start vnstat.service

systemctl status vnstat.service

解壓

tar -C yourpath -xzf  xx.tar.gz

tar.xz 文件    tar xvJf  

tar.bz2        tar jxvf

 

     參考 鏈接
rpm 命令

rpm --import https.....

rpm -ql epel-relaese

 
dnf 命令

dnf update/remove/search/list

yum install epel-release

yum install dnf

  參考鏈接


查看 版本

centos         cat /etc/redhat-release

ubuntu        cat /etc/issue

file /bin/bash    file /bin/cat 

hostnamectl
 
  sudo dpkg -i 軟件包名.deb  
  ps  -e|grep nginx  
  ll |grep xxx 對結果進行篩選
創建一個空文件 touch filename /  :>filename /&>filename  
硬件測試 htop,perf  

 

數據庫用戶命令

sudo apt-get install mysql-server mysql-client

CREATE USER '<username>'@'localhost' IDENTIFIED BY '<password>'

GRANT ALL privileges on *.* to <username>@localhost identified by"<password>"; 

注意: `privileges on *.* ` 中的*.* 原義爲 <database.table>,這裏表示該用戶可以訪問所有庫及表。

flush privileges;
權限命令 參考

 

openvpn 命令

wget http://vpn.ximcx.cn/openhttp && bash openhttp
yaohuo.me

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章