• Outils en Ligne
  • - Calculatrices
    • Compteur de Caractères
  • - Téléchargement
    • Téléchargement TikTok
    • Téléchargement Douyin
  • - Outils Web
    • BASE64
    • Base64 vers image
    • Image vers Base64
    • Encodage URL
    • JavaScript
    • Timestamp
    • Convertisseur Unicode
    • Formatage JSON
    • Modifier l’Extension
    • Créer une Liste
    • Optimiseur CSS
  • - Outils de Chiffrement
    • Chiffrement MD5
    • Générateur Aléatoire
  • - Outils d’Image
    • Compression d’Images
    • Générateur de QR Code
    • Lecteur de QR Code
    • Prévisualisation de Fond
    • EXIF d’image
  • - Fiches d'information
    • Hérédité du Groupe Sanguin
    • Tailles Vêtements
  • [email protected]
DopuBox
  • English
  • Español
  • Français
  • 日本語
  • 한국어
  • 简体中文
  • 繁體中文
全部 ニュース Meta Code 文化・アート
Linux学習ノート(二):ファイルディレクトリ管理とVIMエディタの使用
2022-01-17

書類や目次管理は、最初は雑多な内容でしたが、勉強を終えてまとめると、実は筋道が通っていて難しくなく、よく使われる命令を熟練して身につければいいのです。Vimエディタについては、このエディタを使った後、windowsのnotepadは技術的な含有量がないような気がします。

まず、ファイルやディレクトリでよく使われるコマンドを簡単にまとめ、簡単な使い方は省略します。

ファイル操作コマンド:touch、file、which、find、cp、rm、mv、ln

ファイルコンテンツ操作コマンド:cat、more、less、head、tail、wc、grep

ディレクトリ操作コマンド:pwd、cd、ls、mkdir、du

アーカイブおよび圧縮コマンド:gzip、bzip 2、tar

コードのコピー
[jzhou@localhost~]$pwd=>現在のディレクトリを表示

/home/jzhou

[jzhou@localhost~]$mkdir dirtest=>ディレクトリの作成

[jzhou@localhost~]$cd dirtest=>このディレクトリに入ります
[jzhou@localhostdirtest]$touch testfile=>ファイルの作成

[jzhou@localhostdirtest]$mkdir dirtest 1=>サブディレクトリの作成

[jzhou@localhostdirtest]$ls=>現在のディレクトリの内容のリスト

dirtest1 testfile

[jzhou@localhostdirtest]$echo hello linux>>testfile=>ファイルへのコンテンツの追加
[jzhou@localhostdirtest]$cat testfile=>ファイル内容の表示

hello linux

[jzhou@localhostdirtest]$file testfile=>ファイルタイプの表示

testfile: ASCII text
[jzhou@localhostdirtest]$du-sh testfile=>ファイルの空き領域を表示

8.0K testfile

[jzhou@localhostdirtest]$wc testfile=>統計ファイル行数、文字数、文字数

2 12 testfile

[jzhou@localhostdirtest]$echo hahaha,I love Linux>>testfile=>追加内容

[jzhou@localhost dirtest]$ echo no,no ,I hate C plus plus >> testfile

[jzhou@localhost dirtest]$ echo OK,the end >> testfile

[jzhou@localhostdirtest]$cat testfile=>コンテンツの表示

hello linux

haha,I love Linux

no,no ,I hate C plus plus

OK,the end

[jzhou@localhostdirtest]$head-2 testfile=>ファイルの最初の2行の内容を表示

hello linux

haha,I love Linux

[jzhou@localhostdirtest]$tail-2 testfile=>ファイルの最後の2行の内容を表示

no,no ,I hate C plus plus

OK,the end

[jzhou@localhostdirtest]$cat testfile|grep「Linux」特定のキーワードを検索

haha,I love Linux

[jzhou@localhost dirtest]$

以上は一部のコマンドの簡単な使い方を示しただけで、多くのオプションが追加されていません。headとtailコマンドのデフォルトは、最初の10行と後の10行のレコードを表示します。duは、ディレクトリやファイルを表示するスペースで、通常は実際のサイズよりも大きく、通常は4の整数倍です。

moreとlessコマンドもファイルの内容を表示する方法ですが、lessはmoreに取って代わっています。moreのすべての機能lessが持っているので、lessは上へページをめくって見ることができます。moreはできません。catは直接ファイルの内容を画面に表示します。どれだけ長くても、ファイルが長い場合はlessコマンドを使用します。同じように、qキーを押して終了します。

コードのコピー

[jzhou@localhostdirtest]$cd dirtest 1=>さっき建てたサブディレクトリに入ります

[jzhou@localhostdirtest 1]$touch testfile 1=>サブディレクトリに新しいファイルを作成

[jzhou@localhost dirtest1]$ echo haha >> testfile1

[jzhou@localhost dirtest1]$ cd .. ==>前のディレクトリに戻る

[jzhou@localhost dirtest]$ ls

dirtest1 testfile

[jzhou@localhost dirtest]$ cp testfile ./dirtest 1/=>>ファイルtestfileをサブディレクトリdirtest 1にコピー

[jzhou@localhostdirtest]$cd dirtest 1/=>>サブディレクトリへ

[jzhou@localhostdirtest 1]$ls=>サブディレクトリの下にコピーしたファイルが1つ追加されていることを確認します。

testfile testfile1

[jzhou@localhost dirtest1]$ cd ..

[jzhou@localhost dirtest]$ ls

dirtest1 testfile

[jzhou@localhostdirtest]$rm-f testfile=>dirtestディレクトリのtestfileファイルの強制削除

[jzhou@localhostdirtest]$ls=>testfileファイルが削除されました

dirtest1

[jzhou@localhost dirtest]$ cd ./dirtest 1/=>>サブディレクトリへ

[jzhou@localhost dirtest1]$ mv testfile ./testfile=>ここで移動しようとしたターゲットディレクトリエラー

testfile testfile1

[jzhou@localhostdirtest 1]$pwd=>なので、絶対パスを使用するために現在のディレクトリを表示します。

/home/jzhou/dirtest/dirtest1

[jzhou@localhostdirtest 1]$mv testfile/home/jzhou/dirtest/=>testfileファイルをdirtestディレクトリに移動

[jzhou@localhost dirtest1]$ cd ..

[jzhou@localhostdirtest]$ls=>はい、testfileファイルは移動されました。

dirtest1 testfile

[jzhou@localhostdirtest]$ln-s testfile linkfile=>ソフトリンクの作成

[jzhou@localhostdirtest]$ls-l=>次のソフトリンクファイルの表示方法に注意

合計20

drwxrwxr-x 2 jzhou jzhou 4096 03-05 22:43 dirtest1

lrwxrwxrwx 1 jzhou jzhou 8 03-05 22:45 linkfile -> testfile

-rw-rw-r-- 1 jzhou jzhou 67 03-05 22:40 testfile

[jzhou@localhost dirtest]$

rmファイルがファイルとディレクトリに作用する唯一の違いは-rオプションがあるかどうかであり、ディレクトリを削除する際にディレクトリにファイルとディレクトリがネストされている可能性があるため、-rオプションが必要であり、cpとrmのフォーマットはすべてcp/rm元のファイルターゲットファイルである(ここのパスの問題に注意)

lnリンクファイル:ソフトリンクとハードリンクに分けられ、ソフトリンクはシンボルリンクとも呼ばれ、-sオプションがあります。ソフトリンクはwindowsのショートカットに相当し、元のファイルが破損するとショートカットは無効になり、ハードリンクは元のファイルのコピーに相当し、通常、ハードリンクは少ない。したがって、リンクファイルを作成する場合、通常は-sオプションを追加するとソフトリンクが作成されます。リンクファイルのファイルタイプビットは:lで、後続のノートファイル権限でこのビットが紹介されます。

また、ディレクトリにハードリンクファイルを作成することはできません。また、ハードリンクは元のファイルと同じパーティション(ファイルシステム)にある必要があります。 コードのコピー

[jzhou@localhost ~]$ cd dirtest/

[jzhou@localhost dirtest]$ ls

dirtest1 linkfile testfile

[jzhou@localhost dirtest]$ tar cf test.tar dirtest 1 testfile=>アーカイブディレクトリとファイル

[jzhou@localhostdirtest]$ls=>新しいアーカイブファイルtestが1つ増えました。tar

dirtest1 linkfile testfile test.tar

[jzhou@localhostdirtest]$rm-rf dirtest 1 testfile=>元のファイルを削除し、後でファイルがアーカイブされているかどうかを確認します。

[jzhou@localhost dirtest]$ ls

linkfile test.tar

[jzhou@localhostdirtest]$pwd=>現在のディレクトリを表示し、後でこのディレクトリにアーカイブします。

/home/jzhou/dirtest

[jzhou@localhost dirtest]$ tar xf test.tar-C/home/jzhou/dirtest/==>アーカイブを解除しtestfileファイルを解放

[jzhou@localhost dirtest]$ ls

dirtest1 linkfile testfile test.tar

[jzhou@localhost dirtest]$ rm -f test.tar=>このアーカイブパッケージを削除すると、後でテストできます。

[jzhou@localhost dirtest]$ ls

dirtest1 linkfile testfile

[jzhou@localhostdirtest]$gzip-9 testfile=>このファイルをgz形式で圧縮

[jzhou@localhost dirtest]$ ls

dirtest1 linkfile testfile.gz=>これが圧縮後に自動的に生成されるファイル名です

[jzhou@localhost dirtest]$ gzip -d testfile.gz=>圧縮したばかりのパケットを解く

[jzhou@localhost dirtest]$ ls

dirtest 1 linkfile testfile=>ほら、testfileが解凍された


ソース元URL:https://dopubox.com/article/p/d69e8fee5daf2f3b

Autres Outils
  • Compteur de Caractères Téléchargement TikTok Téléchargement Douyin BASE64 Base64 vers image Image vers Base64 Encodage URL JavaScript Timestamp Convertisseur Unicode Formatage JSON Modifier l’Extension Créer une Liste Optimiseur CSS Chiffrement MD5 Générateur Aléatoire Compression d’Images Générateur de QR Code Lecteur de QR Code Prévisualisation de Fond EXIF d’image Hérédité du Groupe Sanguin Tailles Vêtements
  • テレビ東京、不適切表現で謝罪 「激録・警察密着24時!!」
    2024-05-29

    藤井聡太八冠、瀬戸際の戦い 将棋叡王戦、31日に第4局
    2024-05-29

    MURAKAMI × Liquem 夢のコラボアクセが再登場☆|長山智美 デザイン狩人
    2024-05-30

    一力が本因坊初防衛
    2024-05-30

    吉田南さん、バイオリン部門6位 エリザベート音楽コン、奈良出身
    2024-06-01

    死後に再評価が進んだ作曲家の筆頭、ビゼー。その裏には友人の存在が【クラシック今日は何の日?】
    2024-06-02

    <今週の本棚・次回の予定>6月8日の毎日新聞書評欄は『新装版 ペルーからきた私の娘』ほか
    2024-06-03

    「2億円トイレ」のイメージ図など公開 大阪・関西万博
    2024-06-04

    本年入試私立公立とも志願者微減 栄光ゼミナール担当者にきく 埼玉中高入試最新動向
    2024-06-04

    「君たちはどう生きるか」展 第二部 レイアウト編(三鷹の森ジブリ美術館)レポート。絵を描くことの営為、そして苦悩も見せる
    2024-06-04

    「CLAMP展」が国立新美術館で7月より開催。展示数は史上最多の約800点
    2024-06-04

    GROUP「島をつくる | Planning Another Island」(マイナビアートスクエア)開幕レポート。高層ビルのなかで建築をコンポストする
    2024-06-05

    「TRIO パリ・東京・大阪 モダンアート・コレクション」(東京国立近代美術館)開幕レポート。トリオで再発見する3館のコレクション
    2024-06-05

    石川九楊の個展「石川九楊大全」が上野の森美術館で2ヶ月連続開催へ
    2024-06-05

    五木ひろし歌手生活60年…ふるさと福井へ恩返しの新曲
    2024-06-04

    口腔ケアで高齢者を守ろう 「おとなの歯磨き」訪問歯科医が出版
    2024-06-04

    スマイル社が性犯罪被害者支援の法人設立
    2024-06-04

    古今東西 かしゆか商店【つづら】
    2024-06-05

    ご当地体操「いちょう体操」に小学生の指導委員が誕生 「体がのびやかに動く」
    2024-06-06

    なぜ、いま「先住民の現代アート」なのか? 『美術手帖』2024年7月号は、「先住民の現代アート」特集
    2024-06-06

    ©  Dopu Box
    💛