commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for:
If you have tried to change your prompt and made a mistake, use this command to retrieve a standard prompt.
If you used the export command when you changed your prompt, also use it there:
export PS1='$PWD$ '
Solution to activate (or deactivate with false instead of true) the global mandatory proxy under Ubuntu (not tested elsewhere).
Others keys you can configure :
gconftool-2 --set "/system/http_proxy/host" --type string "
gconftool-2 --set "/system/http_proxy/port" --type int 8080
gconftool-2 --set "/system/http_proxy/ignore_hosts" --type list --list-type string ["localhost","127.0.0.1","*.local"]
gconftool-2 --set "/system/proxy/mode" --type string manual
When you need to work a long time in the same directory, which prompt is of the type:
bob@ubuntu:~/directory1/directory2/directory3/directory4/directory5$
it is better to hide all this with the command PS1='$'
To retrieve a normal prompt, type: PS1='$PWD$ '
watch the seconds of your life tick away - replace YYYY-mm-dd HH:MM:ss w/ your birthtime.
used in an if-then-else in case the default shell is ksh, not bash.
The $(basename ${0#-}) is handy to echo which shell and strip the dash some flavors put in front of "bash"
if [ $(basename ${0#-}) == "bash" ] ; then
export PS1='\[\e]0;\h \u \w\a\]\n\[\e[0;34m\]\u@\h \[\e[33m\]\w\[\e[0;32m\]\n\$ '
else
HOST=`hostname`
ESC=`echo "\033"`
BEL=`echo "\007"`
RAW=`echo "\r"`
export PS1='-${RAW}${ESC}]0;${HOST} ${USER}${BEL}-${ESC}[0;34m${USER}${ESC}[0m@${ESC}[0;34m${HOST%%.*}${ESC}[0;33m${ESC}[0m $ '
fi
this application monitors the apps you use most often and load them into memory with their libraries and other dependencies.
So now, when you launch Firefox or Thunderbird or OpenOffice, the display is immediate as on Mac.
The example will create a directory called "
Caveats: @imports of css files will not be converted.
special thanks to XwZ :)
HTP (HTTP Time Protocol) is an alternative way of getting "good enough" synchronized time. htpdate will give you near-second accuracy.
It works where NTP/SNTP does not because of firewalls and proxies. Of course, if NTP/SNTP can be used, use that instead.
http://www.clevervest.com/twiki/bin/view/HTP
htp is not in Ubuntu!
OMG, you are a Gentoo junkie.
-funroll-loops-me-harder ;-)
ccache is a compiler cache, which speeds up your compiler on successive runs, because it caches intermediate compiled output.
I sometimes want to know what packages are installed on my Ubuntu system. I still haven't figured out how to use aptitude effectively, so this is the next best thing. This allows finding by name.
The grep '^ii' limits the display to only installed packages. If this is not specified, then it includes listing of non-installed packages as well.
Given a GNU Make file version 3.81 with the following entries:
.PHONY: runtest
runtest: $(ARCHNAME) $(TESTAUTOEXES)
@for i in $(TESTAUTOEXES) ; do \
echo ">>>> Running test harness $$i" ; \
env $(RUNTESTENV) $$i ; done
.PHONY: runtestsingle
runtestsingle: $(ARCHNAME)/test/auto_$(testsingle).exe $(ARCHNAME)
@for i in $< ; do \
echo ">>>> Running test harness $$i" ; \
env $(RUNTESTENV) $$i ; done
(ARCHNAME is something like ix86-linux-gnu)
Instead of typing gmake runtest to run all the tests, you can run one specific test with the example command.
The sample output is from compiling a C++ program using Boost::Test testing framework.
Replace 10.0.0.0/8 with your largest local subnet. replace 10.1.1.123:3128 with your proxy information.. Note this only works with a proxy server configured for passive setup..
Now your firefox transparently proxy's stuff destined outside your network.. and Doesn't proxy stuff inside your network. as well as all your other favorite web applications. curl, wget, aria2 ect.
I can remember "cp -av" on Unix like systems to copy files and directories. The same can be done on Windows without extra software, somewhat.
The switches mean:
/E Copies directories and subdirectories, including empty ones.
Same as /S /E. May be used to modify /T.
/H Copies hidden and system files also.
/Y Suppresses prompting to confirm you want to overwrite an
existing destination file.
/Z Copies networked files in restartable mode.
/I If destination does not exist and copying more than one file,
assumes that destination must be a directory.
/K Copies attributes. Normal Xcopy will reset read-only attributes.
/F Displays full source and destination file names while copying.
I don't type that all the time, I stick it into a file called "cpav.cmd" and run that.
echo xcopy /e/h/y /z/i /k /f %1 %2 > cpav.cmd
cpav zsh zsh2
dd for windows is available from http://www.chrysocome.net/dd
Tested with CD-ROMs like Linux install discs
I don't know about DVD-ROMs.
In the Windows cmd.exe window, you can change the directory using cd, but if you need to go to a directory on another drive, you need to type in the drive letter and colon first (e.g. d:). With the /d on cd, you don't need this intermediate step.
cd /?
Tested on Windows XP
Sometimes I want to use the mouse to move/copy/delete files.
(I also sometimes feel like a nut, sometimes I don't.)
This is for Windows 2000 and later, probably.
Tested on Windows XP, cmd.exe.
This works in bash and zsh.
You may also want to alias it, if you need to look at it often...
alias lpath="echo \$PATH | tr : \\\\n"
"\$PATH" to make sure to look at your current $PATH
On Windows 2000 or later, this command will give a listing of all the registered Windows services. You can then know what the name of a command is in order to start and stop it.
e.g.
sc start Apache2.2
or
net start Apache2.2
Please note that sc will allow the SERVICE_NAME only, while net will allow both SERVICE_NAME and DISPLAY_NAME.
Note that the space between the = and the next word are important. Not very unixy, that.
http://www.ss64.com/nt/sc.html