Linux shell tips and tricks
I’m using Linux shell on daily basis, but I often forgot some useful command or shell tip. Yes, I can remember commands, but I can’t say that if I used it just once for specific task. Then I started to write Linux shell tips in text file on my Dropbox account and now I decided to share that. This list will be updated over time. Also keep in mind that for some tips you will need to install additional software on your Linux distribution.
UPDATE: June 15, 2013
Send process to background:
|
|
Move process to foreground:
|
|
Generate random hex number where n is number of characters:
|
|
Execute commands from a file in the current shell:
|
|
Substring for first 5 characters:
|
|
SSH debug mode:
|
|
SSH with pem key:
|
|
Get complete directory listing to local directory with wget:
|
|
Create multiple directories:
|
|
List processes tree with child processes:
|
|
Create war file:
|
|
Test disk write speed:
|
|
Test disk read speed:
|
|
Get md5 hash from text:
|
|
Check xml syntax:
|
|
Extract tar.gz in new directory:
|
|
Get web headers with curl:
|
|
Modify timestamp of some file or directory (YYMMDDhhmm):
|
|
Download from ftp using wget:
|
|
Generate random password (16 char long in this case):
|
|
Quickly create a backup of a file:
|
|
Access Windows share:
|
|
Run command from history (here at line 100):
|
|
Unzip to directory:
|
|
Multiline text (CTRL + d to exit):
|
|
Create empty file or empty existing one:
|
|
Update date from Ubuntu NTP server:
|
|
Convert image from qcow2 to raw:
|
|
Run command repeatedly, displaying it’s output (default every two seconds):
|
|
List all users:
|
|
Mount root in read/write mode:
|
|
Mount a directory (for cases when symlinking will not work):
|
|
Send dynamic update to DNS server:
|
|
Recursively grep all directories:
|
|
List ten largest open files:
|
|
Show free RAM in MB:
|
|
Open Vim and jump to end of file:
|
|
Git clone specific branch (master):
|
|
Git switch to another branch (develop):
|
|
Git delete branch (myfeature):
|
|
Git delete remote branch:
|
|
Git push new branch to remote:
|
|
Print out the last cat command from history:
|
|
Run your last cat command from history:
|
|
Find all empty subdirectories in /home/user:
|
|
Get all from line 50 to 60 in test.txt:
|
|
Run last command (if it was: mkdir /root/test, below will run: sudo mkdir /root/test):
|
|
Create temporary RAM filesystem – ramdisk (first create /tmpram directory):
|
|
Grep whole words:
|
|
UPDATE: June 15, 2013
Source:http://www.techbar.me/linux-shell-tips/