プログラミング
 Computer >> コンピューター >  >> プログラミング >> プログラミング

マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

はじめに

重要な Linux コマンドに関するこの包括的なガイドを使用して、Linux システムの可能性を最大限に引き出します。熟練した管理者であっても、管理を始めたばかりであっても、効率的なサーバー管理、スクリプト作成、トラブルシューティングを行うには、これらのコマンドを習得することが重要です。このチュートリアルでは、ファイル管理、プロセス制御、ユーザー アクセス、ネットワーク構成、システム デバッグのために最も頻繁に使用される強力なコマンドを学習します。

50 以上の必須の Linux コマンドを学習します。 これにより、あなたは Linux のパワー ユーザーに変身します。基本的なものから高度なものまで、これらのコマンドは、あらゆるタスクに取り組むための頼りになるツールになります。

重要なポイント

  • Linux コマンドは目的別に編成されています:ファイル管理 (ls) 、cpmvrm )、プロセス制御 (ps) 、killtop )、ユーザー権限 (chmod) 、chownsudo )、ネットワーク (ssh) 、pingwget ).
  • man command は、あらゆる Linux コマンドの組み込みドキュメントを提供し、構文やオプションの詳細が必要な場合の主なリファレンスとなります。
  • grep を使用します テキスト出力またはファイルを検索するには、head /tail ファイルの内容をプレビューするには、diff /cmp ファイルを比較するため。
  • ファイルのアクセス許可は chmod で管理されます (モードビット変更) および chown (所有者の変更)。これはサーバーのセキュリティとアクセス制御にとって重要です。
  • tar のようなコマンド 、zip 、および unzip アーカイブと圧縮を処理します。 ssh および scp 安全なリモート アクセスとファイル転送を処理する
  • プロセス管理コマンド (ps) 、killkillalltop )は、システムの健全性を監視し、応答しないプロセスを終了するために不可欠です。

前提条件

これらのコマンドは Ubuntu サーバーで実行しますが、最新の Linux ディストリビューションでも同様に実行できます。 Ubuntu での初期サーバー セットアップに関するガイドに従って、このチュートリアル用に Ubuntu サーバーをセットアップできます。

DigitalOcean アプリ プラットフォームを使用して、GitHub からフロントエンド アプリケーションをデプロイします。 DigitalOcean はアプリのスケーリングに集中しましょう。

では早速始めましょう!

一般ユーザーとして知っておくべき Linux コマンド トップ 50

<オル>
  • ls - Linux でディレクトリを一覧表示するために最も頻繁に使用されるコマンド
  • パスワード - Linux での作業ディレクトリの印刷コマンド
  • CD - ディレクトリ内を移動するための Linux コマンド
  • mkdir - Linux でディレクトリを作成するために使用されるコマンド
  • MV - Linux でファイルを移動または名前変更する
  • CP - mv と同様の使用法ですが、Linux でファイルをコピーする場合
  • rm - ファイルまたはディレクトリを削除する
  • タッチ - 空のファイルを作成する
  • ln - 他のファイルへのシンボリック リンク (ショートカット) を作成する
  • クリア - 端末の表示をクリアする
  • - ファイルの内容を端末に表示します
  • エコー - コマンドに続くテキストを出力します
  • 少ない - ターミナルにページングされた出力を表示する Linux コマンド
  • 男性 - すべての Linux コマンドのマニュアル ページにアクセスする
  • 名前 - OS に関する基本情報を取得する Linux コマンド
  • おっと - アクティブなユーザー名を取得する
  • タール - Linux でファイルを抽出および圧縮するコマンド
  • grep - 出力内の文字列を検索
  • - 先頭から指定された行数を返します
  • 尻尾 - 指定された行数を下から返します
  • 差分 - 2 つのファイルの違いを見つける
  • センチメートル - 2 つのファイルが同一かどうかを確認できます
  • コミュニケーション - diff と cmp の機能を組み合わせます
  • 並べ替え - 出力中にファイルの内容を並べ替える Linux コマンド
  • エクスポート - Linux で環境変数をエクスポートする
  • ジップ - Linux での ZIP ファイル
  • 解凍 - Linux でファイルを解凍する
  • ssh - Linux の Secure Shell コマンド
  • サービス - サービスを開始および停止するための Linux コマンド
  • 追記 - アクティブなプロセスを表示
  • キルアンドキルオール - プロセス ID または名前によってアクティブなプロセスを強制終了します
  • DF - ディスクファイルシステム情報を表示する
  • マウント - Linux でファイル システムをマウントする
  • chmod - ファイルのパーミッションを変更するコマンド
  • チャウン - ファイルまたはフォルダーの所有権を付与するコマンド
  • ifconfig - ネットワーク インターフェイスと IP アドレスを表示する
  • トレースルート - 宛先に到達するためにすべてのネットワーク ホップをトレースします
  • ウィゲット - インターネットからファイルを直接ダウンロード
  • うわ - ファイアウォール コマンド
  • iptables - 他のすべてのファイアウォール ユーティリティが接続するベース ファイアウォール
  • apt、パックマン、yum、rpm - ディストリビューションに応じたパッケージマネージャー
  • sudo - Linux で権限を昇格するコマンド
  • カロリー - コマンドラインカレンダーを表示する
  • エイリアス - 定期的に使用するコマンドのカスタム ショートカットを作成する
  • dd - 主に起動可能な USB スティックの作成に使用されます
  • どこにあります - コマンドのバイナリ、ソース、マニュアル ページを見つける
  • とは - コマンドの使用目的を確認する
  • トップ - アクティブなプロセスとそのシステム使用状況をライブで表示
  • useradd と usermod - 新しいユーザーを追加するか、既存のユーザー データを変更します
  • パスワード - 既存ユーザーのパスワードを作成または更新する
  • ファイルおよびディレクトリのコマンド

    コマンド 説明 例 lsList ディレクトリの内容。ls cdChange ディレクトリ。cd /path/to/directory pwd現在のディレクトリを表示します。pwd mkdir新しいディレクトリを作成します。mkdir new_directory rmdir空のディレクトリを削除します。rmdir empty_directory rmファイルまたはディレクトリを削除します。rm file.txt touch空のファイルを作成します。touch new_file.txt cpCopy ファイルまたはディレクトリ。cp file.txt /path/to/destination mvファイルの移動または名前変更。mv file.txt /path/to/new_location catDisplay ファイルの内容。cat file.txt nano / vimターミナルでファイルを編集します。nano file.txt findディレクトリ階層内のファイルを検索します。find . -name "file.txt" grepパターンを使用してテキストを検索します。grep "pattern" file.txt tarArchive とファイルの圧縮。tar -cvf archive.tar file1.txt file2.txt dfファイル システムのディスク使用量を表示します。df duShow ディレクトリ/ファイル サイズ。du -sh /path/to/directory chmodファイルのアクセス許可を変更します。chmod 755 file.txt chownファイルの所有者を変更します。chown user:group file.txt mount ファイルシステムをマウントします。mount /dev/sdb1 /mnt umount ファイルシステムをアンマウントします。umount /mnt

    ネットワーク コマンド

    コマンド 説明 使用例 ホストへの接続を pingTest します。ping google.com ifconfig / ip aネットワーク インターフェイスを表示します。ifconfig または ip a netstat / ssネットワーク接続を表示します。netstat -tuln または ss -tuln wgetHTTP/FTP 経由でファイルをダウンロードします。wget http://example.com/file.zip curl URL 構文を使用してデータを転送します。curl -O http://example.com/file.zip nc (Netcat) ネットワークのデバッグとデータ転送。nc -zv 192.168.1.1 80 tcpdumpネットワーク パケットをキャプチャして分析します。tcpdump -i eth0 iptablesファイアウォール ルールを構成します。iptables -A INPUT -p tcp --dport 22 -j ACCEPT トレースルートパケットがネットワーク ホストまでたどるパスをトレースします。traceroute example.com nslookupDNS をクエリして、ドメイン名または IP アドレスのマッピングを取得します。nslookup example.com sshリモート ホストに安全に接続します。ssh user@example.com

    プロセスおよびシステム監視コマンド

    コマンド 説明 コマンド例 ps実行中のプロセスを表示します。ps aux topDynamic プロセス ビューア。top htoptop.htop の拡張バージョン kill プロセスにシグナルを送信します。kill <PID> killallKill プロセスを名前で指定します。killall <process_name> uptimeシステムの稼働時間と負荷。uptime whoami現在ログインしているユーザー。whoami envDisplay 環境変数。env straceTrace プロセスのシステム コール。strace -p <PID> systemctlsystemd サービスを管理します。systemctl status <service_name> journalctlシステム ログを表示します。journalctl -xe freeDisplay のメモリ使用量。free -h vmstat仮想メモリ統計を報告します。vmstat 1 iostat CPU と I/O の統計を報告します。iostat lsofList はプロセスごとにファイルを開きます。lsof dmesgカーネル リング バッファ メッセージを印刷します。dmesg

    ユーザーおよび権限の管理コマンド

    コマンド 説明 コマンド例 passwdユーザーのパスワードを変更します。passwd <username> adduser / useradd新しいユーザーを追加します。adduser <username> または useradd <username> deluser / userdelユーザーを削除します。deluser <username> または userdel <username> usermodユーザー アカウントを変更します。usermod -aG <group> <username> groupsグループのメンバーシップを表示します。groups <username> sudo root.sudo <command> としてコマンドを実行します。 chageユーザーパスワードの有効期限情報を変更します。chage -l <username> idユーザー ID 情報を表示します。id <username> newgrp新しいグループにログインします。newgrp <group>

    ファイル転送および同期コマンド

    コマンド 説明 コマンド例 scpSSH 経由でファイルを安全にコピーします。scp user@remote:/path/to/file /local/destination rsync ファイルとディレクトリを効率的に同期します。rsync -avz /local/directory/ user@remote:/path/to/destination ftpファイル転送プロトコルを使用してファイルを転送します。ftp ftp.example.com sftpSSH ファイル転送プロトコルを使用してファイルを安全に転送します。sftp user@remote:/path/to/file wgetWeb からファイルをダウンロードします。wget http://example.com/file.zip curlサーバーとの間でデータを転送します。curl -O http://example.com/file.zip

    テキスト処理コマンド

    コマンド 説明 コマンド例 awkPattern のスキャンと処理。awk '{print $1}' file.txt テキストのフィルタリング/変更用の sedStream エディタ。sed 's/old/new/g' file.txt Cutテキスト行からセクションを削除します。cut -d':' -f1 /etc/passwd sortテキスト行を並べ替えます。sort file.txt grepテキスト内のパターンを検索します。grep 'pattern' file.txt wc単語、行、文字をカウントします。wc -l file.txt ペーストファイルの行を結合します。paste file1.txt file2.txt join 共通フィールド上の 2 つのファイルの行を結合します。join file1.txt file2.txt headファイルの最初の部分を出力します。head -n 10 file.txt tailファイルの最後の部分を出力します。tail -n 10 file.txt

    シェル ユーティリティとショートカット コマンド

    コマンド 説明 コマンド例 aliasコマンドのショートカットを作成します。alias ll='ls -la' unaliasエイリアスを削除します。unalias ll 履歴以前に入力したコマンドを表示します。history clearターミナル画面をクリアします。clear rebootシステムを再起動します。reboot shutdownシステムの電源を切ります。shutdown now dateシステムの日付と時刻を表示または設定します。date echoテキスト行を表示します。echo "Hello, World!" 指定された時間の sleepDelay。sleep 5 timeコマンドの実行時間を測定します。time ls watchプログラムを定期的に実行し、出力を全画面表示します。watch -n 5 df -h

    ここで、これらの各コマンドをもう少し深く掘り下げて、さらに詳しく理解しましょう。これらの個々のコマンドについては、すでに多数の既存の記事があります。便宜上、既存のすべての記事へのリンクを追加し、新しいトピックが取り上げられたら記事を更新し続けます。

    ls Linux のコマンド

    ls コマンドは、現在の作業ディレクトリ内のファイルとディレクトリを一覧表示するために使用されます。これは、最も頻繁に使用される Linux コマンドの 1 つであるため、必ず知っておく必要があります。

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    上の画像からわかるように、引数を指定せずにコマンドを単独で使用すると、ディレクトリ内のすべてのファイルとディレクトリを含む出力が得られます。このコマンドは、出力内のデータの表示に関して非常に柔軟です。

    ls の使用方法について詳しくは、こちらをご覧ください。 コマンド

    コマンド リストに戻る ↑

    pwd Linux のコマンド

    pwd コマンドを使用すると、端末上の現在の作業ディレクトリを出力できます。これは非常に基本的なコマンドであり、その目的をうまく解決します。

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    通常、ターミナル プロンプトには完全なディレクトリが含まれているはずです。しかし、そうでない場合に備えて、これは、現在のディレクトリを確認するための簡単なコマンドになります。このコマンドのもう 1 つの用途は、スクリプトを作成する場合であり、このコマンドを使用して、スクリプトが保存されているディレクトリを見つけることができます。

    コマンド リストに戻る ↑

    cd Linux のコマンド

    ターミナル内で作業している間、ディレクトリ内を移動することはほぼ必要です。 cd コマンドは、知っておくべき重要な Linux コマンドの 1 つであり、ディレクトリ間の移動に役立ちます。 cd と入力してください。 以下に示すように、その後にディレクトリが続きます。

    root@ubuntu:~# cd <directory path>
    

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    上記のコマンドでわかるように、単に cd /etc/ と入力しただけです。 /etc ディレクトリに移動します。 pwd を使用しました。 現在の作業ディレクトリを出力するコマンド。

    コマンド リストに戻る ↑

    mkdir Linux のコマンド

    mkdir コマンドを使用すると、ターミナル内からディレクトリを作成できます。

    root@ubuntu:~# mkdir <folder name>
    

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    上のスクリーンショットでわかるように、この簡単なコマンドだけで新しいディレクトリを作成しました。

    コマンド リストに戻る ↑

    cp および mv コマンド

    cp および mv コマンドは、Windows のコピー&ペーストおよびカット&ペーストのコマンドと同等です。ただし、Linux には実際にはファイル名を変更するコマンドがないため、mv も使用します。 ファイルとフォルダの名前を変更するコマンド。

    root@ubuntu:~# cp <source> <destination>
    

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    上記のコマンドでは、Sample という名前のファイルのコピーを作成しました。 mv を使用するとどうなるかを見てみましょう。

    root@ubuntu:~# mv <source> <destination>
    

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    上記の場合、同じディレクトリ内でファイルを移動していたので、名前変更として機能しました。ファイル名が変更されました。

    コマンド リストに戻る ↑

    rm Linux のコマンド

    前のセクションでは、Sample-Copy ファイルを削除しました。 rm コマンドはファイルとフォルダの削除に使用され、知っておくべき重要な Linux コマンドの 1 つです。

    root@ubuntu:~# rm <file name>
    

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    ディレクトリを削除するには、-r を追加する必要があります。 それに対する反論。 -r を使用しない場合 引数、rm このコマンドはディレクトリを削除しません。

    root@ubuntu:~# rm -r <folder/directory name>
    

    -r rm のフラグ Linux のコマンドは「再帰的」を表します。 ”。 rm と一緒に使用する場合 このコマンドを実行すると、指定されたファイルだけでなく、そのすべてのサブディレクトリとそれらのサブディレクトリ内のファイルも再帰的に削除されます。

    注: rm を使用する場合は注意が必要です。 -r を使用したコマンド フラグを使用すると、多数のファイルとディレクトリを迅速かつ永久に削除できるためです。 -i を使用することをお勧めします。 -r と組み合わせたフラグ フラグを設定すると、各ファイルとディレクトリを削除する前に確認を求められます。

    たとえば、mydir を削除するには ディレクトリとその内容を確認するには、次のコマンドを使用できます。

    root@ubuntu:~# rm -ri mydir
    

    mydir 内の各ファイルとディレクトリを削除する前に、確認を求めるメッセージが表示されます。 ディレクトリ。

    コマンド リストに戻る ↑

    touch Linux のコマンド

    touch Linux のコマンドは、空のファイルを作成するか、既存のファイルのタイムスタンプを更新します。

    root@ubuntu:~# touch <file name>
    

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    コマンド リストに戻る ↑

    ln Linux のコマンド

    別のファイルへのリンクを作成するには、ln を使用します。 コマンド。これは、Linux 管理者として働く予定がある場合に知っておくべき、最も重要な Linux コマンドの 1 つです。

    root@ubuntu:~# ln -s <source path> <link name>
    

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    -s flag はシンボリック リンクを作成します (シンボリックリンクまたはソフトリンクとも呼ばれます) ファイルまたはディレクトリへのリンク。シンボリック リンクは、別のファイルまたはディレクトリへのショートカットまたはポインタとして機能する特別なタイプのファイルです。

    デフォルトでは、ln コマンドはハードリンクを作成します シンボリック リンクやソフト リンクの代わりに。

    注: テキスト ファイルがあるとします。 シンボリックリンクを作成する場合 そのファイルへのリンクは、元のファイルへのポインタにすぎません。元のファイルを削除すると、参照するものがなくなるため、リンクは壊れます。

    ハードリンク は、まったく同じ内容を持つ元のファイルのミラー コピーです。シンボリック リンクと同様、元のファイルの内容を編集すると、その変更がハード リンクに反映されます。ただし、元のファイルを削除しても、ハード リンクは引き続き機能し、元のファイルの通常のコピーと同じように表示および編集できます。

    ソフト リンクとハード リンクについて詳しくは、こちらをご覧ください。

    コマンド リストに戻る ↑

    clear Linux のコマンド

    clear Linux のコマンドはターミナル画面をクリアします。現在ターミナルに表示されているすべてのテキストと出力が削除され、白紙の状態で作業できるようになります。

    clear の使用例を次に示します。 コマンド:

    root@ubuntu:~# clear
    

    これにより、端末画面がクリアされ、カーソルが画面の左上隅に移動します。

    clear を使用することもできます。 次のように、コマンドを他のコマンドと組み合わせて使用します。

    root@ubuntu:~# ls -l; clear
    

    これにより、現在のディレクトリ内のファイルとディレクトリが一覧表示され、端末画面が消去されます。

    注: clear このコマンドはシステムからファイルやデータを削除しません。端末の表示にのみ影響します。

    catecho 、および less コマンド

    ファイルの内容を出力したり、端末出力に何かを出力したりする場合は、cat を使用します。 または echo コマンド。基本的な使い方を見てみましょう。

    root@ubuntu:~# cat <file name>
    root@ubuntu:~# echo <Text to print on terminal>
    

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    上の例でわかるように、cat コマンド、New-File で使用する場合 、ファイルの内容を出力します。同時に、echo を使用すると、 コマンドの場合、コマンドの後に続くものを単に出力するだけです。

    less コマンドは、コマンドによって出力される出力が画面スペースより大きく、スクロールが必要な場合に使用されます。 less このコマンドを使用すると、ユーザーは出力を分割し、Enter キーまたはスペース キーを使用してスクロールできます。

    これを行う簡単な方法は、パイプ演算子 (|) を使用することです。 ).

    root@ubuntu:~# cat /boot/grub/grub.cfg | less
    

    注: -S を使用します。 less を含むフラグ 行の折り返しを有効にします。これにより、水平方向にスクロールせずに長い行のテキストを表示できるようになります。

    -N を使用します。 less を含むフラグ 行番号を表示します。これは、テキストの特定の部分の行番号を知る必要がある場合に役立ちます。

    これらの便利なフラグは次の方法で使用できます。

    root@ubuntu:~# cat /boot/grub/grub.cfg | less -SN
    

    less を使用する パイプ演算子を使用すると、さまざまな状況で役立ちます。以下にいくつかの例を示します。

    • top などの長時間実行コマンドの出力の表示 または htop .
    • コマンドの出力内の特定のテキスト(grep など)の検索 または cat .

    コマンド リストに戻る ↑

    man Linux のコマンド

    man コマンドは、知っておくべき非常に便利な Linux コマンドです。 Linux を使用する場合、ダウンロードするパッケージには多くの機能が含まれる場合があります。すべてを知ることは不可能です。

    man Linux のコマンドは、特定のコマンドのマニュアル ページを表示するために使用されます。構文、オプション、例など、コマンドに関する詳細情報が提供されます。

    man の使用例を次に示します。 コマンド:

    <オル>
  • ターミナルを開き、「man ls」と入力します。 ls のマニュアル ページを表示するには コマンド。
  • root@ubuntu:~# man ls
    

    これにより、次のようなページが表示されます。

    LS(1) User Commands LS(1)
    NAME
     ls - list directory contents
    SYNOPSIS
     ls [OPTION]... [FILE]...
    DESCRIPTION
     List information about the FILEs (the current directory by default).
     Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
     Mandatory arguments to long options are mandatory for short options too.
     -a, --all
     do not ignore entries starting with .
     -A, --almost-all
     do not list implied . and ..
     -c with -lt: sort by, and show, ctime (time of last modification
     of file status information) with -l: show ctime and sort
     by name; 
    ...
    

    コマンド リストに戻る ↑

    unamewhoami コマンド

    unamewhoami コマンドを使用すると、複数のシステムで作業するときに役立ついくつかの基本情報にアクセスできます。

    uname Linux のコマンドは、カーネル名、ホスト名、カーネル リリース、カーネル バージョン、マシン ハードウェア名など、システムのカーネルに関する情報を表示します。

    whoami Linux のコマンドは現在のユーザーのユーザー名を返します。それは「私は誰ですか?」の略です。また、シェル スクリプトやターミナルで現在のユーザーの ID を確認するためによく使用されます。

    両方のコマンドの出力と、それらの使用方法を見てみましょう。

    root@ubuntu:~# uname -a
    

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    パラメータ -a uname を使用 コマンドは「すべて」を表します。これにより、完全な情報が出力されます。パラメータが追加されていない場合、出力として得られるのは「Linux」だけです。

    注: uname で使用できるいくつかの重要なフラグ コマンド。

    <オル>
  • uname -s を使用します カーネル名を表示します。
  • uname -n を使用します
  • ホスト名を表示します。
  • uname -r を使用します カーネルのリリースを表示します。
  • uname -v を使用します カーネルのバージョンを表示します。
  • uname -m を使用します マシンのハードウェア名を表示します。
  • コマンド リストに戻る ↑

    tarzipunzip コマンド

    tar Linux のコマンドは、アーカイブ ファイルの作成と抽出に使用されます。 tar を使用して、複数の異なるアーカイブ ファイルを抽出できます。 コマンド。

    アーカイブを作成するには、-c を使用します。 パラメータを使用し、アーカイブを抽出するには -x を使用します。 パラメータ。それがどのように機能するかを見てみましょう。

    #Compress
    root@ubuntu:~# tar -cvf <archive name> <files separated by space>
    #Extract
    root@ubuntu:~# tar -xvf <archive name>
    

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    最初の行では、Compress.tar という名前のアーカイブを作成しました。 New-File と New-File-Link を使用します。次のコマンドでは、これらのファイルをアーカイブから抽出しました。

    zip について話し合いましょう と unzip コマンド。どちらも非常に単純です。パラメーターなしで使用することもでき、意図したとおりに機能します。以下に例を見てみましょう。

    root@ubuntu:~# zip <archive name> <file names separated by space>
    root@ubuntu:~# unzip <archive name>
    

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    これらのファイルは同じディレクトリにすでに存在するため、unzip これらのファイルを上書きする前に、コマンドでプロンプトが表示されます。

    コマンド リストに戻る ↑

    grep Linux のコマンド

    grep command は、Linux および Unix ベースのオペレーティング システムで使用できる強力で多用途のテキスト検索ツールです。 1 つ以上のファイル内の特定のパターンまたは文字列を検索し、他のコマンドの出力をフィルタリングできます。

    grep コマンドは「グローバル正規表現印刷」の略で、複数の行やファイルにわたって正規表現を検索できる機能を反映しています。

    root@ubuntu:~# <Any command with output> | grep "<string to find>"
    

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    これはコマンドの簡単なデモンストレーションでした。 grep コマンドの詳細については、こちらをご覧ください。

    コマンド リストに戻る ↑

    headtail コマンド

    大きなファイルを出力する場合、head および tail コマンドは便利です。これらのコマンドは、それぞれファイルの先頭または末尾を表示します。これらは通常、ファイルをテキスト エディタで開かずにファイルの内容をすばやく表示するために使用されます。

    head および tail コマンドはデフォルトでファイルの最初の 10 行を表示します。別の行数を表示するには、-n を使用します。 オプションの後に、表示する行数を続けます。

    head の使用例を次に示します。 および tail コマンド:

    root@ubuntu:~# head <file name>
    root@ubuntu:~# tail <file name>
    

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    ご覧のとおり、head コマンドはファイルの先頭から 10 行を表示しました。

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    tail コマンドは、ファイルの下部 10 行を出力しました。

    これらのコマンドを使用すると、ファイルの内容をすばやく表示したり、トラブルシューティングの問題についてリアルタイムの更新を監視したり、他のコマンドからの出力をフィルタリングしたり、ログ分析を実行したりできます。

    コマンド リストに戻る ↑

    diffcomm 、および cmp コマンド

    diffcomm 、および cmp コマンドはすべて、Linux および Unix ベースのオペレーティング システムでファイルを比較するために使用されます。これらのコマンドを使用して、2 つのファイル間の相違点を特定し、変更をマージし、その他のファイル比較タスクを実行できます。

    root@ubuntu:~# diff <file 1> <file 2>
    

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    上で見られるように、「この行は編集されています」という小さなテキストを新規ファイル編集ファイルに追加しました。

    cmp コマンドは 2 つのファイルを比較し、それらの間で異なる最初のバイトを表示するために使用されます。これは、バイナリ ファイル間の違いを特定したり、ファイルの破損をチェックしたりするために使用できます。

    root@ubuntu:~# cmp <file 1> <file 2>
    

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    cmp このコマンドでは行番号のみが示されますが、これは異なります。実際のテキストではありません。

    comm このコマンドは、並べ替えられた 2 つのファイルを比較し、各ファイルに固有の行と、両方のファイルに共通する行を表示するために使用されます。

    root@ubuntu:~# comm <file 1> <file2>
    

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    左揃えのテキストは file 1 にのみ存在します。 。中央揃えのテキストは file 2 にのみ存在します。 。そして、右揃えのテキストが両方のファイルに存在します。

    見たところ、comm このコマンドは、大きなファイルを比較しようとしていて、すべてをまとめて確認したい場合に最も合理的です。

    これら 3 つのコマンドはすべて、Linux および Unix ベースのオペレーティング システムでファイルを操作するために不可欠なツールです。 diff の使用方法を理解することで、 、comm 、および cmp コマンドを効果的に使用すると、ファイル間の違いを特定したり、変更をマージしたり、その他のファイル比較タスクを実行したりできます。

    これらのコマンドは、ファイルの問題を特定して解決するだけでなく、変更を追跡し、バージョン管理を維持するのにも役立ちます。開発者であってもシステム管理者であっても、これらのコマンドはツールキットの重要な部分です。

    コマンド リストに戻る ↑

    sort Linux のコマンド

    sort コマンドは、Linux および Unix ベースのオペレーティング システムでテキスト ファイルまたは標準入力内の行を並べ替えるのに使用されます。これを使用して、行を昇順または降順に並べ替えたり、フィールドによる並べ替えやカスタム並べ替え順序の使用などの他の並べ替え操作を実行したりできます。

    sort の基本構文 コマンドは次のとおりです:

    root@ubuntu:~# sort <filename>
    

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    デフォルトでは、sort コマンドは行をASCII 照合順序で並べ替えます。 これにより、数値や特殊文字を並べ替える際に予期しない結果が生じる可能性があります。数値を番号順に並べ替えるには、-n を使用できます。 オプション。

    -n の使用例を次に示します。 オプション:

    root@ubuntu:~# sort -n file.txt
    

    上記のコマンドは、file.txt の行を並べ替えます。 番号順。

    sort -k を使用して、このコマンドを使用して特定のフィールドに基づいて行を並べ替えることもできます。 オプション。

    -k の使用例を次に示します。 オプション:

    root@ubuntu:~# sort -k 2 file.txt
    

    このコマンドは、file.txt の行を並べ替えます。 2 番目のフィールドに基づきます。

    sort command は、Linux および Unix ベースのオペレーティング システムでテキスト ファイルを操作するための強力で柔軟なツールです。 sort の使用方法を理解することで コマンドを効果的に使用すると、テキスト ファイル内の行を並べ替えたり、特定のフィールドに基づいて行を並べ替えたり、その他の並べ替え操作を実行したりできます。

    これらのコマンドは、データの整理と分析、その他のファイル操作タスクの実行に役立ちます。開発者であってもシステム管理者であっても、sort コマンドはツールキットの重要な部分です。

    コマンド リストに戻る ↑

    export Linux のコマンド

    export Linux および Unix ベースのオペレーティング システムのコマンドは、環境変数を設定するために使用されます。環境変数は、プロセスまたはコマンドで使用できる情報を保存するために使用されます。

    環境変数が設定されると、同じシェル内で実行されている任意のプロセスまたはコマンドから環境変数にアクセスできるようになります。

    環境変数は、構成設定、ユーザー設定、システム情報など、幅広い情報を保存するために使用できます。

    export の使用例を次に示します。 コマンド:

    root@ubuntu:~# export <variable name>=<value>
    

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    export の詳細をご覧ください。 コマンド

    コマンド リストに戻る ↑

    ssh Linux のコマンド

    ssh Linux および Unix ベースのオペレーティング システムのコマンドは、リモート サーバーへのセキュア シェル接続を確立します。このコマンドは、ローカル サーバーとリモート サーバーの間に安全な暗号化された接続を提供し、ユーザーがコマンドを実行してファイルを安全に転送できるようにします。

    ssh の基本構文 コマンドは次のとおりです:

    root@ubuntu:~ ssh username@remote-server
    

    このコマンドは ssh を確立します。 remote-server への接続 username を使用する アカウント。

    ssh このコマンドは、次のような幅広いオプションと構成をサポートしています。

    • 認証方法(パスワード、公開キーなど)の構成
    • 暗号化アルゴリズムの構成
    • Configuring compression
    • Configuring port forwarding
    • Configuring X11 forwarding
    • Configuring SSH keys

    The service command in Linux

    The service command in Linux is used to manage system services, which are long-running processes that are started at boot time and run in the background. These services are responsible for providing various system functionalities, such as networking, database management, and user authentication.

    The service command is used to start, stop, restart, and check the status of these services. It is a front-end to the systemctl command, which is used to manage the systemd service manager.

    The basic syntax of the command is as below.

    root@ubuntu:~ service ssh status
    root@ubuntu:~ service ssh stop
    root@ubuntu:~ service ssh start 
    

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    As you can see in the image, the ssh server is running on our system.

    Jump back to commands list ↑

    The ps , kill , and killall commands

    The ps , kill , and killall commands are all used to manage processes in Linux.

    The ps command is used to display information about the current running processes on the system. Here are some examples of using the ps command:

    Display a list of all running processes:

    root@ubuntu:~ ps -ef
    

    Display a list of all processes for a specific process ID (PID):

    root@ubuntu:~ ps -p PID
    

    Let’s see all of this in action:

    root@ubuntu:~ ps 
    root@ubuntu:~ kill <process ID>
    root@ubuntu:~ killall <process name>
    

    For demonstration purposes, we will create a shell script with an infinite loop and will run it in the background.

    With the use of the & symbol, we can pass a process into the background. As you can see, a new bash process with PID 14490 is created.

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    Now, to kill a process with the kill command, you can type kill followed by the PID(Process Id) of the process.

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    But if you do not know the process ID and just want to kill the process with the name, you can make use of the killall command.

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    You will notice that PID 14490 stayed active. That is because, both times, we killed the sleep process.

    Learn more about the ps command and the kill コマンド。

    Jump back to commands list ↑

    The df and mount commands

    When working with Linux, the df and mount commands are very efficient utilities to mount filesystems and get details of the file system.

    The df command is used to display the amount of disk space used and available on the file systems, and the mount command is used to mount a file system or device to a specific directory.

    When we say mount , it means that we’ll connect the device to a folder so we can access the files from our filesystem. The default syntax to mount a filesystem is below:

    root@ubuntu:~ mount /dev/cdrom /mnt
    root@ubuntu:~ df -h
    

    In the above case, /dev/cdrom is the device that needs to be mounted. Usually, a mountable device is found inside the /dev folder. mnt is the destination folder to which to mount the device. You can change it to any folder you want, but we have used /mnt as it’s the system’s default folder for mounting devices.

    To see the mounted devices and get more information about them, we use the df command. Just typing df will give us the data in bytes, which is not readable. So, we’ll use the -h parameter to make the data human-readable.

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    Jump back to commands list ↑

    The chmod and chown commands

    The chmod and chown commands are used to modify file permissions and ownership in Linux.

    The chmod command is used to change the permissions of a file or directory, and the chown command is used to change the ownership of a file or directory

    The default syntax for both the commands is chmod <parameter> filename and chown <user:group> filename

    root@ubuntu:~ chmod +x loop.sh
    root@ubuntu:~ chmod root:root loop.sh
    

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    In the above example, we’re adding executable permissions to the loop.sh file with the chmod command. In addition, with the chown command, we’ve made it accessible only to the root user and users within the root group.

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    As you will notice, the root root part is now changed to www-data which is the new user who has full file ownership.

    Learn more about the Linux file Permissions and using the chmod コマンド。

    Jump back to commands list ↑

    The ifconfig and traceroute commands

    The ifconfig and traceroute commands manage network interfaces and trace the route of network packets in Linux.

    The ifconfig command will give you the list of all the network interfaces along with the IP addresses, MAC addresses and other information about the interface.

    root@ubuntu:~ ifconfig
    

    There are multiple parameters that can be used, but we’ll work with the basic command here.

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    The traceroute command is used to trace the route of network packets and determine the path they take to reach a specific destination.

    When working with traceroute , you can simply specify the IP address, hostname, or domain name of the endpoint.

    root@ubuntu:~ traceroute <destination address>
    

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    Now, obviously, localhost is just one hop (the network interface itself). You can try this same command with any other domain name or IP address to see all the routers your data packets pass through to reach the destination.

    Jump back to commands list ↑

    The wget command in Linux

    If you want to download a file from within the terminal, the wget command is one of the handiest command-line utilities available. It is one of the important Linux commands you should know when working with source files.

    When you specify the link for download, it has to directly be a link to the file. If the file cannot be accessed by the wget command, it will simply download the webpage in HTML format instead of the actual file that you wanted.

    Let’s try an example. The basic syntax of the wget command is :

    root@ubuntu:~ wget <link to file>
    

    Or,

    root@ubuntu:~ wget -c <link to file>
    

    The -c argument allows us to resume an interrupted download.

    Jump back to commands list ↑

    The ufw and iptables commands

    The ufw and iptables commands are used to manage firewalls in Linux.

    UFW and IPTables are firewall interfaces for the Linux Kernel’s netfilter firewall. IPTables directly passes firewall rules to Netfilter while UFW configures the rules in IPTables, which then sends those rules to Netfilter.

    Why do we need UFW when we have IPTables? Because IPTables is pretty difficult for a newbie. UFW makes things extremely easy. See the below example where we are trying to allow port 80 for our webserver.

    root@ubuntu:~# iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
    root@ubuntu:~# ufw allow 80
    

    I’m sure you now know why UFW was created! Look at how easy the syntax becomes. Both these firewalls are very comprehensive and can allow you to create any kind of configuration required for your network. Learn at least the basics of UFW or IPTables firewall, as these are the Linux commands you must know.

    Learn more about managing firewall with ufw and managing firewall with iptables .

    Jump back to commands list ↑

    Package Managers in Linux

    Different Linux distributions use different package managers. Since we’re working on a Ubuntu server, we have the apt package manager. But for someone working on a Fedora, Red Hat, Arch, or Centos machine, the package manager will be different.

    Below are the commands on how to use these package managers on different Linux distributions.

    • Debian and Debian-based distros - apt install <package name>
    • Arch and Arch-based distros - pacman -S <package name>
    • Red Hat and Red Hat-based distros - yum install <package name>
    • Fedora and CentOS - yum install <package>

    Getting yourself well versed with the package manager of your distribution will make things much easier for you in the long run. So even if you have a GUI based package management tool installed, try an make use of the CLI based tool before you move on to the GUI utility. Add these to your list of Linux commands you must know.

    Jump back to commands list ↑

    The sudo command in Linux

    “With great power, comes great responsibility” _

    This is the quote displayed when a sudo-enabled user(sudoer) first uses the sudo command to escalate privileges. This command is equivalent to logging in as root (based on what permissions you have as a sudoer).

    non-root-user@ubuntu:~# sudo <command you want to run>
    Password: 
    

    Just add the command sudo before any command that you need to run with escalated privileges, and that’s it. It’s very simple to use, but can also be an added security risk if a malicious user gains access to a sudoer.

    Learn more about how to create a new sudo user and how to edit sudoers file.

    Jump back to commands list ↑

    The cal command in Linux

    Have you ever wanted to view the calendar in the terminal? There apparently are people who want it to happen, and well, here it is.

    The cal command displays a well-presented calendar on the terminal. Just enter the command cal on your terminal prompt.

    root@ubuntu:~# cal
    root@ubuntu:~# cal March 2024
    

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    Although we don’t need it often, it’s a great addition! It’s an amazing option for terminal fans.

    Jump back to commands list ↑

    The alias command

    Do you have some commands that you run very frequently while using the terminal? It could be rm -r or ls -l , or it could be something longer like tar -xvzf .

    This is one of the productivity-boosting Linux commands you must know.

    If you know a command that you run very often, it’s time to create an alias .

    What’s an alias? In simple terms, it’s another name for a command that you’ve defined.

    root@ubuntu:~# alias lsl="ls -l"
    OR
    root@ubuntu:~# alias rmd="rm -r"
    

    Now, every time you enter lsl or rmd in the terminal, you’ll receive the output that you’d have received if you had used the full commands.

    The examples here are for really small commands that you can still type by hand every time. But in some situations where a command has too many arguments that you need to type, it’s best to create a shorthand version of the same.

    Jump back to commands list ↑

    The dd command in Linux

    This command was created to convert and copy files from multiple file system formats. In the current day, the command is simply used to create bootable USB for Linux but there still are some things important you can do with the command.

    The dd command in Linux is a versatile command used for low-level copying and conversion of data. It stands for “data-description” or “data definition,” and it can be used to copy and convert data between different file formats and storage devices.

    For example, if we wanted to back up the entire hard drive as is to another drive, we would use the dd コマンド。

    root@ubuntu:~# dd if=/dev/sdb of=/dev/sda
    

    The if and of arguments stand for input file and output file .

    It’s a powerful and flexible tool, but it can also be dangerous if not used carefully. Always double-check your syntax and make sure you know what the command will do before executing it.

    Jump back to commands list ↑

    The whereis and whatis commands

    The whereis and whatis commands are used in Linux to search for information about programs and files.

    The whereis command locates the binary, source, and manual pages for a specific command or program, and the whatis command displays a short description of a command or program.

    root@ubuntu:~# whereis sudo
    sudo: /usr/bin/sudo /usr/lib/sudo /usr/share/man/man8/sudo.8.gz
    

    The whatis command gives us an explanation of what a command actually is.

    root@ubuntu:~# whatis sudo
    sudo (8) - execute a command as another user
    

    Jump back to commands list ↑

    The top command in Linux

    A few sections earlier, we talked about the ps command. You observed that the ps command will output the active processes and end itself.

    The top command is like a CLI version of the task manager in Windows.

    The top command in Linux is a system monitoring tool that displays real-time information about system processes and resource usage. It provides a dynamic, real-time view of system activity, including CPU usage, memory usage, and process information.

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    注: Here are some examples of using the top command:

    • Sort processes by memory usage:
    root@ubuntu:~# top -o MEM
    

    This will sort the process list by memory usage, with the most memory-intensive processes at the top.

    • Display detailed information about a specific process:
    root@ubuntu:~# top -p PID
    

    Replace PID with the ID of the process you want to inspect.

    • Display a summary of system resource usage:
    root@ubuntu:~# top -n 1
    

    This will display a single summary screen of system resource usage.

    It’s a powerful and flexible tool for monitoring system activity and troubleshooting performance issues.

    Jump back to commands list ↑

    The useradd and usermod commands

    The useradd and usermod commands are used in Linux to manage user accounts.

    The useradd or adduser commands are the exact same commands where adduser is just a symbolic link to the useradd command. This command allows us to create a new user in Linux.

    root@ubuntu:~# useradd JournalDev -d /home/JD
    

    The above command will create a new user named JournalDev with the home directory as /home/JD .

    The usermod command, on the other hand, is used to modify existing users. You can modify any value of the user including the groups, the permissions, etc.

    For example, if you want to add more groups to the user, you can type in:

    root@ubuntu:~# usermod JournalDev -a -G sudo, audio, mysql
    

    Jump back to commands list ↑

    The passwd command in Linux

    Now that you know how to create new users, let’s also set the password for them. The passwd command lets you set the password for your own account, or if you have the permissions, set the password for other accounts.

    Here are some examples of using the passwd command:

    • Change the password for the current user:

      root@ubuntu:~# passwd
      

    This will prompt you to enter a new password for the current user.

    • Change the password for a specific user:

      root@ubuntu:~# passwd username
      

    Replace username with the name of the user whose password you want to change.

    • Force a user to change their password at the next login:

      root@ubuntu:~# passwd -f username
      
    • Set an expiration date for a user’s password:

      root@ubuntu:~# passwd -e -n days -w warndays username
      

    Replace days with the number of days before the password expires and warm days with the number of days before the password expires that the user will be warned.

    These are just a few examples of using the passwd command in Linux. By understanding how to use this command effectively, you can manage user accounts and ensure that your system is secure.

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド

    Jump back to commands list ↑

    Common Errors and Debugging

    When working with Linux commands, you may encounter various errors and issues. Here are some common problems and how to resolve them:

    1. Fixing “command not found” errors

    If you receive a command not found error, it means that the command you are trying to run is not recognized by the system. This can happen for several reasons:

    <オル>
  • The command is not installed on your system. You can install it using your package manager (e.g., apt , yum , dnf ).

    If you see:

    bash: xyz: command not found
    

    Use:

    which xyz
    

    If the command isn’t installed, try installing:

    apt-get install <package-name>
    
  • The command is not in your system’s PATH. You can add the directory containing the command to your PATH.

    export PATH=$PATH:/path/to/command
    
  • You made a typo. Double-check the command for any spelling errors.

  • 2. Resolving permission issues with sudo

    If you encounter permission issues, you can use sudo to run the command with superuser privileges.例:

    sudo command_name
    

    3. Handling File Conflicts

    File conflicts can occur when multiple users or processes attempt to modify the same file simultaneously. Here are some ways to handle file conflicts:

    <オル>
  • Use Version Control Systems (VCS): Tools like Git can help manage file conflicts by allowing users to merge changes and resolve conflicts manually.

    git merge <branch_name>
    

    If there are conflicts, Git will prompt you to resolve them. Open the conflicting files, make the necessary changes, and then commit the resolved files.

    git add <resolved_file>
    git commit -m "Resolved merge conflict"
    
  • Locking Mechanisms: Implement file locking to prevent multiple processes from writing to the same file simultaneously. Use flock in Linux to create a lock on a file.

    flock -x <file> -c "<command>"
    
  • Atomic Operations: Use atomic operations to ensure that file writes are completed in a single step, reducing the risk of conflicts.

    mv temp_file target_file
    

    Or, Use mv with -f (force) or cp with -i (interactive):

    mv -f file1 file2
    cp -i file1 file2
    
  • 4. Debugging Performance Bottlenecks

    Performance bottlenecks can significantly impact the efficiency of your system. Here are some steps to debug and resolve them:

    <オル>
  • Identify the Bottleneck: Use tools like top , htop , vmstat , and iostat to monitor system performance and identify the resource causing the bottleneck (CPU, memory, disk I/O, etc.).

    top
    
  • Analyze Logs: Check system and application logs for any errors or warnings that might indicate performance issues.

    tail -f /var/log/syslog
    
  • Optimize Code: Review and optimize your code to improve performance. Look for inefficient algorithms, unnecessary computations, and memory leaks.

  • Profile Your Application: Use profiling tools like gprof , perf , or valgrind to analyze your application’s performance and identify slow functions or memory issues.

    gprof <executable> gmon.out
    
  • Scale Resources: If the bottleneck is due to resource limitations, consider scaling up your hardware or using load balancing to distribute the load across multiple servers.

  • FAQs

    1. What are the most used Linux commands?

    The most used Linux commands include cd , ls , mkdir , rm , cp , mv , echo , cat , grep , find , man , sudo , apt-get , ssh , ping , df , du , free , top , ps , kill , killall , service , systemctl , reboot , shutdown , whoami , uname , uptime , history , and clear .

    2. How do I list all available commands in Linux?

    You can list all available commands in Linux by using the compgen -c command. This will display a list of all commands that are available on your system.

    3. How do I find a file in Linux?

    You can find a file in Linux using the find command. The basic syntax is find <path> -name "<filename>" , where <path> is the directory where you want to start searching, and <filename> is the name of the file you’re looking for. For example, find /home/user -name "example.txt" .

    4. How do I kill a process in Linux?

    You can kill a process in Linux using the kill command. First, you need to find the process ID (PID) of the process you want to kill using the ps or top command. Then, use the kill command followed by the PID. For example, kill 1234 , where 1234 is the PID of the process.

    5. What is the difference between cp and mv ?

    The cp command is used to copy files or directories, while the mv command is used to move or rename files or directories. cp creates a duplicate of the original file, leaving the original intact, whereas mv moves the file to a new location, removing it from the original location.

    6. How do I check my Linux system’s memory usage?

    You can check your Linux system’s memory usage using the free command. This command displays the total amount of free and used physical and swap memory in the system. For example, free -h will display the memory usage in a human-readable format.

    結論

    In this tutorial, you explored over 50 essential Linux commands covering file and directory management, process control, user permissions, networking, text processing, and shell utilities. You also worked through real-world examples, troubleshooting patterns, and comparisons between related commands.

    You can now navigate the Linux filesystem, manage processes, configure permissions, and troubleshoot common issues from the command line. These commands form the foundation of effective Linux system administration and scripting.

    To go deeper on specific topics, explore these tutorials:

    • The grep Command in Linux/Unix
    • The ls Command in Linux/Unix
    • Process Management in Linux
    • The ps Command in Linux
    • An Introduction to the Linux Terminal

    マスター Linux:効率的なシステム管理のための 50 以上の必須コマンド この作品は、クリエイティブ コモンズ 表示 - 非営利 - 継承 4.0 国際ライセンスに基づいてライセンスされています。


    1. 無関係な履歴のマージを拒否するGit

      gitワークフローには、エラーを引き起こす可能性のある場所がいくつかあります。この記事では、そのようなエラーの1つについて説明します。これは、対処して解決策を見つけるのに混乱を招きます。 Gitエラー fatal: refusing to merge unrelated histories gitリポジトリからプロジェクトのクローンを作成したときにエラーが発生し、その行のどこかで、その特別な.gitディレクトリが削除されるか破損します。 この.git ディレクトリは、バージョン管理がリモートリポジトリからの変更を追跡する方法です。 ls -aを入力すると、このディレクトリが存在すること

    2. 二重連結グラフ

      2つの頂点の間に2つの頂点が互いに素なパスが存在する場合、無向グラフは2重連結グラフと呼ばれます。つまり、任意の2つの頂点の間にサイクルがあると言えます。 グラフGは、接続されていて、グラフに関節点や切断点が存在しない場合、2重連結グラフであると言えます。 この問題を解決するために、DFSトラバーサルを使用します。 DFSを使用して、アーティキュレーションポイントが存在するかどうかを確認します。また、すべての頂点がDFSによってアクセスされているかどうかを確認します。アクセスされていない場合は、グラフが接続されていないと言えます。 入力と出力 Input: The adjacency