0
0

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コマンド完全まとめ【初心者〜中級者向け】

🔰 基本操作

ls - ファイルやディレクトリの一覧を表示

ls
ls -l         # 詳細表示
ls -a         # 隠しファイルも含めて表示
ls -lh        # サイズを人間にわかりやすく

cd - ディレクトリの移動

cd /path/to/dir
cd ..          # 一つ上の階層へ
cd ~           # ホームディレクトリへ

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

pwd

mkdir / rmdir - ディレクトリの作成・削除

mkdir newdir
rmdir newdir
mkdir -p a/b/c  # ネスト作成可

touch - 空ファイルの作成・タイムスタンプ更新

touch file.txt

📁 ファイル操作

cp - ファイルやディレクトリのコピー

cp source.txt dest.txt
cp -r dir1 dir2  # ディレクトリごとコピー

mv - ファイルやディレクトリの移動/名前変更

mv old.txt new.txt
mv file.txt ../  # 親ディレクトリへ移動

rm - 削除(⚠慎重に!)

rm file.txt
rm -r dir/          # ディレクトリごと削除
rm -rf dir/         # 強制削除(超注意)

📄 内容確認・検索

cat, less, more - ファイル表示

cat file.txt
less file.txt
more file.txt

head, tail - 一部表示

head -n 10 file.txt
tail -n 20 file.txt
tail -f log.txt  # リアルタイム表示

grep - テキスト検索

grep "keyword" file.txt
grep -r "keyword" ./logs/
grep -i "error" file.txt  # 大文字小文字無視

🔍 高度な検索

find - ファイル検索

find . -name "*.log"
find /var -type f -mtime -1  # 1日以内に更新されたファイル

locate(要 mlocate インストール)

locate filename.txt

🛠 権限・所有者

chmod - パーミッション変更

chmod 755 script.sh
chmod +x script.sh  # 実行権限付与

chown - 所有者変更

chown user:group file.txt

📦 圧縮・解凍

tar - アーカイブ作成・展開

tar -cvf archive.tar dir/
tar -xvf archive.tar
tar -czvf archive.tar.gz dir/
tar -xzvf archive.tar.gz

zip / unzip

zip -r archive.zip folder/
unzip archive.zip

🔄 ネットワーク・プロセス

ps / top / htop

ps aux | grep nginx
top
htop  # UI付き(要インストール)

netstat / ss / lsof

netstat -tuln
ss -tulnp
lsof -i :80

ping / curl / wget

ping google.com
curl http://example.com
wget http://example.com/file.zip

⚙ システム情報・ディスク管理

df, du - ディスク使用量

df -h        # マウントごとの使用量
du -sh *     # ディレクトリ単位のサイズ

free - メモリ情報

free -h

uptime, top - 稼働状況確認

uptime
top

🔐 パーミッションとユーザー管理

whoami, id, groups

whoami
id
groups user

useradd, passwd, usermod, deluser

sudo useradd newuser
sudo passwd newuser
sudo usermod -aG sudo newuser
sudo deluser newuser

🧹 ログ確認・サービス管理(Systemd)

journalctl, systemctl

journalctl -xe            # エラーの詳細表示
systemctl status nginx    # サービスの状態
systemctl start nginx
systemctl stop nginx
systemctl enable nginx    # 起動時自動起動

🧪 その他便利コマンド

alias, history, crontab

alias ll='ls -l'
history | grep ssh
crontab -e       # 定期実行設定

date, cal, uptime

date
cal
uptime
0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?