目次情報の表示#
目次表示コマンド#
文法:
ls [-alrtAFR] [name...]
パラメータ:
- -a すべてのファイルとディレクトリを表示(. で始まる隠しファイルもリストされます)
- -d ディレクトリのみをリスト表示(ディレクトリ内のファイルは再帰的にリストしません)。
- -l ファイルとディレクトリの情報を長形式で表示、権限、所有者、サイズ、作成時間などを含む。
- -r ファイルとディレクトリを逆順で表示。
- -t 修正時間でソートし、最新のファイルが最初に表示されます。
- -A -a と同様ですが、"."(現在のディレクトリ)および ".."(親ディレクトリ)はリストしません。
- -F リストされたファイル名の後に記号を追加;例えば、実行可能ファイルには "*", ディレクトリには "/" を追加。
- -R ディレクトリ内のすべてのファイルとサブディレクトリを再帰的に表示。
例:
ls -l
出力:
合計 12
drwxr-xr-x 2 user user 4096 6月 23 09:30 Documents
drwxr-xr-x 2 user user 4096 6月 23 09:30 Pictures
drwxr-xr-x 2 user user 4096 6月 23 09:30 Videos
-rw-r--r-- 1 user user 0 6月 23 09:30 file1.txt
ディレクトリ切り替えコマンド#
文法:
cd [dirName]
パラメータ:
-
dirName 切り替える対象のディレクトリ。
-
~ 自分のホームディレクトリに移動
-
../.. 上の 2 つの階層に移動
例:
cd /home/user/Documents
現在のパス表示コマンド#
文法:
pwd
例:
pwd
出力:
/home/user/Documents
システム情報表示コマンド#
文法:
uname
例:
uname
出力:
Linux
画面クリアコマンド#
文法:
clear
例:
clear
ファイル内容表示コマンド#
文法:
cat [file...]
パラメータ:
- file 内容を表示するファイル。
例:
cat file1.txt
出力:
Hello, world!
ユーザー権限切り替えコマンド#
文法:
sudo [command]
パラメータ:
- command 管理者権限で実行するコマンド。
例:
sudo apt-get update
ファイルコピーコマンド#
文法:
cp [option] source destination
パラメータ:
-
-i, --interactive 上書き前に確認を行う。
-
-v, --verbose コピー過程の詳細情報を表示。
-
source コピーする元のファイルまたはディレクトリ。
-
destination 目的のファイルまたはディレクトリ。
例:
cp file1.txt file2.txt
ユーザー切り替えコマンド#
文法:
su [user]
パラメータ:
- user 切り替えるユーザー。
例:
su user2
ファイル移動コマンド#
文法:
mv [option] source destination
パラメータ:
-
-i, --interactive 上書き前に確認を行う。
-
-v, --verbose 移動過程の詳細情報を表示。
-
source 移動する元のファイルまたはディレクトリ。
-
destination 目的のファイルまたはディレクトリ。
例:
mv file1.txt /home/user/Documents
フォルダ作成コマンド#
文法:
mkdir [option] directory...
パラメータ:
-
-p, --parents 親ディレクトリを作成(存在しない場合)。
-
directory 作成するディレクトリ。
例:
mkdir documents
ファイル作成コマンド#
文法:
touch [option] file...
パラメータ:
-
-a, --time=atime アクセス時間を変更。
-
-c, --no-create 新しいファイルを作成しない。
-
-m, --time=mtime 修正時間を変更。
-
-r, --reference=FILE 指定ファイルの時間情報を使用。
-
file 作成するファイル。
例:
touch file1.txt
削除コマンド#
文法:
rm [option] file...
パラメータ:
-
-f, --force 存在しないファイルを無視し、警告を表示しない。
-
-i, --interactive 確認プロンプトを表示。
-
-r, -R, --recursive ディレクトリとその内容を再帰的に削除。
-
file 削除するファイルまたはディレクトリ。
例:
rm file1.txt
ディレクトリ削除コマンド#
文法:
rmdir [option] directory...
パラメータ:
-
-p, --parents 空であれば親ディレクトリを削除。
-
directory 削除するディレクトリ。
例:
rmdir documents
ネットワーク設定情報表示コマンド#
文法:
ifconfig
例:
ifconfig
出力:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.10 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::c6e9:84ff:fe87:6835 prefixlen 64 scopeid 0x20<link>
ether c4:e9:84:87:68:35 txqueuelen 1000 (Ethernet)
RX packets 45574 bytes 33661624 (33.6 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 23257 bytes 2469127 (2.4 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
再起動コマンド#
文法:
reboot
例:
reboot
シャットダウンコマンド#
文法:
poweroff
例:
poweroff
システムヘルプコマンド#
文法:
man [command]
パラメータ:
- command ヘルプを表示するコマンド。
例:
man ls
データ同期ディスク書き込みコマンド#
文法:
sync
例:
sync
ファイル検索コマンド#
文法:
find [path...] [expression]
パラメータ:
- path 検索するパス。
- expression 一致させる表現。
例:
find /home/user -name "*.txt"
出力:
/home/user/Documents/file1.txt
/home/user/Documents/file2.txt
内容検索コマンド#
文法:
grep [option] pattern [file...]
パラメータ:
-
-i, --ignore-case 大文字と小文字を無視。
-
-r, --recursive ディレクトリ内のファイルを再帰的に検索。
-
-l, --files-with-matches 一致する項目を含むファイル名のみ表示。
-
pattern 検索するパターン。
-
file 検索するファイル。
例:
grep "Hello" file1.txt
出力:
Hello, world!
フォルダサイズ表示コマンド#
文法:
du [option] [directory...]
パラメータ:
-
-s, --summarize 合計サイズのみ表示。
-
-h, --human-readable 人間が読みやすい形式でサイズを表示。
-
directory サイズを表示するディレクトリ。
例:
du -sh /home/user/Documents
出力:
4.0K /home/user/Documents
ディスクスペースチェックコマンド#
文法:
df [option] [file...]
パラメータ:
-
-h, --human-readable 人間が読みやすい形式でサイズを表示。
-
file スペースをチェックするファイル。
例:
df -h
出力:
ファイルシステム 容量 使用済み 利用可能 使用% マウントポイント
/dev/sda1 100G 50G 50G 50% /
gedit で特定のファイルを開くコマンド#
文法:
gedit [file...]
パラメータ:
- file:開くファイル。
例:
gedit file1.txt
現在のシステムプロセス表示コマンド#
文法:
ps [option]
パラメータ:
- -a, --all:すべてのプロセスを表示、他のユーザーのプロセスも含む。
- -u, --user=USER:指定したユーザーのプロセスのみ表示。
- -x, --deselect:端末に関連するプロセスを表示しない。
- -e:-A と同等、すべてのプロセスを表示。
- -f:詳細なプロセス情報を表示。
- -l:長形式でプロセス情報を表示。
- -p PID:指定した PID のプロセスのみ表示。
- -U, --userlist=USERLIST:指定したユーザーリストのプロセスを表示。
例:
ps -ef
出力:
UID
PID PPID C STIME TTY TIME CMD
root 1 0 0 09:30 ? 00:00:01 /sbin/init
root 2 0 0 09:30 ? 00:00:00 [kthreadd]
root 3 2 0 09:30 ? 00:00:00 [rcu_gp]
...
プロセスのリアルタイム実行状態表示コマンド#
文法:
top
例:
top
ファイルタイプ表示コマンド#
文法:
file [file...]
パラメータ:
- file:タイプを表示するファイル。
例:
file file1.txt
出力:
file1.txt: ASCII text
この記事は Mix Space によって xLog に同期更新されました
元のリンクは https://api.xn--i2r.cc/posts/Linux-Study/LS1