$ 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
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
/tmp
$cd /mnt
$cd -
/tmp
將上一條命令中的 foo 替換爲 bar,並執行。
$ ^foo^bar
$touch testfile
$^touch^cat
cat testfile
$^touch^cat
cat testfile
快速備份或複製文件。
$ cp filename{,.bak}
$touch testfile
$cp testfile{,.bak}
$ls -a testfile*
testfile testfile.bak
$cp testfile{,.bak}
$ls -a testfile*
testfile testfile.bak
traceroute + ping google.com
$ mtr google.com
搜索命令歷史,但不執行。
$ !whatever:p
$!mtr:p
mtr google.com
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/
...
/root:
...
/tmp/:
...
/var/:
....
#ls !!:3
ls /var/
...
#ls /root /tmp/ /var/
/root:
...
/tmp/:
...
/var/:
....
#ls !!:2
ls /tmp/
...