1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

独学エンジニアが1年半知らなかった、使わなかったlinuxの便利なコマンド

Posted at

まずは、historyから。
コマンドの履歴を表示してくれる。

$ history

ログアウトしても以前に実行したコマンド履歴が観れるのだが、それは、「bash_history」という隠しファイルにあるらしい。

$ cat ~/.bash_history 

で確認。

以下の二つが衝撃だった。(恥ずかしながら知らなかった。。。そりゃこんなコマンドあるに決まってるよな。。。)

Ctrl + Aでコマンドの先頭へいき、Ctrl + Kでコマンド一括削除

$ Ctrl + A
$ Ctrl + K

rails g contorller~~~~~~なんて長いコマンドを消すのは大変だったがこれで一発。

こちらは、直前に実行したコマンドを再実行してくれる。

「↑キー」押してエンターとまあ変わらないか。。。。

$ !!

直前にいたディレクトリに移動するコマンド。頻繁にディレクトリを移動する時とかは便利。

$ cd ~_

以下は、以前に実行したコマンドを検索してくれる。

$ Ctrl + R

を押すと、ターミナル上で

(reverse-i-search)`': 

のように変化するので、ここで好きな文字で検索できる。

linuxの本をちらっと読んでみて知らなくて便利なコマンドが割とあった。
特に、検索系とか一括操作系は考えたら「当然ある」訳で、今後の教訓にもなった。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?