LoginSignup
1
0

More than 5 years have passed since last update.

UNIXコマンドの使い方!

Posted at

フォルダ操作

・フォルダ作成 → mkdir
・ホームディレクトリに移動 → cd
・ひとつ上のディレクトリに移動 → cd -

[vagrant@localhost ~]$ mkdir lessons
[vagrant@localhost ~]$ cd lessons
[vagrant@localhost lessons]$ cd
[vagrant@localhost ~]$ 

ファイル操作

・ファイルの中身を見る → cat
・ファイルをコピー(現在のファイルはドット(.)で表現できる)→ cp

[vagrant@localhost lessons]$ cat hello.txt
[vagrant@localhost lessons]$ cp hello.txt .

コマンド履歴の活用

・履歴一覧表示 → history
・履歴にあるコマンドを使用 → ! + 履歴番号
・直前のコマンド使用 → !!

[vagrant@localhost ~]$ history
[vagrant@localhost ~]$ !551
[vagrant@localhost ~]$ !!

シンボリックリンク

・シンボリックリンク(よくアクセスするようになったものに別名をつけること)
 → ln -s パス シンボリックリンク名

・シンボリックリンクの消し方 → unlink シンボリックリンク名

[vagrant@localhost myapp]$ ln -s config/production/database/ dbconfig

[vagrant@localhost myapp]$ unlink dbconfig

管理者ユーザー

・管理者ユーザーにログイン → su -
・特定のコマンドのみを管理者ユーザーとして実行 → sudo

※rootユーザー(管理者)になって作業すると、重大なミスを犯してしまう可能性があるので、基本的にはsudoを使って作業するようにしましょう。

[vagrant@localhost lessons]$ su -
[root@localhost ~]#
[root@localhost ~]# exit
[vagrant@localhost lessons]$ sudo 特定のコマンド

便利機能

・tabキー → 補完
・コマンドキャンセル → Control + C
・コマンド履歴 → 矢印の上下

1
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
1
0