ウェブサイト検索

中級レベルの Linux ユーザー向けの 20 の高度なコマンド


最初の記事が非常に役に立ったと思われるかもしれませんが、この記事は Linux 初心者のための 20 の便利なコマンドを拡張したものです。最初の記事は初心者向けでしたが、 この記事は中級ユーザー上級ユーザーを対象としています。ここでは、検索をカスタマイズする方法、それらを強制終了するためのガイドを実行しているプロセスを知る方法、Linux ターミナルの生産性を高める方法が重要な側面、および c をコンパイルする方法について説明します。 nix のstrong>C++、Javaプログラム。

21. コマンド: 検索

指定されたディレクトリ内のファイルを、親ディレクトリから階層的に開始してサブディレクトリに移動して検索します。

root@tecmint:~# find -name *.sh 

./Desktop/load.sh 
./Desktop/test.sh 
./Desktop/shutdown.sh 
./Binary/firefox/run-mozilla.sh 
./Downloads/kdewebdev-3.5.8/quanta/scripts/externalpreview.sh 
./Downloads/kdewebdev-3.5.8/admin/doxygen.sh 
./Downloads/kdewebdev-3.5.8/admin/cvs.sh 
./Downloads/kdewebdev-3.5.8/admin/ltmain.sh 
./Downloads/wheezy-nv-install.sh

注: `-name` オプションを使用すると、検索で大文字と小文字が区別されます。 `-iname` オプションを使用すると、大文字と小文字を区別せずに何かを検索できます。 (* はワイルドカードで、拡張子「.sh」を持つすべてのファイルを検索します。ファイル名またはファイル名の一部を使用して出力をカスタマイズできます)。

root@tecmint:~# find -iname *.SH ( find -iname *.Sh /  find -iname *.sH)

./Desktop/load.sh 
./Desktop/test.sh 
./Desktop/shutdown.sh 
./Binary/firefox/run-mozilla.sh 
./Downloads/kdewebdev-3.5.8/quanta/scripts/externalpreview.sh 
./Downloads/kdewebdev-3.5.8/admin/doxygen.sh 
./Downloads/kdewebdev-3.5.8/admin/cvs.sh 
./Downloads/kdewebdev-3.5.8/admin/ltmain.sh 
./Downloads/wheezy-nv-install.sh
root@tecmint:~# find -name *.tar.gz 

/var/www/modules/update/tests/aaa_update_test.tar.gz 
./var/cache/flashplugin-nonfree/install_flash_player_11_linux.i386.tar.gz 
./home/server/Downloads/drupal-7.22.tar.gz 
./home/server/Downloads/smtp-7.x-1.0.tar.gz 
./home/server/Downloads/noreqnewpass-7.x-1.2.tar.gz 
./usr/share/gettext/archive.git.tar.gz 
./usr/share/doc/apg/php.tar.gz 
./usr/share/doc/festival/examples/speech_pm_1.0.tar.gz 
./usr/share/doc/argyll/examples/spyder2.tar.gz 
./usr/share/usb_modeswitch/configPack.tar.gz

: 上記のコマンドは、ルート ディレクトリとマウントされたデバイスを含むすべてのサブディレクトリで拡張子「tar.gz」を持つすべてのファイルを検索します。

Linux の「find」コマンドの例の詳細については、35「Linux での Find コマンドの例」を参照してください。

22. コマンド: grep

grep」 コマンドは、指定されたファイル内で、指定された文字列または単語と一致する行を検索します。 「/etc/passwd」で「tecmint」ユーザーを検索します。

root@tecmint:~# grep tecmint /etc/passwd 

tecmint:x:1000:1000:Tecmint,,,:/home/tecmint:/bin/bash

-i」オプションを使用すると、大文字と小文字やその他すべての組み合わせが無視されます。

root@tecmint:~# grep -i TECMINT /etc/passwd 

tecmint:x:1000:1000:Tecmint,,,:/home/tecmint:/bin/bash

再帰的に検索 (-r)つまり各ディレクトリにあるすべてのファイルを読み取り、文字列「127.0.0.1」を探します。

root@tecmint:~# grep -r "127.0.0.1" /etc/ 

/etc/vlc/lua/http/.hosts:127.0.0.1
/etc/speech-dispatcher/modules/ivona.conf:#IvonaServerHost "127.0.0.1"
/etc/mysql/my.cnf:bind-address		= 127.0.0.1
/etc/apache2/mods-available/status.conf:    Allow from 127.0.0.1 ::1
/etc/apache2/mods-available/ldap.conf:    Allow from 127.0.0.1 ::1
/etc/apache2/mods-available/info.conf:    Allow from 127.0.0.1 ::1
/etc/apache2/mods-available/proxy_balancer.conf:#    Allow from 127.0.0.1 ::1
/etc/security/access.conf:#+ : root : 127.0.0.1
/etc/dhcp/dhclient.conf:#prepend domain-name-servers 127.0.0.1;
/etc/dhcp/dhclient.conf:#  option domain-name-servers 127.0.0.1;
/etc/init/network-interface.conf:	ifconfig lo 127.0.0.1 up || true
/etc/java-6-openjdk/net.properties:# localhost & 127.0.0.1).
/etc/java-6-openjdk/net.properties:# http.nonProxyHosts=localhost|127.0.0.1
/etc/java-6-openjdk/net.properties:# localhost & 127.0.0.1).
/etc/java-6-openjdk/net.properties:# ftp.nonProxyHosts=localhost|127.0.0.1
/etc/hosts:127.0.0.1	localhost

: 次のオプションを grep と一緒に使用できます。

  1. -w は単語の場合 (egrep -w ‘word1|word2‘ /path/to/file)。
  2. -c はカウント (つまり、パターンが一致した合計回数) を表します (grep -c ‘word‘ /path/to/file)。
  3. カラー出力の場合は –color (grep –color server /etc/passwd)。

23. コマンド: 男

man」 はシステムのマニュアル ページャーです。 Man は、コマンドとその使用法で可能なすべてのオプションに関するオンライン ドキュメントを提供しています。ほとんどすべてのコマンドには、対応するマニュアル ページが付属しています。例えば、

root@tecmint:~# man man

MAN(1)                                                               Manual pager utils                                                              MAN(1)

NAME
       man - an interface to the on-line reference manuals

SYNOPSIS
       man  [-C  file]  [-d]  [-D]  [--warnings[=warnings]]  [-R  encoding]  [-L  locale]  [-m  system[,...]]  [-M  path]  [-S list] [-e extension] [-i|-I]
       [--regex|--wildcard] [--names-only] [-a] [-u] [--no-subpages] [-P pager] [-r prompt] [-7] [-E encoding] [--no-hyphenation] [--no-justification]  [-p
       string] [-t] [-T[device]] [-H[browser]] [-X[dpi]] [-Z] [[section] page ...] ...
       man -k [apropos options] regexp ...
       man -K [-w|-W] [-S list] [-i|-I] [--regex] [section] term ...
       man -f [whatis options] page ...
       man -l [-C file] [-d] [-D] [--warnings[=warnings]] [-R encoding] [-L locale] [-P pager] [-r prompt] [-7] [-E encoding] [-p string] [-t] [-T[device]]
       [-H[browser]] [-X[dpi]] [-Z] file ...
       man -w|-W [-C file] [-d] [-D] page ...
       man -c [-C file] [-d] [-D] page ...
       man [-hV]

man ページ自体のマニュアルページ。同様に、「man cat」 (cat コマンドのマニュアルページ) および「man ls」 (コマンド ls のマニュアルページ)。

: man ページは、コマンドのリファレンスと学習を目的としています。

24. コマンド: ps

ps (プロセス) は、PID と呼ばれる一意のIDを使用して、実行中のプロセスのステータスを示します。

root@tecmint:~# ps

 PID TTY          TIME CMD
 4170 pts/1    00:00:00 bash
 9628 pts/1    00:00:00 ps

すべてのプロセスのステータスをプロセス id および PID とともにリストするには、オプション '-A を使用します。

root@tecmint:~# ps -A

 PID TTY          TIME CMD
    1 ?        00:00:01 init
    2 ?        00:00:00 kthreadd
    3 ?        00:00:01 ksoftirqd/0
    5 ?        00:00:00 kworker/0:0H
    7 ?        00:00:00 kworker/u:0H
    8 ?        00:00:00 migration/0
    9 ?        00:00:00 rcu_bh
....

: このコマンドは、実行中のプロセスを知りたい場合や、プロセスを強制終了するために時々PIDが必要になる可能性がある場合に非常に役立ちます。 「grep」 コマンドと一緒に使用して、カスタマイズされた出力を見つけることができます。例えば、

root@tecmint:~# ps -A | grep -i ssh

 1500 ?        00:09:58 sshd
 4317 ?        00:00:00 sshd

ここで、「ps」は「grep」コマンドでパイプライン処理され、必要に応じてカスタマイズされた関連する出力を見つけます。

25. コマンド: 殺す

コマンドの名前から、このコマンドの目的は理解できたかもしれません。このコマンドは、現在関係のないプロセス、または応答していないプロセスを強制終了するために使用されます。これは非常に便利なコマンドです。むしろ、非常に非常に便利なコマンドです。実行中のプロセスはほとんどの場合強制終了できず、強制終了された場合、変更を有効にするために Windows を再起動する必要があるため、Windows が頻繁に再起動することはよく知られているかもしれませんが、Linux の世界では、そのようなことはありません。ここでは、システム全体を再起動せずにプロセスを強制終了して開始できます。

プロセスを強制終了するには、プロセスの pid (ps) が必要です。

応答していない可能性があるプログラム「apache2」を強制終了したいとします。 grep コマンドとともに「ps -A」を実行します。

root@tecmint:~# ps -A | grep -i apache2

1285 ?        00:00:00 apache2

プロセス「apache2」を検索し、そのpidをメモして強制終了します。たとえば、私の場合、「apache2」の pid は「1285」です。

root@tecmint:~# kill 1285 (to kill the process apache2)

: プロセスを再実行するかシステムを起動するたびに、プロセスごとに新しいpid が生成され、現在実行中のプロセスとそのプロセスについて知ることができます。 >コマンド 'ps' を使用して pid を実行します。

同じプロセスを強制終了する別の方法もあります。

root@tecmint:~# pkill apache2

: Kill ではシグナルを送信するためのジョブ ID/プロセス ID が必要ですが、pkill の場合と同様にオプションがあります。パターンの使用、プロセス所有者の指定など。

26. コマンド: whereis

whereis」 コマンドは、 コマンドのバイナリソース、およびマニュアル ページを見つけるために使用されます。たとえば、コマンド 'ls' および 'バイナリソース、およびマニュアル ページを見つけるには、 > 殺す』。

root@tecmint:~# whereis ls 

ls: /bin/ls /usr/share/man/man1/ls.1.gz
root@tecmint:~# whereis kill

kill: /bin/kill /usr/share/man/man2/kill.2.gz /usr/share/man/man1/kill.1.gz

: これは、手動で編集する場合にバイナリがどこにインストールされているかを知るのに役立ちます。

27. コマンド: サービス

サービス」 コマンドは、「サービス」 の開始停止、または再起動を制御します。 >」。このコマンドを使用すると、システムを再起動せずにサービスを開始再起動、または停止して、変更を有効にすることができます。

Ubuntuでのapache2サーバーの起動

root@tecmint:~# service apache2 start

 * Starting web server apache2                                                                                                                                 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
httpd (pid 1285) already running						[ OK ]

Ubuntu での Apache2 サーバーの再起動

root@tecmint:~# service apache2 restart

* Restarting web server apache2                                                                                                                               apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
 ... waiting .apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName  [ OK ]

Ubuntu での Apache2 サーバーの停止

root@tecmint:~# service apache2 stop

 * Stopping web server apache2                                                                                                                                 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
 ... waiting                                                           		[ OK ]

: すべてのプロセス スクリプトは「/etc/init.d」にあり、特定のシステムではパスを含める必要がある場合があります。つまり、「 service apache2 start 」を実行すると、「/etc/init.d/apache2 start 」を実行するように求められます。

28. コマンド: alias

エイリアスは、長いコマンドや頻繁に使用されるコマンドに名前を割り当てることができる組み込みのシェル コマンドです。

私は「ls -l」コマンドを頻繁に使用します。これにはスペースを含めて 5 文字が含まれます。したがって、これのエイリアスを「l」に作成しました。

root@tecmint:~# alias l='ls -l'

動作するかどうかを確認してください。

root@tecmint:~# l

total 36 
drwxr-xr-x 3 tecmint tecmint 4096 May 10 11:14 Binary 
drwxr-xr-x 3 tecmint tecmint 4096 May 21 11:21 Desktop 
drwxr-xr-x 2 tecmint tecmint 4096 May 21 15:23 Documents 
drwxr-xr-x 8 tecmint tecmint 4096 May 20 14:56 Downloads 
drwxr-xr-x 2 tecmint tecmint 4096 May  7 16:58 Music 
drwxr-xr-x 2 tecmint tecmint 4096 May 20 16:17 Pictures 
drwxr-xr-x 2 tecmint tecmint 4096 May  7 16:58 Public 
drwxr-xr-x 2 tecmint tecmint 4096 May  7 16:58 Templates 
drwxr-xr-x 2 tecmint tecmint 4096 May  7 16:58 Videos

エイリアス「l」を削除するには、次の「unalias」コマンドを使用します。

root@tecmint:~# unalias l

l’ がまだエイリアスであるかどうかを確認してください。

root@tecmint:~# l

bash: l: command not found

このコマンドを少し楽しんでみてください。特定の重要なコマンドの別名を別の重要なコマンドに作成します。

alias cd='ls -l' (set alias of ls -l to cd)
alias su='pwd' (set alias of pwd to su)
....
(You can create your own)
....

さて、友人が「cd」と入力したときに、ディレクトリの変更ではなくディレクトリの一覧が表示されたらどんなに面白いだろうか考えてみてください。そして、彼が「su」になろうとすると、得られるのは作業ディレクトリの場所だけです。上で説明したように、後でコマンド「unalias」を使用してエイリアスを削除できます。

29. コマンド: df

ファイル システムのディスク使用量をレポートします。ユーザーだけでなくシステム管理者もディスクの使用状況を追跡するのに役立ちます。 「df」はディレクトリ エントリを調べることによって機能します。ディレクトリ エントリは通常、ファイルが閉じられたときにのみ更新されます。

root@tecmint:~# df

Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sda1       47929224 7811908  37675948  18% /
none                   4       0         4   0% /sys/fs/cgroup
udev             1005916       4   1005912   1% /dev
tmpfs             202824     816    202008   1% /run
none                5120       0      5120   0% /run/lock
none             1014120     628   1013492   1% /run/shm
none              102400      44    102356   1% /run/user
/dev/sda5         184307   79852     94727  46% /boot
/dev/sda7       95989516   61104  91045676   1% /data
/dev/sda8       91953192   57032  87218528   1% /personal

df」 コマンドのその他の例については、記事「12 Linux での df コマンドの例」を参照してください。

30. コマンド: du

ファイルスペースの使用量を見積もります。ファイルごとにディスク使用量の概要を階層的に、つまり再帰的に出力します。

root@tecmint:~# du

8       ./Daily Pics/wp-polls/images/default_gradient
8       ./Daily Pics/wp-polls/images/default
32      ./Daily Pics/wp-polls/images
8       ./Daily Pics/wp-polls/tinymce/plugins/polls/langs
8       ./Daily Pics/wp-polls/tinymce/plugins/polls/img
28      ./Daily Pics/wp-polls/tinymce/plugins/polls
32      ./Daily Pics/wp-polls/tinymce/plugins
36      ./Daily Pics/wp-polls/tinymce
580     ./Daily Pics/wp-polls
1456    ./Daily Pics
36      ./Plugins/wordpress-author-box
16180   ./Plugins
12      ./May Articles 2013/Xtreme Download Manager
4632    ./May Articles 2013/XCache

注意: ‘df’ はファイル システムの使用統計のみを報告しますが、一方、‘du’ はディレクトリの内容を測定します。 「du」コマンドの例と使用法については、「10 du (ディスク使用量) コマンド」を参照してください。

31. コマンド: rm

コマンド「rm」は削除を表します。 rm は、ファイルとディレクトリを削除するために使用されます。

ディレクトリの削除

root@tecmint:~# rm PassportApplicationForm_Main_English_V1.0

rm: cannot remove `PassportApplicationForm_Main_English_V1.0': Is a directory

ディレクトリは単に「rm」コマンドだけでは削除できません。「rm」とともに「-rf」スイッチを使用する必要があります。

root@tecmint:~# rm -rf PassportApplicationForm_Main_English_V1.0

警告: 「rm -rf 」コマンドは、誤って間違ったディレクトリに移動すると破壊的なコマンドになります。ディレクトリに「rm -rf」を実行すると、すべてのファイルとディレクトリ自体が突然永久に失われます。慎重に使用してください。

32. コマンド: echo

エコーは、名前が示すように、標準出力上のテキストをエコーします。これはシェルとは何の関係もありませんし、シェルは echo コマンドの出力を読み取りません。ただし、対話型スクリプトでは、echo はターミナルを介してユーザーにメッセージを渡します。これは、スクリプト、対話型スクリプトでよく使用されるコマンドの 1 つです。

root@tecmint:~# echo "linux-console.net is a very good website" 

linux-console.net is a very good website
小さな対話型スクリプトを作成する

1. デスクトップに「interactive_shell.sh」という名前のファイルを作成します。 (拡張子「.sh」が必須であることに注意してください)。
2. 以下のスクリプトと全く同じものをコピーして貼り付けます。

#!/bin/bash 
echo "Please enter your name:" 
   read name 
   echo "Welcome to Linux $name"

次に、実行権限を設定してスクリプトを実行します。

root@tecmint:~# chmod 777 interactive_shell.sh
root@tecmint:~# ./interactive_shell.sh

Please enter your name:
Ravi Saive
Welcome to Linux Ravi Saive

注意: 「#!/bin/bash」 はシェルにそれがスクリプトであることを伝えます。スクリプトの先頭に含めることが常に推奨されます。 「読み取り」は、指定された入力を読み取ります。

33. コマンド: passwd

これは、ターミナルで自分のパスワードを変更するのに役立つ重要なコマンドです。明らかに、セキュリティ上の理由から現在のパスワードを知る必要があります。

root@tecmint:~# passwd 

Changing password for tecmint. 
(current) UNIX password: ******** 
Enter new UNIX password: ********
Retype new UNIX password: ********
Password unchanged   [Here was passowrd remians unchanged, i.e., new password=old password]
Enter new UNIX password: #####
Retype new UNIX password:#####

34. コマンド: lpr

このコマンドは、コマンドラインで指定されたファイルを指定されたプリンターに印刷します。

root@tecmint:~# lpr -P deskjet-4620-series 1-final.pdf

: 「lpq」 コマンドを使用すると、プリンタのステータス (稼働しているかどうか) と印刷を待機しているジョブ (ファイル) を表示できます。

35. コマンド: cmp

任意のタイプの 2 つのファイルを比較し、結果を標準出力に書き込みます。デフォルトでは、‘cmp‘ ファイルが同じ場合は 0 を返します。それらが異なる場合は、最初の違いが発生したバイトと行番号が報告されます。

このコマンドの例を示すために、次の 2 つのファイルを考えてみましょう。

ファイル1.txt
root@tecmint:~# cat file1.txt

Hi My name is Tecmint
ファイル2.txt
root@tecmint:~# cat file2.txt

Hi My name is tecmint [dot] com

次に、2 つのファイルを比較し、コマンドの出力を見てみましょう。

root@tecmint:~# cmp file1.txt file2.txt 

file1.txt file2.txt differ: byte 15, line 1

36. コマンド: wget

Wget は、Web からファイルを非対話型 (バックグラウンドで動作できる) ダウンロードするための無料ユーティリティです。 HTTPHTTPSFTP プロトコル、およびHTTP プロキシをサポートします。

wgetを使ってffmpegをダウンロードする

root@tecmint:~# wget http://downloads.sourceforge.net/project/ffmpeg-php/ffmpeg-php/0.6.0/ffmpeg-php-0.6.0.tbz2

--2013-05-22 18:54:52--  http://downloads.sourceforge.net/project/ffmpeg-php/ffmpeg-php/0.6.0/ffmpeg-php-0.6.0.tbz2
Resolving downloads.sourceforge.net (downloads.sourceforge.net)... 216.34.181.59
Connecting to downloads.sourceforge.net (downloads.sourceforge.net)|216.34.181.59|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://kaz.dl.sourceforge.net/project/ffmpeg-php/ffmpeg-php/0.6.0/ffmpeg-php-0.6.0.tbz2 [following]
--2013-05-22 18:54:54--  http://kaz.dl.sourceforge.net/project/ffmpeg-php/ffmpeg-php/0.6.0/ffmpeg-php-0.6.0.tbz2
Resolving kaz.dl.sourceforge.net (kaz.dl.sourceforge.net)... 92.46.53.163
Connecting to kaz.dl.sourceforge.net (kaz.dl.sourceforge.net)|92.46.53.163|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 275557 (269K) [application/octet-stream]
Saving to: ‘ffmpeg-php-0.6.0.tbz2’

100%[===========================================================================>] 2,75,557    67.8KB/s   in 4.0s   

2013-05-22 18:55:00 (67.8 KB/s) - ‘ffmpeg-php-0.6.0.tbz2’ saved [275557/275557]

37. コマンド: マウント

マウント は、それ自体をマウントしないファイルシステムをマウントするために使用される重要なコマンドです。デバイスをマウントするには root 権限が必要です。

ファイルシステムを接続した後、まず「lsblk」を実行し、デバイスを識別し、デバイスに割り当てられた名前をメモします。

root@tecmint:~# lsblk 

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT 
sda      8:0    0 931.5G  0 disk 
├─sda1   8:1    0 923.6G  0 part / 
├─sda2   8:2    0     1K  0 part 
└─sda5   8:5    0   7.9G  0 part [SWAP] 
sr0     11:0    1  1024M  0 rom  
sdb      8:16   1   3.7G  0 disk 
└─sdb1   8:17   1   3.7G  0 part

この画面から、4 GB のペンドライブを接続したことが明らかでした。したがって、「sdb1」がマウントされるファイルシステムです。この操作を実行するにはルートになり、すべてのファイル システムがマウントされている /dev ディレクトリに移動します。

root@tecmint:~# su
Password:
root@tecmint:~# cd /dev

任意の名前のディレクトリを作成しますが、参照に関連するものでなければなりません。

root@tecmint:~# mkdir usb

次に、ファイルシステム「sdb1」をディレクトリ「usb」にマウントします。

root@tecmint:~# mount /dev/sdb1 /dev/usb

これで、ターミナルまたはX-windows システムから /dev/usb に移動し、マウントされたディレクトリからファイルにアクセスできるようになります。

38. コマンド: gcc

gcc は、Linux 環境の「c」言語用の組み込みコンパイラです。単純な c プログラム。Hello.c という名前でデスクトップに保存します (拡張子「.c」が必要であることに注意してください)。

#include <stdio.h>
int main()
{
  printf("Hello world\n");
  return 0;
}
コンパイルしてください
root@tecmint:~# gcc Hello.c
それを実行します
root@tecmint:~# ./a.out 

Hello world

: c プログラムをコンパイルすると、出力は新しいファイル「a.out 」に自動的に生成され、 プログラムをコンパイルするたびにc プログラムの同じファイル「a.out 」が変更されます。したがって、コンパイル中に出力ファイルを定義すると、出力ファイルが上書きされる危険がなくなります。

このようにコンパイルします
root@tecmint:~# gcc -o Hello Hello.c

ここで、「-o」は出力を「a.out」ではなく「Hello」ファイルに送信します。もう一度実行してください。

root@tecmint:~# ./Hello 

Hello world

39. コマンド: g++

g++ は、最初のオブジェクト指向プログラミング言語である「C++」の組み込みコンパイラです。単純な C++ プログラム。Add.cpp という名前でデスクトップに保存します (拡張子「.cpp」が必要であることに注意してください)。

#include <iostream>

using namespace std;

int main() 
    {
          int a;
          int b;
          cout<<"Enter first number:\n";
          cin >> a;
          cout <<"Enter the second number:\n";
          cin>> b;
          cin.ignore();
          int result = a + b;
          cout<<"Result is"<<"  "<<result<<endl;
          cin.get();
          return 0;
     }
コンパイルしてください
root@tecmint:~# g++ Add.cpp
それを実行します
root@tecmint:~# ./a.out

Enter first number: 
...
...

: c++ プログラムをコンパイルすると、出力は新しいファイル「a.out 」に自動的に生成され、 プログラムをコンパイルするたびに、 C++ プログラムの同じファイル「a.out 」が変更されます。したがって、コンパイル中に出力ファイルを定義すると、出力ファイルが上書きされる危険がなくなります。

このようにコンパイルします
root@tecmint:~# g++ -o Add Add.cpp
それを実行します
root@tecmint:~# ./Add 

Enter first number: 
...
...

40. コマンド: java

Java は世界でよく使用されているプログラミング言語の 1 つで、高速、安全、信頼性が高いと考えられています。現在の Web ベースのサービスのほとんどは Java 上で実行されます。

以下のテストを tecmint.java という名前のファイルに貼り付けて、単純な Java プログラムを作成します (拡張子「.java」が必要であることに注意してください)。

class tecmint {
  public static void main(String[] arguments) {
    System.out.println("Tecmint ");
  }
}
javacを使用してコンパイルします
root@tecmint:~# javac tecmint.java
それを実行します
root@tecmint:~# java tecmint

: ほぼすべてのディストリビューションにはgcc コンパイラが同梱されており、多くのディストリビューションにはg++java コンパイラが組み込まれています。そうでない人もいるかもしれません。必要なパッケージをapt またはyum することができます。

貴重なコメントと、ここで見たい記事の種類を忘れずに記載してください。 Linux に関するあまり知られていない事実についての興味深いトピックをすぐに取り上げます。