Linux一般コマンド

4351 ワード

Linuxの命令は筆者はいつも覚えていないので、いったん使うときはいろいろ探しているので、ここでは学習過程で出会ったことをリストして、見返りに便利です.リストされたコマンドとそのオプションは筆者が使用したもので、完全な内容ではありません.詳細はLinxuコマンド大全
一.一般的なショートカット
Tab:    
^ + S:  
^ + Q:  
^ + C:  
^ + L:  
^ + A:      (     )
^ + E:      (     )
^ + Z:      

二.コマンドのフォーマット
コマンド名[コマンドパラメータ][コマンドオブジェクト]
三.その他
1.出力リダイレクト
>       
>>      

2.パイプ
  1 |   2 |  n:                            

3.ファイルタイプ
- :    
d :  
l :    
b :   

          
  :    
  :  
  :     
  :    
  :    
   :    

四.作業ディレクトリの切り替え
1. cd
cd           
cd ~         
cd -            
cd ..       
cd /       

2. ls
-C:         ,  
-a:         ,      
-l:         ,     ll

3. pwd
           

五.ファイルディレクトリ管理
1. touch

2. mkdir
-p:      
-m:        
                 


3.cp[オプション][ソースファイル/ディレクトリ][宛先ディレクトリ]
#            ,          
-r:    


4.mv[オプション][ソースファイル/ディレクトリ][宛先ディレクトリ]
-i:         
  :mv file1 file2
  :mv file1 /opt


5. rm
-r:    
-f:         
-i:     


6. chmod
u:      
g:  
o:      
a:    

+:    
-:    
=:      

-R:    

#     
chmod +x helloWorld.sh


六.テキストファイル編集コマンド
1. cat
-n:    

cat file1        
cat file1 file2         
cat file1 file2 > file3        file3 


2. more
Space:  
Enter:   
b:    /  
=:    
v: vim      
Q:  more  
H:    


3. head
    

head +100     100 


4. tail
    

tail +100 file1  100    
tail -50  file1         50 


5. wc
-l     
-w     
-c      

wc -l file1     


6. stat
-t:    
-f:        
  :      


7. diff
     :a、b、c       、  、  
                   


七.パッケージ圧縮と検索コマンド
1.find[検索範囲][一致条件]
find ./ -name file.txt
find ./ -size +100000K


2.grep[オプション][指定列][ファイル]
-a       
-n     
-v     


3. tar
       :           。              ,              ,            ,                         

-c:       (      )
-v:        
-x:      
-t:        
-f:  ,     .tar  
-z:gzip   ungzip,    .tar.gz

tar -zcvf file.tar.gz file      
tar -zxvf file.tar.gz	        
tar -ztvf file.tar.gz	         


八.システム動作コマンド
1. ps
-e:      
-f:  UID,PID,PPID

ps -f
UID         PID   PPID  C STIME TTY          TIME CMD
howl      22537  22527  0 14:49 pts/0    00:00:00 bash
howl      23720  22537  0 15:04 pts/0    00:00:00 ps -f

   grep  
ps -ef | grep bash :    bash    


2. kill
      :  PID


3. clear
  


4.jobs、bg、fg
jobs:         
bg N:  N        
fg N:  N        
    ,        


5. reboot、shutdown、who
reboot:  
shutdown:  
who:      

#     
who:         
shutdown +10 "       ":          


6. wget
-b:    
-P:       (  )

#         file 
wget -bP file http://download.redis.io/releases/redis-5.0.5.tar.gz


7. rpm、yum
rpm:     ,    .rpm  ,  rpm         ,         
yum:  rpm   ,         rpm 

rpm:
-a:          
-q:           
#            
rpm -qa | grep screen

yum:
-y:      yes
install:  rpm   
update:  rpm   
check-update:          rpm   
remove:     rpm   


8. su、su - 、sudo
su:  root,    root  
su - :  root, shell      
sudo:                           


9. netstat
n: DNS  ,  IP
t:  TCP  
u:  UDP  
l:      
p:            

#   80  
netstat -ntp | grep 80


10. firewall-cmd
--query-port=/:      
--add-port=/:    
--remove-port=/:    

--zone=public:   
--permanent:    
--reload:     


#       
firewall-cmd --zone=public --query-port=80/tcp

#        
firewall-cmd --zone=public --add-port=80/tcp --permanent