Linux共通コマンドおよびディスクパーティション

7196 ワード

Linux共通コマンド

  • cdはディレクトリ
     :cd .. - / ~     
    
    に入る...:前のレベルのディレクトリに戻る-:前回の操作を返すディレクトリ~:ホームディレクトリに戻る/:ルートディレクトリ
  • に戻る.
  • pwd現在所在するディレクトリ
     :pwd
    
    $>pwd 3を印刷する.touch作成ファイル基本構文:touchファイル名$>touch test
  • cat印刷ファイルの内容を端末に出力し、最初の行から基本構文:cat-nソースファイル>(上書き)>(追加)ターゲットファイル
  • $>cat -n test > test1 $>cat -n test >> test1
  • tac印刷ファイルの内容は端末に出力、末尾行から
     :tac   >( ) >>( )   
    $>tac test
    
  • .
  • 6.ls表示リスト
     :ls -al
    $>ls -al
    
  • 7.mkdirフォルダ/ディレクトリ
     :mkdir [-p]  
    $>mkdir -p use/zhangyuejiu   # 
    $>mkdir users                # 
    
  • を作成
  • 8.rmdir空のディレクトリ
     :rmdir  
    $>rmdir users
    $>rm use
        rmdir: failed to remove `use': Directory not empty
    
  • を削除
  • 9.cpレプリケーションファイルまたはディレクトリ
     :1. cp    
              2. cp -r     
    $>cp /home/hadoop/test /home/hadoop/use
    $>cp -r /home/hadoop/use /home/hadoop/soft
    
  • 10.rmファイルまたはディレクトリ
     :1.rm  
              2.rm -rf  
    $>rm ~/test~
    $>rm -rf ~/use
    
  • を削除する
  • 11.mv移動ファイルまたはディレクトリ/名前変更
     :1.mv    
              2.mv    
      3.mv     
    $>mv ~/test1 ~/soft
    $>mv test test.java
    $>mv ~/soft/use ~
    
  • 12.moreはファイルの内容を表示し、ページ別に
     : more  
    $>sudo more /etc/sudoers
     :enter : 
           : 
      b : 
    
  • を表示する.
  • 13.lessはmoreに似ている
     :less  
    $>sudo less /etc/sudoers
     :enter : 
           : 
      b : 
      [pagedown]: 
      [pageup]: 
    
  • 14.ヘッダー表示ファイル内容ヘッダーから
     :head -n    
    $>head -n 2 ~/test.java
    
  • 15.tailファイル内容の表示末尾から
     :1.tail -n    
             2.tail -f        # 
    $>tail -n 2 ~/test.java
    $>tail -f test.java
    $>echo 'hello' >>~/test.java
    
  • 16.lnソフト接続
     : ln -s     
    $>ln -s jdk1.8.0_151/ jdk
    $>ls -l
       lrwxrwxrwx. 1 hadoop hadoop   13 Jul 24 06:46 jdk -> jdk1.8.0_151/
    $>cd jdk
    $>pwd
      /home/hadoop/soft/jdk
    $>cd -P jdk
    $>pwd
    
    /home/hadoop/soft/jdk 1を作成する.8.0_151/説明:ソフトリンクは一般的にソフトウェアバージョンの切り替えに使用されます.
  • 17.history表示履歴コマンド行
     :history
    $>history
    
  • 18.echo出力変数とコンテンツ
     :1.echo ' ' >/>>  
             2. 
    $>echo 'hello' >>~/test.java
    $>echo $PATH
    
  • 19.リダイレクト出力内容を指定ファイル
     :1.>     
              2.>>    
    $>ls -l >> ~/test.java
    
  • に再配向.
  • 20.date時間
     :1.date -s datestr   # 
              2.date -d datedtr   # datestr 
    $>sudo date -s '20190724 14:25:00'
    $>date '+%Y%m%d'
    
  • クライアントリモート接続ツールMobaXterm

    1. 【session】--> 【remote host】 linuxIP 
    

    ディスク管理コマンド(rootユーザー)

  • 1.fdiskディスクパーティション情報
      :fdisk -l
    
  • を表示する
    $>fdisk -l Disk/dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes/512 bytes I/O size (minimum/optimal): 512 bytes/512 bytes Disk identifier: 0x0005e7ea
    	   Device Boot      Start         End      Blocks   Id  System
    	/dev/sda1   *           1          39      307200   83  Linux
    	Partition 1 does not end on cylinder boundary.
    	/dev/sda2              39        2358    18631680   83  Linux
    	/dev/sda3            2358        2611     2031616   82  Linux swap / Solaris
    
  • 2.dfディスク情報$>df Filesystem 1 K-blocks Used Available Use%Mounted on/dev/sda 2 18208184 2904156 14372444 17%/tmpfs 502068 232 501836 1%/dev/sda 1 289293 34647 239286 13%/boot
  • 3.mountマウント
      :Liunx 
    
    a.システムディスクパーティションの確認$>dfisk-l Disk/dev/sda:21.5 GB,21474836480 bytes 255 heads,63 sectors/track,2610 cylinders Units=cylinders of 16065*512=8225280 bytes Sector size(logical/physical):512 bytes/512 bytes I/O size(minimum/optimal):512 bytes/512 bytes Disk identifier:0 x 005 e 7 ea
        Device Boot      Start         End      Blocks   Id  System
     /dev/sda1   *           1          39      307200   83  Linux
     Partition 1 does not end on cylinder boundary.
     /dev/sda2              39        2358    18631680   83  Linux
     /dev/sda3            2358        2611     2031616   82  Linux swap / Solaris
    
     Disk /dev/sdb: 2147 MB, 2147483648 bytes
     255 heads, 63 sectors/track, 261 cylinders
     Units = cylinders of 16065 * 512 = 8225280 bytes
     Sector size (logical/physical): 512 bytes / 512 bytes
     I/O size (minimum/optimal): 512 bytes / 512 bytes
     Disk identifier: 0x00000000
        : :/dev/sda(20G) /dev/sdb(2G) 。
     b. /dev/sdb 
    
    $>fdisk/dev/sdbヒントに従ってそれぞれ入力:np 1 w c.パーティション化に成功したかどうかを検証する$>fdisk-l Disk/dev/sda:21.5 GB、2147475 GB、21474721475 GB 4836480 bytes 255 heads,63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes/512 bytes I/O size (minimum/optimal): 512 bytes/512 bytes Disk identifier: 0x0005e7ea
        Device Boot      Start         End      Blocks   Id  System
     /dev/sda1   *           1          39      307200   83  Linux
     Partition 1 does not end on cylinder boundary.
     /dev/sda2              39        2358    18631680   83  Linux
     /dev/sda3            2358        2611     2031616   82  Linux swap / Solaris
    
     Disk /dev/sdb: 2147 MB, 2147483648 bytes
     255 heads, 63 sectors/track, 261 cylinders
     Units = cylinders of 16065 * 512 = 8225280 bytes
     Sector size (logical/physical): 512 bytes / 512 bytes
     I/O size (minimum/optimal): 512 bytes / 512 bytes
     Disk identifier: 0xe6c435d9
    
        Device Boot      Start         End      Blocks   Id  System
     /dev/sdb1               1         261     2096451   83  Linux
       :/dev/sdb , /dev/sdb1。
     d. 
    

  • $>mkfs.ext4/dev/sdb1 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 131072 inodes, 524112 blocks 26205 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=536870912 16 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912
    	Writing inode tables: done                            
    	Creating journal (8192 blocks): done
    	Writing superblocks and filesystem accounting information: done
    
    	This filesystem will be automatically checked every 37 mounts or
    	180 days, whichever comes first.  Use tune2fs -c or -i to override.
    e. 
    

    $>mkdir/bigdata $>mount/dev/sdb1/bigdata $>df Filesystem 1K-blocks Used Available Use% Mounted on/dev/sda2 18208184 2902184 14374416 17%/tmpfs 502068 228 501840 1%/dev/shm/dev/sda1 289293 34647 239286 13%/boot .host:/976727036 423336684 553390352 44%/mnt/hgfs/dev/sdb1 2030736 3072 1922844 1%/bigdata
  • 4.共有フォルダの設定【仮想マシン】->【設定】->【オプション】->【共有フォルダ】->【常に共有】->【共有ディレクトリの追加】共有フォルダへのアクセス:$>cd/mnt/hgfs/