Remove the last word when typing a command in Bash
Answer:
When you are typing a command in Bash shell, , to quickly remove the last typed word, press "Ctrl + w"
This trick is very handy and should be known by all Bash users.
Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.
Remove the last word when typing a command in Bash
Answer:
When you are typing a command in Bash shell, , to quickly remove the last typed word, press "Ctrl + w"
This trick is very handy and should be known by all Bash users.
Swap last two characters in Bash
Answer:
Sometimes it is easy to mis-type characters in the wrong order, e.g. typed "sl" instead of "ls"
To swap it, use the little know Bash's trick: Ctrl + t
E.g.
# sl
[Ctrl + t]
Allow a remote IP for incoming connection in UFW (Uncomplicated firewall)
Answer:
To allow a remote IP for incoming connection in Ubuntu's UFW (Uncomplicated firewall), you can use the following command:
# sudo ufw allow from x.x.x.x
Of course you need to reload the firewall.
# sudo ufw reload
Disable auto indent when pasting text into vim
Answer:
When you copy multiple lines text and paste it into the vim , sometimes you might find the text is aligned wrongly as the following:
Line1
Line 2
Line 3
Line 4
To solve this problem, enter the paste mode by
: set paste
Then do all the pasting works, and when finished, type
: set nopaste
How to diff two remote files over ssh?
Answer:
Assume you have two files on two different machine, how do you do a diff of them?
Simply use the command below:
# diff <(ssh server_1 'cat foo1') <(ssh server_2 'cat foo2')