Once in a while a developer has to say goodbye to his or her favourite text editor and go commando-style command-line editing with nothing but basic linux skills and vi. This is the bare minimum you need to know if you want to survive the black screen.
The tilde ~ refers to the home page
The dot . refers to current directory
Moving one directory up:
Move to the home directory:
Move to the root folder
Move to the folder public in the current directory
Get a overview:
with flags -a for all and -l for long format.
Get a recursive directory view
Find all files with .php extension by recursion from current directory
find -name "*.php"
Find all files with .php extension but exclude the Zend folder
find -name "*.php" ! -path "*/Zend/*"
find -iname "test.php"
Finding text in files
Find the text string userName in any file in the current directory
grep "userName" ./
Find one word but not another word in a file
grep "xxx" | grep -v "yyy"
Find the text string user in any file but not .svn files
find ! -name "*.svn-base" | xargs grep -iln "user" 2>/dev/null
2>/dev/null will supress any No such file or directory notice. The flag -i makes the query case-insensitive and the the flag -l will make sure only the filenames are printed. The line number is printed with the flag -n.
Find the text string user in any file but exclude the cache folder
find -path ./cache -prune -o | xargs grep -in "user" 2>/dev/null
File / directory manipulation
Create a file
Delete a file
Delete a directory by recursion
rm -Rf dirname
Create a directory
Delete a directory
Vi text editor
Two major text editors are vi and the more extensive vim (Vi IMproved).
Open a file
Open a file at a specific line number
vi filename.text +200
Switch to edit mode
A stands for addition
Save a file
control C followed by
Save a file and exit
control C followed by
Find a text string
For the next instance type
n, for the previous instance type
Goto line number 200
Copy and paste:
yy (y = yanked) to copy 10 lines starting from the current line and then move the cursor to the position for pasting and
Delete a section:
Repeat above but use d (= delete) instead of y.
* In case of a
CTRL s event see: https://raam.org/2007/recovering-from-ctrls-in-putty/
* For multiscreen Putty sessions see SuperPutty.