0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

実務で役立つLinuxコマンド集

Posted at

Linuxを使用する現場で頻繁に使うコマンドを、目的ごとにまとめました。これらを習得すれば、効率的に作業を進めることができます。

Linuxとは?

Linuxは、Unixに似たオープンソースのオペレーティングシステム(OS)です。世界中の開発者や企業によって共同で開発されており、サーバー、デスクトップ、モバイル端末、組み込みシステムなど、さまざまな用途で利用されています。

主な特徴:

オープンソース: 誰でも自由に利用・改良が可能。

高い安定性とセキュリティ: サーバー用途に最適。

多様なディストリビューション: Ubuntu、CentOS、Debianなど、ニーズに応じた選択が可能。

Linuxはコマンドライン操作が重要な役割を果たしており、効率的に操作するためには基本的なコマンドを理解することが不可欠です。

1. ファイル・ディレクトリ操作

ls: ディレクトリの内容を表示


ls -l  # 詳細表示
ls -a  # 隠しファイルも表示

cd: ディレクトリを移動

cd /path/to/directory
cd ..  # 一つ上のディレクトリに移動

pwd: 現在のディレクトリを表示

pwd

mkdir: 新しいディレクトリを作成

mkdir new_directory

rm: ファイルやディレクトリを削除

rm file.txt  # ファイルを削除
rm -r directory  # ディレクトリを削除

cp: ファイルやディレクトリをコピー

cp file.txt /destination/path
cp -r directory /destination/path  # ディレクトリをコピー

mv: ファイルやディレクトリを移動または名前変更

mv file.txt /new/path
mv old_name.txt new_name.txt

2. ファイル閲覧・検索

cat: ファイルの内容を表示

cat file.txt

less: ファイルをページごとに閲覧

less file.txt

grep: 特定の文字列を検索

grep "search_term" file.txt
grep -r "search_term" /path/to/directory  # ディレクトリ内を検索

find: ファイルやディレクトリを検索

find /path/to/search -name "*.txt"

wc: ファイル内の行数、単語数、文字数をカウント

wc -l file.txt  # 行数をカウント

3. パーミッション操作

chmod: ファイルやディレクトリの権限を変更

chmod 755 file.txt

chown: 所有者を変更

chown user:group file.txt

ls -l: パーミッションを確認

ls -l

4. プロセス管理

ps: 実行中のプロセスを確認

ps aux

top: システムのリアルタイムリソース使用状況を表示

top

kill: プロセスを終了

kill -9 <PID>

5. ネットワーク操作

ping: ネットワーク接続を確認

ping google.com

curl: HTTPリクエストを送信

curl http://example.com

netstat: ネットワーク接続を確認

netstat -tuln

scp: リモート間でファイルを転送

scp file.txt user@remote_host:/path/to/destination

6. 圧縮・解凍

tar: ファイルを圧縮/解凍

tar -czf archive.tar.gz directory/  # 圧縮
tar -xzf archive.tar.gz  # 解凍

zip/unzip: ZIPファイルを操作

zip -r archive.zip directory/
unzip archive.zip

7. パッケージ管理

apt (Ubuntu/Debian): パッケージをインストール/更新

sudo apt update
sudo apt install package_name

yum (CentOS/RHEL): パッケージをインストール/更新

sudo yum update
sudo yum install package_name

8. その他便利なコマンド

history: 実行履歴を確認

history

alias: よく使うコマンドを簡略化

alias ll='ls -la'

df: ディスクの空き容量を確認

df -h

du: ディレクトリの使用容量を確認

du -sh directory/

まとめ

これらのコマンドを覚えておくと、Linuxでの作業がスムーズになります。まずはよく使うコマンドから慣れていき、効率的な操作を目指しましょう!

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?