Linux Command

以 root 帳戶執行上一條命令。

$ sudo !!

$apt-get update
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock the list directory
$sudo !!
sudo apt-get update


更改到上一次訪問的目錄。
$ cd -

$pwd
/tmp
$cd /mnt
$cd -
/tmp


將上一條命令中的 foo 替換爲 bar,並執行。

$ ^foo^bar

$touch testfile
$^touch^cat
cat testfile


快速備份或複製文件。
$ cp filename{,.bak}

$touch testfile
$cp testfile{,.bak}
$ls -a testfile*
testfile    testfile.bak


traceroute + ping google.com
$ mtr google.com


搜索命令歷史,但不執行。

$ !whatever:p
$!mtr:p
mtr google.com


將 ssh keys 複製到 user@host 以啓用無密碼 SSH 登錄。
$ssh-copy-id user@host

$ ls !!:2
#ls /root /tmp/ /var/
/root:
...

/tmp/:
...

/var/:
....
#ls !!:3
ls /var/
...

#ls /root /tmp/ /var/
/root:
...

/tmp/:
...

/var/:
....
#ls !!:2
ls /tmp/
...


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章