Collections of Cool Linux Commands


Collections of Cool Linux Commands

Command History
Runs previous command but replacing
^foo^bar
Really useful for when you have a typo in a previous command. Also, arguments default to empty so if you accidentally run: echo "no typozs", you can correct it with ^z
^foo^bar replaces first instance of foo. If you want to replace multiple instances of a string, then you should use: !!:gs/foo/bar
Check command history, but avoid running it
!whatever:p
!whatever will search your command history and execute the first command that matches 'whatever'. If you don't feel safe doing this put :p on the end to print without executing.
Run the last command as root
sudo !!
Make sudo forget password instantly
sudo -K
Execute a command at a given time
echo "ls -lah >/foo/bar/ls.txt" |at 07:00
Execute a command without saving it in the history
command
Prepending one or more spaces to your command won't be saved in history, useful for pr0n or passwords on the commandline.

Salvage a broken terminal
reset
stty sane
If you bork your terminal by sending binary data to STDOUT or similar, you can get your terminal back using this command
Running scripts after a reboot for non-root users.
$ @reboot
Sometimes we may want to run a script when a system reboots. We can simply do this by just scheduling the script using vixie cron with the @reboot option

File && Directory
Prevent accidents and test your command with echo
echo rm *
Empty a file
> file.txt
List the size (in human readable form) of all sub folders from the current location
du -h --max-depth=1
Like top, but for files
watch -d -n 2 'df; ls -FlAt;'
Remove all but one specific file
rm -f !(survivior.txt)
Quickly backup or copy a file with bash
cp filename{,.bak}

SSH - Remote Server
Copy ssh keys to user@host to enable password-less ssh logins.
ssh-copy-id user@host
Compare a remote file with a local file
ssh user@host cat /path/to/remotefile | diff /path/to/localfile -
vimdiff scp://[@]/
vimdiff scp://[user@]host1/ scp://[user@]host2/
Start a tunnel from some machine's port 80 to your local post 2001
ssh -N -L2001:localhost:80 somemachine
Run command on a group of nodes in parallel
echo `date` | pee "ssh host1" "ssh host2" "ssh host3"

Network
Lists all listening ports together with the PID of the associated process
netstat -tlnp
List all open ports and their owning executables
lsof -i -P | grep -i "listen"

Download
Download an entire website
wget --random-wait -r -p -e robots=off -U mozilla http://www.example.com
-p parameter tells wget to include all files, including images.
-e robots=off you don't want wget to obey by the robots.txt file
-U mozilla as your browsers identity.
--random-wait to let wget chose a random number of seconds to wait, avoid get into black list.
Other Useful wget Parameters:
--limit-rate=20k limits the rate at which it downloads files.
-b continues wget after logging out.
-o $HOME/wget_log.txt logs the output
The default recursion depth is now 5, which is often enough to download entire sites. However, if you want to be sure, add a '-l 0' to remove the recursion depth limit.

Utilities
Serve current directory tree at http://$HOSTNAME:8000/
python -m SimpleHTTPServer
To use a different port:
python -m SimpleHTTPServer 8080
twistd -n web --path .
python -m smtpd -n -c DebuggingServer localhost:1025
Capture video of a Linux desktop
ffmpeg -f x11grab -s wxga -r 25 -i :0.0 -sameq /tmp/out.mpg
ffmpeg -f x11grab -r 25 -s 800x600 -i :0.0 /tmp/outputFile.mpg
Create a single PDF from multiple images with ImageMagick
$ convert *.jpg output.pdf
mtr, better than traceroute and ping combined
mtr google.com
Find out my Linux distribution name and version
cat /etc/*-release
cat /proc/version
lsb_release -a

Miscs
Display currently mounted filesystems in nice layout
mount | column -t
A very simple and useful stopwatch
time read (ctrl-d to stop)
Quick access to the ascii table.
man ascii
Clear the terminal screen
ctrl+l, clear
Pretend to be busy in office to enjoy a cup of coffee
$ for i in `seq 0 100`;do timeout 6 dialog --gauge "Install..." 6 40 "$i";done
cat /dev/urandom | hexdump -C | grep "ca fe"
Just make some data scrolling off the terminal.

4 Websites to Learn Cool Linux Command Line Tricks
shell-fu
command-line-fu
snipt
good coders code, great reuse

Resources
http://www.commandlinefu.com

From Apprentice to Master


How to Become a Great Programmer

From Apprentice to Master

Emptying Your Cup
Ask the most experienced and available programmer you know for ongoing help.
Never become completely dependent on your more experienced friend to solve all your problems.
Have an actual problem to solve

Learn to think differently by/when learning a new language
Set your previous knowledge aside as you approach new situations.
Make sure your new implementation follows the idioms of the new language.
Unleash Your Enthusiasm (to your team)
Inject some excitement, your ideas, intelligence, and passions into your team.
Question everything
Determine which of these skills would be immediately useful to the team, and strive to acquire the knowledge.
Expose Your Ignorance and Confront Your Ignorance
Brave to ask for help.

Prepare and grasp the opportunity to assume a high-profile role or solve a difficult problem.
Craft over Art
Place the interests of your customers over your desire to display skill
Nurture/Grow Your Passion and Keep Sustainable Motivations
Keep the sense of wonder/curiosity
Be ambitious about your career.
Draw Your Own Development/Career Map

Accurate Self-Assessment
Evaluate yourself frequently and know your weaknesses, and combat them.
Find Mentors to get advices
Kindred Spirits
Immerse into the community
Sweep the Floor for the team
Volunteer for unglamorous, yet necessary, tasks.

Perpetual Learning
Expand Your Bandwidth
Action Items:
l          Subscribe to software development blogs in Google Reader
l          Follow some software luminaries on Twitter
l          Subscribe to an online mailing list and answer people’s questions.
l          Join a newly formed local technology user group
l          Attend technical conference
l          There are hundreds of online academic courses, podcasts, and videos (Google Tech Talks) on iTunes and YouTube.

Keep Practice and Make Breakable Toys
Use the Source, Read and Learn from the code
Use your skills you learn at work
Reflect As You Work
Observation, reflection, and learn from your own activities, your colleagues.
Take notes everywhere, anytime
Record What You Learn and Share What You Learn

Create Feedback Loops
Solicit feedback early, often, and effectively, be conscious of your incompetence.
Pay careful attention to any feedback; avoid defending your behaviors, your skills.
Learn How/Why You Fail

Construct Your Curriculum

Build and Maintain Your Reading List
Read Constantly
Study the Classics

Dig Deeper
Get your information from primary sources
Understand the forces that led to a design rather than just the details of a design.
Understand Why - the problems trying to solve
Understand How it is solved, implemented.

Letting go of familiar and valuable tools
Keep an open mind and learn something new
Understand your tools, knowledge will become obsolete, they need be upgraded.
Discover problems of the tools you use, find whether there are better alternatives.
If not, it's your time to show your talent.

Resources
Apprenticeship Patterns: Guidance for the Aspiring Software Craftsman

My Reading List for 2010


My Reading List for 2010


As suggested in the book - Apprenticeship Patterns: Guidance for the Aspiring Software Craftsman, it's time to make my reading book list for 2010 to track the books I plan to read, and remember the books I have read.

This is just a book list I plan to read; maybe or maybe not I will finish reading them one day.
I will constantly update this list, and one year later I would like to see what I have read, what I have improved in this one year.

And if you occasionally visit this page, and have suggestions about what I should read next, what I should improve to be a successful software craftsman, please leave you comments.
I would be thankful for your kindly help and suggestions : )

Techniques:
RESTful Java with Jax-RS (Animal Guide)        [Done]
SOA
Java Soa Cookbook                                                 [Reading]
Cloud Computing
SAAS
OSGI
Database

Coding Skills
Clean Code: A Handbook of Agile Software Craftsmanship        [Reading]

Classic Software Books
Patterns of Enterprise Application Architecture
Design Patterns
Have read several books about this topic before, but I think I have never got a comprehensive and deep understanding about it.

Design Skills
Practical API Design: Confessions of a Java Framework Architect     [Reading]
Working Effectively with Legacy Code

Architect Skills
97 Things Every Software Architect Should Know: Collective

Become a better developer
Apprenticeship Patterns: Guidance for the Aspiring Software Craftsman    [Done]
The Passionate Programmer: Creating a Remarkable Career in Software Development (Pragmatic Life)        [Read Next]
The Pragmatic Programmer: From Journeyman to Master
97 Things Every Programmer Should Know: Collective Wisdom from the E

Algorithms
How to Think About Algorithms          [Reading]
The Algorithm Design Manual             [Reading]

Better thinking
Enhance the ability to think bigger, differently, and innovatively.
Pragmatic Thinking and Learning: Refactor Your Wetware (Pragmatic Programmers)
[Read Next]

Better Brain
Keep brain sharp and improve overall memory
TBD

Learn skills of learning
TBD

Other Skills
English Writing Skills
TBD

Green      – [Finished]
Yellow    – [Reading]
Pink        - [Read Next]

New Features in Java EE 6.0


New Features in Java EE 6.0

Profiles: Different Strokes for Different Folks
One of the major criticisms of Java EE has been that it is simply too large. Indeed, a majority of small to medium range Java web applications do not utilize the full Java EE stack.

The main goal of the Profiles is to address this issue, to reduce the size of the platform to suit the developer’s needs more efficiently.
Profiles are essentially sub-sets of Java EE APIs geared towards a particular class of applications in mind.

Java EE 6 includes the first of these profiles called Web Profile which is a subset of the Java EE platform designed for web application development. The Web Profile is the light-weight version of Java EE and includes only those technologies needed in most web applications, and does not include the enterprise technologies that these web applications typically don't need..
Pruning the Dead Wood
Since Java EE was first released in 1999, each release added new specifications. None of the features has been completely removed from the specification.

This became a problem in terms of size, implementation, the installation time, and adoption. Some features were not well supported or not widely deployed because they were technologically outdated or other alternatives were made available in the meantime.

The platform is weighted down with some dead wood in the shape of APIs that are outdated, not well supported or not widely deployed.

Java EE 6 has adopted the pruning process (also known as marked for deletion) already adopted by the Java SE group. Pruning these APIs would make the platform more lightweight and make room for healthier growth.

The suggested proposals are JAX-RPC, EJB 2.x Entity Beans CMP, JAXR (one of the few Java APIs for interfacing with UDDI registries)...
Richer
Provide significant enhancements in EJB, Servlets, JSF, and JSP technologies.
Servlet 3.0
Pluggability
Modular web.xml, web fragments to provide better support for frameworks
Allow programmatic addition of Servlets and Filters at start up time of an application
Asynchronous support
Ease of Development, Annotations vs. Deployment Descriptor
Other Miscellaneous Changes
HttpOnly Cookies
API changes
Contexts and Dependency Injection for Java EE
This(JCDI) allows developers to bind Java EE components to lifecycle contexts, to inject these components, and to enable them to support loosely coupled communication. Java EE components can also fire and get notified of events with JCDI. The benefit is that different kinds of objects, such as EJB 3 session beans, POJOs, and Java EE resources, can all be injected. JCDI provides a good facility for integrating the web tier and Java EE enterprise services.
JAX-RS 1.1 to create REST-based web services
Web Beans
Enterprise JavaBeans 3.1
EJB Lite
Removal of local business interface
Business interfaces also are not mandatory.
Packaging EJB components directly in a WAR file
Embeddable API for executing EJB in Java SE environment
This is to facilitate better support for testing, batch processing, and using EJB from the desktop applications.
Introduction of Singleton beans
Asynchronous Session Bean
JSF 2.0
JPA 2.0

Bean Validation 1.0 - annotation-based validation API

More Portable
Standard global JNDI names
Java EE 6 specifies a syntax for JNDI names that is the same across application servers
EJB 3.1 specifies an embedded container that is a standard API for executing EJBs within a Java SE environment.

Resources
The Java EE 6 Tutorial
Java EE 6 Overview
New Features in Java EE 6
New Features in Java EE 6.0
New Features in Servlets 3.0

Great Words to Replace Common Words


Vocabulary Workshop:

Great Words to Replace Common Words

Verb
begin, start, commence
rely on, depend on
follow, keep up with, up to date
take advantage of, utilize,
improve, boost, promote, advance, enhance
promote the trade between A and C.
Our understanding of human genetics has considerably advanced.
The publicity has enhanced his reputation.
assess, judge
desire, want
bear in mind that, remember
tackle, handle with, solve
prepare, prep(ping)
change, transform
The increasing population has transformed the landscape and structure of local industry structure.

emphasize, highlight, stress, accentuate
The report highlight the decline in the numbers of native plants and insects.
He stresses the need for parents to listen to their children.
The crisis accentuates the gap between rich and poor.

develop, cultivate, nurture
cultivate the ability of
cultivate a more relaxed and positive way towards life.
The sea nutures ample marine animals.

break, impair, undermine, jeopardize, fevastate
Undermine one’s ability/confidence/authority/position/credibility
Jeopardize the process of peace.
The earthquake devastated the whole city.

Keep, Preserve, Conserve, protect
deal With, tackle, resolve:
resolve dispute/conflict/problem/issue/crisis

adjective
external, third-party
right, correct
main, primary
effectively, efficiently
consistent with, compatible with
missing, absent
feasible, possible, probable
viable, valuable
beneficial, rewarding, helpful
exceedingly, extremely, intensely, very
hardly necessary, hardly inevitable,  unnecessary, avoidable
Everywhere, Widespread, Prevalent, Overflow, Rampant
Drug abuse is especially prevalent among teenagers.
The garden is overflew with colors of flowers.
H1n1 Virus is rampant in the world.

Good, Impressive, glorious, amazing, brilliant, incredible, attractive…


Beneficial(antonym:detrimental), Advantageous
The drug is beneficial to the immune system.
Advantageous industry 优势产业

Harmful, Unfavorable, horrible, disgusting
Inhumane: 没人性的
lousy (I’m fed up with the lousy job.)
severe (severe problem, illness, injuries.)
abysmal(低谷: their performance is abysmal.)
Detrimental: smoking is detrimental to your health.

Rich, Wealthy, Affluent, ample

Poor, Impoverished
The great depression had impoverished many third world countries.
an impoverished student.

Serious, Severe

Obvious, Manifest, Apparent, Evident, Patent
a manifest error judge
manifestly unfair system.
patent impossibilities. 显然不可能的事。

cheap, Economical:经济的,不浪费,而不是单纯指某物便宜, Inexpensive=cheap, Reasonable价格合理的, Affordable:能够支付的
economically affordable housing经济适用房
Reasonable price

Noun
estate, asset
applicant, candidate, interviewee
responsibility, duty
shopper, client, consumer, purchaser, customer
interaction, communication
Forefather, Ancestor, Predecessor

Difference, Gap, Distinction, schism
generation gap
sharp/clear distinction between allergy and food intolerance
heal the schism between clinical medicine and public health.

Crime,Delinquency
Criminal Act

Environment, Circumstance, Atmosphere, Ambience
under the circumstances
Surrounding:表示周围居住的环境,想当具体。Nearby可与之互换。The surrounding area.

Pollution, Contamination
contaminated water

Human, Individual/men/ones, Humankind
The human race
Humanity:特别指出,用来表示人性。其他一概不要用。虽然也有人之类的意思。

Danger, Hazard
Polluted water is a hazard to wild life and nature;safety/nature hazard.

In modern society, In contemporary society, In present-day society, In this day and age
Preposition
otherwise, or

Phrases:
frown on sth, be against, disagree with sth
next to/virtually impossible, , nearly/almost impossible
to name only a few, as an example,  for example, for instance
sth appeals to sb, sth exerts a tremendous fascination on sb, sb take interest in/sb. be interested in
little if anything, little or nothing, hardly
capture one's attention, attract one's attention.
give rise to, lead to, result in, trigger, cause
There are several reasons behind sth, reasons for sth
drive sb nuts, drive sb crazy
as stated earlier, as mentioned earlier
This is a time, this is an opportunity

Resources:
http://zhidao.baidu.com/question/110893239
http://music.yeshj.com/music/102460/
http://wenku.baidu.com/view/590ccbd233d4b14e85246881.html
http://joinyoung.yzu.edu.cn/bbs/redirect.php?tid=3181&goto=lastpost&sid=9yYyv9
3000 Most Common Words in American English

Labels

adsense (5) Algorithm (69) Algorithm Series (35) Android (7) ANT (6) bat (8) Big Data (7) Blogger (14) Bugs (6) Cache (5) Chrome (19) Code Example (29) Code Quality (7) Coding Skills (5) Database (7) Debug (16) Design (5) Dev Tips (63) Eclipse (32) Git (5) Google (33) Guava (7) How to (9) Http Client (8) IDE (7) Interview (88) J2EE (13) J2SE (49) Java (186) JavaScript (27) JSON (7) Learning code (9) Lesson Learned (6) Linux (26) Lucene-Solr (112) Mac (10) Maven (8) Network (9) Nutch2 (18) Performance (9) PowerShell (11) Problem Solving (11) Programmer Skills (6) regex (5) Scala (6) Security (9) Soft Skills (38) Spring (22) System Design (11) Testing (7) Text Mining (14) Tips (17) Tools (24) Troubleshooting (29) UIMA (9) Web Development (19) Windows (21) xml (5)