LoginSignup
0
0

More than 1 year has passed since last update.

Linuxコマンドをまとめる(自分用)

Posted at

実行中プロセス表示

ps

プロセスを終了させる

kill [PID] 

ディレクトリの操作

// カレントディレクトリの確認
pwd

// ファイルなどを一覧表示
ls

// ファイルとディレクトリの区別をして表示
ls -F

// 隠しファイルを表示
ls -Fa

// ホームディレクトリへ移動
cd
cd ~

// ルートディレクトリ(システム)へ移動する
cd /

// 一つ上の階層のディレクトリへ移動する
cd ../

// ホームディレクトリの中の特定のディレクトリに移動する
例: Directory1/Directory2に移動する場合
cd Directory1/Directory2

//どこかのディレクトリから直でどこかのディレクトリへ移動する
例: Directory1/Directory2 から Directory-A/Directory-Bに移動する場合
cd ~/Directory-A/Directory-B

// ディレクトリを作成する
例:testというディレクトリを作る
mkdir test

// ディレクトリを削除する
例:testというディレクトリを削除する
rmdir test

ファイルやディレクトリの操作

// 空のファイルを作成する
例:testFileという殻のファイルを作成する
touch testFile

// ファイルやディレクトリをコピーする
例:Directory-AをDirectory-Bにコピーベント
cp -R Directory-A Directory-B

// ファイルやディレクトリを移動させる
例:Directory-AにあるtestFileをDirectory-Bへ移動する
cd Directory-A
mv testFile Directory-B

// ファイルやディレクトリの名前を変更する
例:Directory-BにあるtestFileをTestFileに名前を変える
mv testFile TestFile
同ディレクトリの場合はファイル名の変更になる

// ファイルを削除する
例:TestFileを削除する
rm TestFile

// ディレクトリを削除する
例:Directory-Cを削除する
rm -R Directory-C

パーミッション(権限)

// 権限を確認する
ls -la

結果の例
-rw------- user root 4096 jul 12 11:05 .zshrc
-rw-r--r-- user root 省略
(パーミッション ユーザ グループ 最終更新日時 ファイル名) 

// パーミッションの変更
chmod パーミッション ファイル名

r:読み取り、w:書き込み、x:実行
rwx:111(7),rw-:110(6),r-x:101(5),r--:100(4),-wx:011(3),-w-:010(2),--x:001(1),---:000(0)

111や110などは2進表記。
rwx r-- -wx(rwxr---wx)の場合は"743"となる

// testFileのパーミッションを変える
例:パーミッションを743に変えてみる
chmod 743 testFile

// ファイルの所有者を変更する
例:testFileの所有者をuser2へ変える
chown user2 testFile

// ファイルのグループを変更する
例:testFileのグループをrootへ
chgrp root testFile


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