GNU/Linux >> Linux の 問題 >  >> Debian

初心者向けの無料 4 時間 Ubuntu コース

これは合計 4 時間の Linux Ubuntu トレーニング コースであり、初心者向けの無料 4 時間 Ubuntu コースという名前で YouTube チャンネルに公開されています。

1. Linux とは

Linux はよく知られているオペレーティング システムです。 1991 年、Linux は Linux Torvalds という大学生によって作成されました。すべてのソフトウェアのアーキテクチャは Linux でカバーされています。これは、コンピューター プログラムとシステム ハードウェア間の通信を支援し、それらの間の要求も管理するためです。 Linux はオープンソース ソフトウェアです。多くの点で他のオペレーティング システムと区別できます。プログラミングに関する専門的なスキルを持っている人は、誰でも無料でコードを編集することもできます。トーバルズは自分の創造物を「フリークス」と名付けるつもりだった 、」しかし、管理者は作成者の名と Unix でコードを配布していたため、その名前が残っていました.

2. Linuxディストリビューション

Linux ディストリビューションは、Linux カーネルを使用してパッケージ管理システム全体を構成する一種のオペレーティング システムです。 Linux ディストリビューションには、任意の Linux ディストリビューションをダウンロードすることで簡単にアクセスできます。

Linux ディストリビューションの特定の例には、カーネル、さまざまなライブラリ、GNU ツール、完全なデスクトップ環境、およびいくつかの追加のソフトウェア ドキュメントが含まれます。マクドナルドの例は、Linux ディストリビューションの概念を理解するのに最適です。マクドナルドは世界中に複数のフランチャイズがありますが、サービスと品質は同じです。同様に、Red Hat、Debian、Ubuntu、または Slackware の他のディストリビューションから Linux のオペレーティング システムをダウンロードすることもできます。端末内のコマンドの多くまたはすべてが同じです。マクドナルドの例はここに当てはまります。マクドナルドの各フランチャイズはディストリビューションのようなものと言えます。 Linux ディストリビューションの例としては、Red Hat、Slackware、Debian、Ubuntu などがあります。

3.インストールガイド

このトピックでは、システムに Ubuntu をインストールするための完全な方法を提供します。 Ubuntu をスムーズにインストールするには、以下の手順に従ってください:

ステップ 1 :お気に入りのブラウザを開き、https://ubuntu.com/ にアクセスして [ダウンロード] をクリックします。 セクション。

ステップ 2 :ダウンロードから セクション、Ubuntu デスクトップ LTS をダウンロードする必要があります .



ステップ 3 :クリックして Ubuntu デスクトップ ファイルをダウンロードします。これをクリックすると、Ubuntu Desktop をダウンロードしていただきありがとうございますという感謝メッセージが表示されます .



ステップ 4 :Windows を使用しているため、このダウンロードしたオペレーティング システムを USN に直接転送しても起動可能にならないため、USB を起動可能にする必要があります。

ステップ 5 :パワー ISO を使用できます この目的のためのツール。このリンクをクリックするだけで、Power ISO ツールをダウンロードできます https://www.poyouriso.com/download.php



ステップ 6 :Power ISO を使用して、Ubuntu オペレーティング システムを USB に転送します。 USB を起動可能にしながらこれを行います。

ステップ 7 :システムを再起動し、F11 を押してシステムのブート メニューに移動します。 または F12 そこからオペレーティング システムをセットアップします。

ステップ 8 :設定を保存し、システムを再起動して、システムに Ubuntu を歓迎します。

4.コマンドラインとターミナル

最初に頭に浮かぶ疑問は、なぜコマンド ラインを学ぶのかということです。問題は、GUI ですべてを行うことはできないということです。 GUI では処理できないことは、コマンドラインを使用してスムーズに実行されます。次に、コマンド ラインを使用すると、GUI よりも高速に実行できます。

次に、シェルとターミナルの 2 つについて説明します。システムは、シェルを使用してオペレーティング システムと通信します。どのようなコマンドを記述しても、シェルはそれを実行し、オペレーティング システムと通信し、オペレーティング システムにコマンドを与えて、要求されたことを実行します。その後、結果を提供します。 ターミナル そのコマンドを受け取り、それ自体に結果を表示するウィンドウです。これはシェルとの対話を支援するツールであり、シェルはオペレーティング システムとの対話を支援します。

すべてのコマンドは、異なる Linux ベースのシステムで同じです。ターミナルを開きたい場合は、「ターミナル」を検索してください。 ' 検索バーを使用して手動で。



CTRL+ALT+T」を押してターミナルを開く別の方法があります。

5. Linux ファイル システム

Linux には、階層ベースのファイル構造があります。ツリー状に存在し、すべてのファイルとその他のディレクトリがこの構造に含まれています。 Windows には「フォルダ」がありますが、Linux には「ルート」があります。 ' を基本ディレクトリとして、このディレクトリの下にすべてのファイルとフォルダーが存在します。以下に示すように、ファイル システムを開くと、システムのルート フォルダーを確認できます。その下にすべてのファイルとフォルダーがあります。ルート フォルダはメイン フォルダです。次に、その中に bin、boot、dev などのサブフォルダーがあります。これらのフォルダーのいずれかをクリックすると、そこにある別のディレクトリが表示され、Linux が階層構造を持っていることが証明されます。

6.コマンドの例

このトピックでは、Linux の理解に役立つコマンドの例について説明します。

CTRL+ALT+T を押します ターミナルを開きます。



最初のコマンドは、Linux ファイル ディレクトリ システムに関するものです。 Linux はツリーのようなシステムを持っており、例えば、どこか深いフォルダにジャンプしたい場合、その親にリンクされている各フォルダを経由する必要があります。最初のコマンドは「pwd コマンド」です 」。 pwd は 現在の作業ディレクトリ を表します .ターミナルに「pwd」と入力すると、作業中の現在/現在のディレクトリがわかります。結果により、ルートまたはホーム ディレクトリに移動します。

$ pwd



次に説明するコマンドは「cd コマンド」です 」。 cd は「ディレクトリの変更」の略です 」。このコマンドは、現在の作業ディレクトリを変更するために使用されます。現在のディレクトリからデスクトップに移動するとします。そのためには、ターミナルで以下のコマンドを入力してください。

$ cd デスクトップ



元のディレクトリに戻るには、「cd ..」と入力して Enter キーを押します。

次に学習するコマンドは「ls コマンド」です。現在ルート ディレクトリにいるので、ターミナルに「ls」と入力して、ルート ディレクトリ内にあるすべてのフォルダのリストを取得します。

$ ls

7.ハードリンクとソフトリンク

まず、リンクとは何かについて説明しましょう。リンクは、元のディレクトリへのショートカットを作成する簡単で便利な方法です。リンクは、ライブラリをリンクする、ディレクトリへの適切なパスを作成する、ファイルが一定の場所に存在するかどうかを確認するなど、さまざまな目的でさまざまな方法で使用できます。これらのリンクは、1 つのファイルの複数のコピーを異なる場所に保持するために使用されます。したがって、これらは4つの可能な用途です。このような場合、リンクはある意味ではショートカットですが、厳密にはそうではありません。

別の場所へのショートカットを作成するだけではなく、リンクについて学ぶべきことがたくさんあります。この作成されたショートカットは、元のファイルの場所へのポインターとして機能します。 Windowsの場合、任意のフォルダにショートカットを作成して開くと。作成された場所を自動的に参照します。リンクには、ソフト リンクとハード リンクの 2 種類があります。ハード リンクは、ディレクトリではなく、ファイルをリンクするために使用されます。現在作業中のディスク以外のファイルは参照できません。ソースと同じ inode を参照します。これらのリンクは、元のファイルを削除した後でも役立ちます。シンボリック リンクとも呼ばれるソフト リンクは、同じディスクまたは別のディスクにあるファイルを参照し、ディレクトリをリンクするために使用されます。元のファイルの削除後、壊れた使用可能なリンクとしてソフト リンクが存在します。

それでは、ハードリンクを作成しましょう。たとえば、Document フォルダー内にテキスト ファイルを作成します。



このファイルにコンテンツを書き込んで「fileWrite」として保存し、この場所からターミナルを開きます。

ターミナルで「ls」コマンドを入力して、作業ディレクトリ内の現在のファイルとフォルダーを表示します。

$ ls

これはlinuxhint.comです



$ ls



この「ln」コマンドでは、ハード リンクを作成するファイル名を指定し、ハード リンク ファイルに付ける名前を記述する必要があります。

$ ln fileWrite ハードリンク

次に、「la」コマンドを使用して、ハード リンクの存在を確認します。このファイルを開いて、元のファイルの内容が含まれているかどうかを確認できます。

$ラ





次に、ディレクトリ、たとえばドキュメント用のソフト リンクを作成します。ホームディレクトリからターミナルを開き、ターミナルを使用して次のコマンドを実行します

$ ln -s ドキュメントのソフトリンク

次に、「ls」コマンドを使用して、ソフト リンクが作成されているかどうかを確認します。確認のため、ファイルを開いてファイルの内容を確認してください。

$ ls





8.リストファイル「ls」

このトピックでは、「ls」コマンドを使用してファイルを一覧表示する方法を学習します。 「pwd コマンド」の使用 ' まず、現在または現在の作業ディレクトリを確認します。このディレクトリの内容を知りたい場合は、単に「ls」と入力して、ディレクトリ内のファイルのリストを表示してください。

$ pwd $ ls



Documents フォルダの内容を確認したい場合は、cd コマンドを使用してこのディレクトリにアクセスし、ターミナルで「ls」と入力します。

$ cd デスクトップ
$ ls



ファイルのリストを表示する方法は他にもあり、この方法でもファイルに関する情報が得られます。これを行うには、ターミナルで「ls -l」と入力する必要があります。これにより、ファイルの作成日時、ファイル名とファイルのアクセス許可、およびファイル サイズを含むファイルのロング フォーマットが表示されます。

$ ls -l



また、任意のディレクトリにある隠しファイルも表示できます。この場合、Documents ディレクトリ内の隠しファイルのリストを表示する場合は、ターミナルで「ls -a」と入力して Enter キーを押します。隠しファイルのファイル名は「.」で始まります。これは、隠しファイルであることを示しています。

$ ls -a



長いリストでファイルを表示することもでき、非表示のファイルは形式を結合します。この目的のために、「ls -al」コマンドを使用すると、次の結果が得られます。

$ ls -アル



「ls -Sl」コマンドを使用して、ソートされたファイルのリストを表示します。このリストは、サイズの降順に基づいてソートされています。出力と同様に、最初のファイルが他のすべてのファイルの中で最大のファイル サイズを持っていることがわかります。 2 つのファイルのサイズが同じ場合、このコマンドは名前に基づいてファイルを並べ替えます。

$ ls -Sl



「ls -lS> out.txt」と書くことで、端末に現在表示されているファイルに関連するこの情報をコピーできます。out.txt は、端末の現在のコンテンツを含む新しいファイルです。ターミナル。このコマンドを実行し、out.txt ファイルを開いて内容を確認してください。

$ ls -lS> out.txt $ ls





「man ls」コマンドを使用して、「ls」に関連するコマンドの完全な説明を表示し、それらのコマンドを適用してそのパースペクティブ結果を表示できます。

$ 男 ls



9.ファイルのアクセス許可

このトピックでは、ユーザー特権またはファイル許可について説明します。コマンド「ls -l」を使用して、ファイルの長いリストを表示します。ここでは「-rw-rw-r–」の形式 」は3つに分類されます。最初の部分は所有者の権限を表します 、2 番目は グループ権限 を表します 、3 つ目は 一般向け です .

$ ls -l



この形式では、r は読み取りを表し、w は書き込みを表し、d はディレクトリを表し、x は実行を表します。この形式「-rw-rw-r–」では、所有者は読み取りと書き込みのパーミッションを持ちます。グループには読み取りと書き込みのアクセス許可もありますが、パブリックにはファイルの読み取りアクセス許可しかありません。これらのセクションの権限は、ターミナルを使用して変更できます。そのために、ここでは「u」をユーザーに、「g」をグループに、「o」をパブリックに使用することを覚えておいてください。たとえば、file1.txt に対して次のファイル権限「-rw-rw-r–」があり、パブリック グループの権限を変更したいとします。 public グループに書き込み権限を追加するには、次のコマンドを使用します

$ chmod o+w file1.txt

そしてエンターを押します。その後、変更を確認するためにファイルの長いリストを表示します。

$ ls -l



file1.txt の公開グループに与えられた書き込み権限を取り戻すには、以下のように記述してください

$ chmod o-w file1.txt

次に、「ls -l」で変更を表示します。

$ ls -l

4 =「読み取り」
2 =「書き込み」
1 =「実行」
0 =権限なし

このコマンド「chmod 754 file1.txt」では、7 は所有者のアクセス許可を扱い、5 はグループのアクセス許可を扱い、4 はパブリックまたは他のユーザーを扱います。 4 はパブリックに読み取り権限があることを示し、5 (4+1) は他のグループに読み取りと実行の権限があることを意味し、7 は所有者がすべての権限を持っていることを意味します (4+2+1)。 /P>

10.環境変数

このトピックに入る前に、変数とは何かを知っておく必要があります。

これは、値を格納するためにさらに使用されるメモリ位置と見なされます。保存された値は、さまざまな動機に使用されます。編集、表示、削除後の再保存が可能です。

環境変数には、コンピューター上のプログラムのプロセスに影響を与える動的な値があります。それらはすべてのコンピューター システムに存在し、その種類はさまざまです。これらの変数を作成、保存、編集、および削除できます。環境変数は、システムの動作に関する情報を提供します。システムの環境変数を確認できます。 CTRL+ALT+T を押してターミナルを開きます 「echo $PATH」と入力します

$ エコー $PATH



以下に示すように、環境変数のパスが表示されます。このコマンド「echo $PATH」では、PATH は大文字と小文字が区別されることに注意してください。

ユーザー環境変数名を確認するには、「echo $USER」と入力して Enter キーを押します。

$ エコー $USER



ホーム ディレクトリ変数を確認するには、以下のコマンドを使用します

$ エコー $HOME



これらのさまざまな方法で、特定の環境変数に格納されている値を確認できます。システムに存在する変数のリストを取得するには、「env」と入力して Enter キーを押します。

$環境



次の結果が得られます。


以下に記述されたコマンドは、変数に値を作成して代入する目的で使用されます。

$ NewVariable=abc123
$ echo $NewVariable



この新しい変数の値を削除したい場合は、unset コマンドを使用してください

$ unset NewVariable

そして、それをエコーし​​て結果を確認します

$ エコー $NewVariable

11.ファイルの編集

CTRL+ALT+T を押してターミナルを開き、「ls」コマンドを使用してファイルを一覧表示します。

$ ls



現在の作業ディレクトリに存在するファイル名が表示されます。たとえば、ファイルを作成し、手動ではなくターミナルを使用して編集したいとします。そのためには、ファイルの内容を入力し、付けたいファイル名を書き出してください。

$ echo ‘This is a file”> linuxhint.txt を入力し、‘ls’ コマンドを使用してファイルのリストを表示します。

$ echo ‘これはファイルです”> linuxhint.txt $ ls



次のコマンドを使用して、ファイルの内容を表示します。

$ 猫 linuxhint.txt



ターミナルを使用してファイルを編集するには、次のコマンドを入力します

$ nano linuxhint.txt



「これはファイルです」
これは Linux のヒントです
linuxhint とも呼ばれるチャンネルにアクセスしてください



追加したいコンテンツをこのファイルに書き込み、CTRL+O を押します それをファイルに書き込み、Enter キーを押します。

CTRL+X を押します 終了します。

ファイルの内容を表示して、編集されたテキストを確認することもできます。

$ 猫 linuxhint.txt

12.疑似ファイル システム (dev proc sys)

ターミナルを開いて「ls /dev」と入力し、Enter キーを押します。このコマンドは、システムにあるデバイスのリストを表示します。これらは物理デバイスではありませんが、カーネルがいくつかのエントリを作成しています。

$ ls /dev



3
デバイス自体にアクセスしたい場合は、上記のコマンドの結果であるデバイス ツリーを経由する必要があります。
「ls /proc」と入力します。 Enter キーを押します。

$ ls /プロセス





ここの数字は、実行中のプロセスの ID を表します。番号「1」はシステムの最初のプロセスであり、「init プロセス」です。プロセス ID を使用して、システム内のステータスを確認します。たとえば、プロセス 1 のステータスを確認する場合は、「cd /proc/1」と入力してから「ls」と入力して実行します。

$ cd /proc/1



‘ cd ..’ を使ってその道から抜け出してください

$ CD ..



次に、「sys」について説明します。端末に次のコマンドを書き留めます

$ cd /sys $ ls

これで、重要なディレクトリがすべて表示されます。これは、カーネルまたはオペレーティング システム内に存在する多くの設定を取得できない場所です。カーネルに入り、そのファイルを一覧表示することもできます。

$ cd カーネル $ ls

これで、フラグ、プロセスのリストが表示されます。



cat コマンドと「sudo」を使用すると、管理者権限が必要になるため、これらのファイルの内容を表示できます。

パスワードを入力してください。



ここ 0 フラグがデフォルトであることを示します。フラグを設定すると、システムの動作が大幅に変わる可能性があります。

13.ファイルを探す

このトピックの目的は、ターミナルを介したファイルの検索と検索について学習することです。まず、ターミナルを開いて「ls」コマンドを使用します。次に、ここからファイルを見つけるために、次のように記述できます

$ 検索します。 file1.txt





すべてのファイルに「.」と「file1」が含まれているコマンドの結果を確認できます。

特にファイルを見つけるには、コマンドを記述してください。

$ sudo 検索 . -名前「file1.txt」



これを行う別の方法は、「locate」コマンドを使用することです。このコマンドは、キーワードに一致するすべてのものを見つけて見つけます。

ターミナル ウィンドウにコマンドのエラーが表示された場合は、まずシステムに「mlocate」をインストールしてから、このコマンドを再試行してください。

$ sudo apt-get install mlocate

$ ロケートファ

「fa」を含むすべての情報が出力されます。



14.ドットファイル

ドット ファイルは、通常のファイル システムに隠されているファイルです。まず、ファイルの結合リストを表示するには、ターミナルで次のコマンドを入力します。

$ ls -アル



ここでは、1 つのドットがユーザー名を表し、2 つのドットがルート フォルダーを表していることがわかります。

コマンド「ls .」を使用すると、現在のディレクトリにあるファイルまたはコンテンツのリストが表示されます

$ ls .





「ls ..」は上記のフォルダを表示します。この場合、これは基本的にユーザー名です。

$ ls ..



一部の転送ファイルの内容にジャンプするには、以下のコマンドを使用します。

$ 猫 ../../etc/passwd

二重ドットを使用して、この passwd ファイルなどのすべてのコンテンツを直接表示します。



15.圧縮と解凍

任意の場所からファイルを圧縮するには、ステップ 1 でその場所からターミナルを開き、「cd」コマンドを使用してそのディレクトリを現在の作業ディレクトリにします。

ファイルを圧縮するには、「gzip filename」と入力します。この例では、デスクトップにある「file1.txt」という名前のファイルを圧縮しました。

$ gzip file1.txt

コマンドを実行して結果を確認してください。



このファイルを解凍するには、圧縮ファイルであるため、ファイル名と拡張子「.gz」を付けて「gunzip」コマンドを記述します。

$ gunzip file1.txt.gz

そして、コマンドを実行してください。



複数のファイルを一度に 1 つのフォルダーに圧縮することもできます。

$ tar cvf compressfile.tar file1.txt newfile.txt

ここで、c は作成、v は表示、f はファイル オプションです。これらのコマンドは次のように動作します。まず、この車では「compressfile」という名前の圧縮フォルダーが作成されます。次に、このフォルダーに「file1.txt」と「newfile.txt」を追加します。





コマンドを実行してから、compressfile.tar をチェックして、そこにファイルが存在するかどうかを確認してください。

$ ls -l



ファイルを解凍するには、ターミナルで次のコマンドを入力します

$ tar xvf 圧縮ファイル.tar

16. Linux のタッチ コマンド

ターミナルを使用して新しいファイルを作成するには、touch コマンドを使用します。また、ファイルのタイムスタンプを変更するためにも使用されます。まず、「ls -command;」と入力します。現在の作業ディレクトリに存在するファイルのリストが表示されます。ここから、ファイルのタイムスタンプを簡単に確認できます。

最初にファイルを作成し、「bingo」という名前を付けましょう

$タッチビンゴ

次に、ファイルのリストを表示して、その存在を確認します。

$ ls



次に、ファイルの長いリストを表示して、タイム スタンプを確認します。

$ ls -l



「file1.txt」という名前のファイルのタイムスタンプを変更したいとしましょう。そのためには、touch コマンドを作成し、それでファイル名を定義してください。

$ touch file1.txt $ ls -l



「file1.txt」という名前の既存のファイルがある場合、このコマンドはこの変更のタイム スタンプのみを変更し、同じ内容を含みます。

17.ディレクトリの作成と削除

このトピックでは、Linux でディレクトリを作成および削除する方法を学習します。これらのディレクトリを「フォルダ」と呼ぶこともできます。デスクトップに移動し、ターミナルを開きます。ファイル リストを取得するには、次のコマンドを入力します。

$ ls



ここにフォルダを作成します。これには、make directory コマンドである「mkdir」コマンドを使用して、フォルダー名を入力します。

$ mkdir newfolder

コマンドを実行し、再度ファイルを一覧表示して、コマンドが機能したかどうかを確認してください。

$ ls



このフォルダも削除できます。そのためには、オペレーティング システムと通信してフォルダーを削除するが内部のファイルを削除しないようにシェルに指示するコマンドを作成する必要があります。

$ rm -r 新しいフォルダー

そして、「ls」コマンドを使用して削除を確認してください。

$ ls

18. Linux でのファイルのコピー、貼り付け、移動、名前変更

このトピックで説明されているすべての機能を実行するには、まず、別のファイルを作成する必要があります。デスクトップからターミナルを開きます。

ファイルを作成するコマンドを記述します。

$ touch bingwindowslinux

内容を書き込んで、ファイルを保存します。

$ ls

これは単なるLinuxです



その後、再度ターミナルを開きます。この「bingowindowslinux」のコンテンツを別のファイルにコピーするには、コンテンツを別のファイルにコピーする最初のファイル名を指定して「cp」コマンドを使用します。

$ cp bingowindowslinux コピー

次に、ファイルのリストを表示します。

$ ls



「copy」ファイルを開いて、「bingowindowslinux」自体のファイル コンテンツがコピーされているかどうかを確認します。



このファイルの名前を変更するには、move コマンドを使用します。 「移動」コマンドは、ファイルをディレクトリから別のディレクトリに移動するために使用されますが、同じディレクトリでこのコマンドを実行すると、ファイルの名前が変更されます。

$ mv コピー notcopy

この名前が変更されたファイルを開いて内容を表示してください。





このファイルの場所を変更したい場合は、ファイルを移動したい場所を定義することにより、「移動」コマンドを再度使用できます。

「notcopy」ファイルをルート「~」ディレクトリに移動するには、次のように記述します

$ mv notcopy 〜

次に「ls ~」でルート ディレクトリのファイルを表示します。

$ ls ~



19. Linux でのファイル名とスペース

まず、$ ls コマンドでデスクトップ上のファイルを表示します。ファイル名にスペースを含むファイルを作成する場合は、単純な touch コマンドにいくつかの変更があります。

コマンド「touch new file」を実行すると、以下に示すように別のファイルが作成されます。

ファイル名にスペースを含むファイルを作成するには、次の形式を検討してください:

$ touch ubuntu ファイル

コマンドを実行し、ファイルを一覧表示して結果を確認してください。







名前にスペースを入れてディレクトリを作成したい場合は、単に次のように記述してください

$ mkdir 新しいフォルダー

コマンドを実行して結果を確認してください。

20. Linux のオートコンプリート

このトピックでは、Linux でのオートコンプリートについて説明します。デスクトップに移動し、そこからターミナルを開きます。

「cd./D」と書き、タブを押します

$ cd ./D



このコマンドにより、'D' の 3 つのオートコンプリートの可能性が得られます。

次に、「o」と入力し、Enter ではなくタブを押すと、「Do」という単語のオートコンプリートの可能性が表示されます。

$ cd ./Do

次に、「c」とタブを押します。このオプションの可能性は 1 つしかないため、単語が自動的に完成します。

$ cd./ドキュメント







コマンドにも使えます。コマンドのオートコンプリートにより、その特定の単語に対するコマンドのオプションが表示されます。

「to」と入力してタブを押します。このアクションにより、次の結果が得られます

$から



21.キーボード ショートカット

このトピックでは、Linux のさまざまなキーボード ショートカットについて学習します。
CTRL+Shift+n 新しいフォルダの作成に使用されます。
Shift+delete ファイルを削除するには
ALT+Home ホーム ディレクトリに入るために
ALT+F4 ウィンドウを閉じる
CTRL+ALT+T ターミナルを開きます。
ALT+F2 単一のコマンドを入力するには
CTRL+D 行を削除するには
CTRL+C コピーの場合は CTRL+V、貼り付けの場合は CTRL+V。

22.コマンドライン履歴

「history」コマンドを使用して、Linux のコマンド ライン履歴を表示できます。

$履歴





このリストのコマンドを再度使用するには、次の形式を使用してください

$ !496





ウィンドウをクリアします.
別のコマンドを試してみましょう

$ 履歴 |以下







いくつかのコマンドが表示されます。Enter キーを押すと、コマンド全体からさらに多くのコマンドが表示されます。このコマンドは「500」コマンドのみを保存し、その後は消え始めます。

23.頭と尾のコマンド

Head コマンドはファイルの上部の最初の部分を取得するために使用され、Tail コマンドは固定長のテキスト ファイルの下部の最後の部分を取得するために使用されます。

CTRL+ALT+T を使用してターミナルを開き、デスクトップ ディレクトリに移動します。

$ヘッドファイル記事

コマンドを実行して結果を確認してください。



ドキュメントの最後の数行を読むには、次のコマンドを使用します

$ テールファイル記事

このコマンドは、ドキュメントの最後の部分を取得します。





一度に 2 つのファイルを読み取ることができ、文書の上部と下部を抽出することもできます。

$ head filessay filearticle



$ テールファイルエッセイファイル記事

24. wc コマンド

このトピックでは、「wc」コマンドについて学習します。 wc コマンドは、ドキュメントの文字数、単語数、行数を教えてくれます。

このコマンドを「fileessay」ファイルで試してください。

$ wcファイルエッセイ

値を確認してください。



ここで、31 は、この「filessay」文書の単語数、712 行数、4908 文字数を表します。

ファイルの内容を変更してから、この「wc」コマンドを再度使用して、目に見える違いを確認できます。



これらの属性を個別に確認することもできます。たとえば、この「fileessay」ファイルの文字数を知るには、ターミナルで次のコマンドを入力します。

$ wc -c fileessay



このコマンドでは、「-l」を使用して行数を取得し、「-w」を使用して単語数を取得します。

$ wc -l fileessay $ wc -w fileessay



ファイルの最長行から文字数を取得することもできます。このコマンドでは、まず、ドキュメントの最も長い行がチェックされ、現在の文字数が表示されます。

$ wc -L fileessay

コマンドを実行して、クエリの結果を確認してください。

25.パッケージのソースと更新

まず、パッケージとは何かを知る必要があります。パッケージとは、特定のアプリケーションに付属するすべてのファイルを含む圧縮ファイルを指します。最新の Linux ディストリビューションには、Linux システムに必要な多くのソフトウェアを含む標準リポジトリがあります。組み込みのパッケージ マネージャーは、インストール手順全体を管理します。システムの整合性は、インストールされたソフトウェアがパケット マネージャーによって認識されるようにすることで維持されます。

次の場合、リポジトリからソフトウェアをダウンロードできます。 1 つ目は、パッケージがリポジトリに見つからないことです。2 つ目は、パッケージが誰かによって開発され、まだリリースされていないことです。最後の理由は、カスタムの依存関係またはそれらの依存関係を持つオプションを含むパッケージをインストールする必要があることです。一般的ではない

sudo コマンドを使用して、任意のパッケージを簡単にインストールできます。 Sudo は root ユーザーまたはスーパーユーザーになるためのものです。スーパーユーザーでないと実行できない特定のタスクがあります。リポジトリの更新もその 1 つです。ターミナルからリポジトリを更新するには、次のコマンドを入力します。

$ sudo apt-get update

パスワードを入力して許可を与え、このプロセスが完了するまで待ちます。



26.パッケージ管理、検索、インストール、削除

「apt-cache」は、ターミナルからパッケージを検索するために使用される単純なコマンドです。

$ apt-cache 検索 yum



このコマンドでは、「yum」パッケージを検索します。したがって、これは検索したいパッケージ名を検索するための簡単なコマンドです。この検索コマンドは、yum に関連するすべてを表示します。

$ sudo apt-get インストール yum



この yum パッケージをアンインストールするには、次のコマンドを使用するだけです

$ sudo apt-get remove yum

構成設定を含むパッケージを削除するには、purge コマンドを使用します。

$ sudo apt-get パージ yum

27.ロギング

Linux では、ログは「/var/log」ディレクトリに保存されます。ログ ファイルを表示するには、次のコマンドを使用します。

$ ls /var/ログ



From the output, you can see there exist various log files in your system, like some of them are related to authorization, security, and some are related to kernel, system boot, system log, etc.

To view the content inside of these files, you have to use the ‘cat’ command with the path of the log file. Example command execution is given below.

$ cat /var/log/auth.log







The output shows all the information related to the authorization and security things you have done today, all the files and sessions in which you used your root permissions and worked as a superuser.

28. Services

This topic is about services, okay, so you are going to discuss services in Linux. First, understand the basics of the services. Services in Linux are the background tasks that are waiting to be used. These background applications or sets of applications are the set of essential tasks running in the background, and you don’t even know. An example of typical services would be apache and MySQL.

Now let’s see how you can work with services on how you can start, stop, restart, and even check the status of it or check all the services that are running on your system. First of all, you will open up your terminal by pressing CTRL+ALT+T.

here you are going to write

$ service –status-all



It will tell you about all the services which are running in the background, and ‘+’ means that the service is up and running and it is active the ‘-’ means that the service is not active and it is not running, or maybe it is unrecognized.

Let’s explore the ‘Apache’ service. First of all, you are going to write ‘service’ and then the service name, which is essentially Apache, and then you write ‘status.’

$ service apache2 status



The green dot shows that it is running, and the white dot shows that it has been stopped.

Press ‘CTRL+c’ so that you can come out of it, and you can simply write your command in the terminal.

$ service apache2 start



$ service apache2 status

$ service apache2 restart





29. Processes

The process is a computer program in action and carryout the task of the operating systems. Now, what if you want to, you know, see, or check what are the processes that are like going on your system.

$ ps



Here you can see that you have a list of the processes which are like going on. The PID is nothing but a unique process ID that is given to the process, so it is ideal for defining and identifying a process or anything any entity by the ID number. TTY is the terminal from it is running, and time is the CPU time that it has taken to run the process or complete the process, and CMD is the basic name of the process.

Let’s run an example and see how you can check out the processes and run them. If you run a process named Xlogo, you hit enter, and you can see that this is a process it takes a lot of time here, and you cannot run anything right here.



To write anything, you have to press CTRL+C. It is visible that the Xlogo window is now gone.

To shift this process into the background, what you can do is that you can write

$ xlogo &

You can see that now this process is running in the background.

30. Utilities

Utilities are also known as commands in Linux.

Utilities are also known as commands; although there is no real differentiation between a command and a utility, there is still a difference between Linux shell commands and standard Linux commands. The utility is nothing but a tool to run a command. ‘ls’, ‘chmod’, ‘mdir’ are some of the utilities used in general.

31. Kernel Modules

Kernel modules are stored in the home directory or the root folder. These are the drivers that can be loaded and unloaded as well as needed or at the boot time. The kernel is the low-level aspect of your computer that sits between the user and hardware, and its job is to how to you know, talk to CPU to communicate with the memory and the communication with the devices. It takes all the information from the application and communication with the hardware, and it also takes all the information from the hardware, and it communicates with the application, so you can say that kernel is a bridge which takes the information from the application to the hardware and from the hardware to the application. For the kernel to communicate with the hardware, it needs to have some specific modules. It needs to have a module that can tell it how to do that, and those modules are available and built-in, and a few of them can be imported. They are externally available, and you can use them as you need them.

Use the following command to check the list of the available modules in your system.

$ lsmod





So here, you can see the name of the modules in the first row, and the second row is for a module, and the third one is just the comments or the information against each driver or each kernel module.

To uninstall a module named ‘lp’, you can write

$ sudo rmmod lp

32. Adding and changing users

This topic is about adding users and changing users. When you add a user, you will add it to a specific group, or you can also create a user as if you don’t want to add it to any group then the user will you will be created and it will generate its own like sort of a unique identity and a unique group sort of thing.

Open up our terminal, so before you add a user to the group, there are a couple of things that you need to know. You should know that in which group you are going to add the user. To know which groups exist on our system, you need to write this command

$ cat /etc/group

You can see that you have several groups available. Let’s say you want to add a user to this group, so l the user name you want to name the user as John.

$ sudo useradd -d /home/john -s /bin/bash -g colord -m john



As you created the users successfully, you can write

$ cat /etc/passwd





Here you can see that you have a user named John, and this 126 is the group ID of the group ‘colord’.

33. User group and user privileges

In this topic, you are going to learn how to create and delete a user as well as a group and also discuss the user privileges.

Open up the terminal and create a user with its unique group. You can add users individually as well.

$ sudo useradd -m johny

And now confirm the existence of this user by opening the content of the ‘passwd’ file

$ cat /etc/passwd







What if you want to create another specific group, and you want to add users to that so adding users to that is very simple, and it is discussed in the previous topic. Now write a command to create a unique group so that you can add any member to it.

$ sudo groupadd Linuxusers

Check the content of the group file

$ cat /etc/group





You can also delete the group by using the ‘groupdel’ command

$ sudo groupdel Linuxusers

And again, check the group file to confirm its deletion.

$ cat /etc/group



34. Using sudo

sudo stands for ‘superuser do 」。 The idea is that you cannot perform certain actions without being a superuser, and you can ask why is that so? You cannot perform any installation or changes in the root folder without being a superuser because your system needs to be saved so no other user can make any changes other than you. So you have to put in your password, and you need to make your system make sure that it’s you, and then you can make changes in the root folder; otherwise, whatever commands you would write, it would give you the error or the warning. Whenever you see that permission denied message, it means that you need to work as a superuser because these changes are going to affect your root folder.

Using the sudo command, you can update your system.

$ sudo apt-get update



You can create or delete a new directory and many more actions by becoming a superuser.

$ sudo mkdir newDirectory $ ls

35. Network UI

Openup the terminal and write here the first command, which is

$ sudo ip link



Press enter and see different network interfaces. The number one is this ‘lo’, which stands for Linux host, and others are the ethernet networks. You can see there is a MAC address, which tells us that it is the ether link. If you see here we have ‘UP’, it means that it is ready and available and it can be used so up just tells you that it is available. It doesn’t mean that it is being used; it means that it is available to use. ‘LOWER_UP’ shows that a link is established at the physical layer of the network.

We will also see you know the IP addresses and how do we check them.

$ sudo ip addr



To get the information about all of the commands related to ip link, type

$ man ip link





Try some of those commands for a better understanding of the topic.

36. DNS (incomplete)

$ hostnamectl set-hostname SERVER.EXAMPLE.COM
10.0.2.15
~$ sudo nano /etc/network/interfaces
$ sudo apt-get install bind9 bind9utils
$ cd /etc/bind
$ nano etc/bind/name.conf

37. Changing nameservers

Open your terminal by using ‘CTRL+ALT+T’ and write the following command in it.

$ sudo nano /etc/resolve.conf





This is the configuration file that has been opened. Now, we are going to write ‘8.8.8.8’ and then we’re going to change another server we’re going to write here ‘8.8.4.4’ so save it, write it out, and then we exit it.

Now before doing anything, let’s let us check that if the changes have been made in the file successfully or not. Write this command ping, which is the packet internet groper, so P is for packet I for Internet, and G is for groper. It communicates between the server and the source and the server and the host. It will verify that our main service has been changed and they’re like a set.

$ ping 8.8.8.8



We have set the name server as 8.8.8.8, and now you can see we have started to get reserves; we are getting all the packets, and the communication has begun.

Press ‘CTRL+C’ and you can see it has shown us all the details about the packets which have been sent, received and the information about the packet lost.

38. Basic Troubleshooting

We are going to discuss some basic troubleshooting commands on this topic. Before everything, whenever you get to a Linux host, run the following command to know the version of the Linux.

$ uname -a



This is essential to know because of the version across different distributions of Linux; the commands might differ. But these commands will work on any Linux distribution, so the first command that we are going to discuss the ping command.

Ping is used for network reachability tests, so if you want to test the network reachability, you will write this ping command. Let’s try to send five requests, and we send it to the IP address 8.8.8.8

$ ping -c5 8.8.8.8



Now it would send like five requests, and you can see that five packets have been transmitted, and five have been received, and in that whole scenario, there is a zero percent packet loss.

You can also test the ping command on some IP address where you know there might be a packet loss or something. Give a random IP address and test the command.

$ ping 2.2.2.2



Press ‘CTRL+C’ to know the results.

Ping can also be used with the DNS name as well; you can test it with the ‘www.google.com’.

$ ping www.google.com



Now let’s discuss another command, which is ‘traceroute’. This traceroute command trace all the path of the network, and it displays you each activity on each hop.

$ traceroute 8.8.8.8



Results have shown you all the activity through every hop. There is another command that will troubleshoot commands that we would like to discuss, which is ‘dig’. let’s try digging amazon.com, so we have tried to dig amazon.com

$ dig www.amazon.com



We can get the message size, the name, server IP, QE time.

There is another command, ‘netstat’, which represents the network status statistics; it displays you all the active sockets and internet connection.

$ netstat

$ netstat -l



This command will display all the programs which are currently listening and all the internet connections which are listening as well.

39. Informational utilities

Let’s look at some utilities which could provide information about your networking subsystem. The first command is the ‘arp’ command. arp stands for address resolution protocol, so the idea is that every machine has a unique address like every DNS has a unique address in the form of an IP address similarly every machine has a unique address as well which is known as MAC address. ‘arp’ or the address resolution protocol matches the IP address with the MAC address. Locally wherever you want to communicate or you want to communicate in that case, we need a MAC address specifically for local communication from one machine to another machine on the same network or from one machine to the router on the same network.

$ arp -a



There is another informational utility, which is ‘route.’

$ route



you can see a routing table as a result of the route command execution.

You can also use another utility to view the routing table, but this one shows the IP addresses of the destination instead of its name.

$ netstat -rn

$ man netstat





40. Packet Captures

In this topic, you will learn how to capture packets, and we can do that using some packet capturing tool. The most used tool for this purpose is ‘wireshark’. Write the following command to begin its installation on your system.

$ sudo apt-get install wireshark



Enter your password when it asks for it. After that, it would ask you for the configuration of Wireshark that if you want to give access to non-superusers so you have to select yes because we want to give access to non-superusers as well and now it would start to you know unpack the packet.





After its installation, open the Wireshark software; first of all, go here on the capture options, and you can see that we have input as cisco remote capture random pattern generator and ssh remote capture, UDP listener. Select the random packet generator, and once you click start and if you do not see any of these options, ten simply restart your system. Sometimes you need to restore the system.

Run a few commands before starting the process of packet capturing and to make sure that you set everything. First of all, check the group of the Wireshark

$ sudo addgroup -system wireshark

Make sure that this group exists.

After that write another command

$ sudo setcap cap_net_raw,cap_net_admin=eip /usr/bin/dumpcap

After that, add the user to the Wireshark group.



$ sudo usermod -a -G wireshark linuxhint

Now go back to the Wireshark software, and under the same settings, you will see the packet capturing process.



41. IP Tables

In this topic, we are going to discuss IP tables. IP tables are just a set of rules which define your network’s behavior, your machine’s behavior on your network.

The command to view the IP table is given below

$ sudo iptables -L



you can see this is the first chain is the input, then the second chain that we have is the forward chain, then we have the output chain. Whatever rules you will give to this in this IP table, your machine will follow it. This input rule or the input policy is for sending that traffic to itself like your machine right now whatever input it is taking like if you send traffic you’re sending traffic from your machine to your machine is called the input chain. Whatever rules you will set here, they will be for your machine or your localhost.

Output chain would send from your machine to some other machine out there in the world or out there on the network that would be the output chain. You can set and define rules for dealing with the output traffic from here, the traffic that you’re sending from your machine to the outside world to any other machine. In this example, you are trying to send traffic from your machine to the outside world to any other machine.

For sending a packet to the local host, execute the following command

$ ping 127.0.0.1



Now let’s say we define a rule here, and we do not want to send any packet to ourselves. We define a rule, and we drop the package that we intend to send to ourselves. For that, we set a rule in the IP tables.

$ sudo iptables -A INPUT -d 127.0.0.1 -p icmp -j DROP $ sudo iptables -L



You can see that this command has been executed successfully, so now, if you check the IP tables, you can see that this is a rule that has been added to the input chain, right. You can also define rules for the OUTPUT chain. An example of this is given below.

$ sudo iptables -A OUTPUT -d 8.8.8.8 -p icmp -j DROP $ sudo iptables -L

42. SSH servers

In this topic, you are going to learn how you can enable SSH and install an open server in your system. If your system is an SSH client, then it can connect to any SSH server out there using a simple command. It can connect to any of the SSH servers, and it can use the operating system remotely. To check that if SSH is installed or enabled on your system, type ssh and press enter.

$ ssh

If you see, you know things like this.



then it means that you are an SSH client, or your machine is an SSH client.

simply if you want to connect your machine to a remote machine and you want to use it like any server out there which is hundreds of miles away from you, you can do that by writing a command like this

$ ssh username@ip -5252

SSH then the username of that server, then the IP address of that server, and then if there is a special port, you can write here.

Now you are going to learn going to connect to your localhost. It means that you are going to connect to our machine and use your operating system. First of all, check whether SSH is enabled in your system or not.

$ ssh localhost



After this step, install the open shh server on your system

$ sudo apt-get install openssh-server



$ ssh localhost





Now check the status of the SSH service by using the following command.

$ sudo service ssh status



You can also make a different kind of changes in this whole procedure. You can edit the file for that.

$ sudo nano /etc/ssh/ssh_config



43. Netcat

Netcat is a popular network security tool. It was introduced in 1995. Netcat runs as a client to initiate the connections with other computers, and it can also operate as a server or listener in some specific settings. Some common usages of Netcat are using it as a chat or messaging service or file transfers. Netcat is also used for port scanning purposes.

To know that your system has netcat or not, type the command given below in your terminal.

$ nc -h





Next, you are going to learn how to create a chat service using Netcat on a terminal.

For this, you have to open two windows of the terminal. One is then considered ad server and the other window as a client. Use the following command in the server terminal for the establishment of a connection.

$ sudo nc -l -p 23

Here 23 is the port number. At the client-side, execute the following command.

$ nc localhost 23

And here we are with our chat service.



44. Installing Apache, MySQL, Php

First of all, we are going to install Apache, but before that, update your repository

$ sudo apt-get update



After updating the repository, install apache2 on your system.

$ sudo apt-get install apache2



You can confirm its existence by checking the system services and by typing localhost in your web browser.



The next package is the PHP, so you have to write the following command on your terminal.

$ sudo apt install php-pear php-fpm php-dev php-zip php-curl php-xmlrpc php-gd php-mysql php-mbstring php-xml libapache2-mod-php



Now, test the terminal by executing the following command.

$ php -r ‘echo “nnYour PHP iNSTALLATION IS WORKING FINE. nnn”;





Execute the following command for the installation of MySQL.

$ sudo apt-get install mysql-server

After that, run some test commands on this MySQL terminal for testing.

$ sudo mysql -u root -p

> create database testdb;> show databases;



To install PHPMyAdmin, follow these steps:

$ sudo apt-get install phpmyadmin













45. Best youtube editors

We have plenty of editors that we can install, which are best. The first one that we are going to recommend is ‘Sublime text’; then, we have ‘brackets,’ and the one you are going to install on Ubuntu is named ‘Atom’.

$ snap install atom –classic





You can open it up, and then you can open all sorts of reading web files JS files, HTML files, CSS, or PHP files, whatever files related to the web development sort of thing.

46. Bash script

Open up your terminal by pressing ‘CTRL+ALT+T’. In this window, you can write and execute commands, and you will also get the instant output for that too. Below is a simple example is given for a better understanding of a bash script.

In step 1, you can view the list of files in your current working directory. Execute the ‘ls’ command for this purpose.

Now, let’s create and edit a bash script file through the terminal. For that, write the following ‘nano’ command in your terminal.

$ nano bashscript.sh

#! /bin/bash
touch bashtextfile.txt
chmod 777 bashtextfile.txt

$ ls



Now let’s create another file using this bash script. You can use the ‘touch’ command for creating the file and ‘chmod’ for changing the file privileges.

Write out the content using ‘ctrl+o’ and exit this window. Now execute ‘bashscript.sh’ and list the files to see if the ‘bashtextfile.txt’ is created or not.



The ‘bashscript.sh’ is not executable yet. Change the file permissions of this file by the ‘chmod’ command.

$ chmod 775 bashscript.sh

‘775’ is the file privileges given to the owner, groups, and public. File privileges are already well explained in the previous topic.

$ ls



You can also write some statements using the ‘echo’ command.

$ nano bashcript.sh #! /bin/bash
touch bashtextfile.txt
chmod 777 bashtextfile.txt
echo “this is linuxhint.com”



47. Python scripts

To work with python scripts, First of all, install python3 in your system using the terminal.

$ sudo install python3

Follow the installation procedure and install it. After the successful installation of python, test it on the terminal



Write some python commands to see the results.

$ python3

$ print(‘hello World’)



There are other methods of running python using the terminal, which is considered to be the conventional one. First, create a file using the ‘.py’ extension and write all of your python code you want to execute and save the file. To execute this file, simply write the following command in the terminal, and you will get your desired results in seconds.

$ python3 pythonscript.pyPrint(‘hello world’)

$ ls

$ python pythonscript.py

48. C programs

To work with ‘C programs’ using terminal, first of all, you should know whether ‘gcc’ is installed on your system or not and what is the version of ‘gcc’. To know this thing, write the following command in the terminal.

$ gcc –version



Now install the ‘build-essential’ package in your system.

$ sudo apt install build-essential



Create a ‘c’ file using the touch command.

$ touch hello.c

List the files to check its existence.

$ ls



Write the program in this ‘hello.c’ file for which you want to get the output.

#include
int main()
{
printf(“hello World”);
return 0;
}



After that, execute the file on the terminal, using the following command.

$ gcc hello.c -o test $ ./test

Now see the desired result.





Watch FULL VIDEO Course of 4 HOURS:


Debian
  1. 2022 年の Linux/Ubuntu システム向けベスト 10 IPTV

  2. Linux 用の 7-Zip

  3. Amazon EC2 の Amazon Linux と Ubuntu の比較

  1. LinuxMalwareDetectをDebian/Ubuntu / LinuxMintにインストール–Linuxオペレーティングシステム用のマルウェアスキャナー

  2. Ubuntuのタスクマネージャー?

  3. MX Linux 対 Ubuntu

  1. 初心者向けのLinuxフリーコマンドの説明(6例)

  2. Linuxの稼働時間コマンドを初心者向けに例を挙げて説明

  3. Ubuntu のシステム プロンプトでパスワードを偽装できませんか?