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.
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:
This command modifies the preferences file of Firefox that is located in .mozilla/firefox/*.default/prefs.js. It edits the file with sed and the -i option. Then it searches the string "browser.startup.homepage", and the string next to it (second string). Finally, it replaces the second string with the new homepage, that is http://sliceoflinux.com in the example.
It doesn't work if you haven't set any homepage.
Prerequisites: module Pod::Webserver installed. You can install it typing:
sudo perl -MCPAN -e 'install Pod::Webserver'
You can replace elinks with your fav browser. For FF:
podwebserver& sleep 2; firefox -remote 'openurl( http://127.0.0.1:8020/, new-tab )'
If you have Firefox open, this will pop-up the index web in a new tab.
This command defragment the SQLite databases found in the home folder of the current Windows user.
This is usefull to speed up Firefox startup.
The executable sqlite3.exe must be located in PATH or in the current folder.
In a script use:
for /f "delims==" %%a in (' dir "%USERPROFILE%\*.sqlite" /s/b ') do echo vacuum;|"sqlite3.exe" "%%a"
Just refining last proposal for this check, showing awk power to make more complex math (instead /1024/1024, 2^20). We don't need declare variable before run lsof, because $(command) returns his output. Also, awk can perform filtering by regexp instead to call grep. I changed the 0.0000xxxx messy output, with a more readable form purging all fractional numbers and files less than 1 MB.
You have to do that before :
cd ~/.mozilla/firefox/<YOUR PROFILE>
Require bash. If you use something else, you may use
echo <CODE> | python
Forked from ArkSeth python script.
If you want all the URLs from all the sessions, you can use :
perl -lne 'print for /url":"\K[^"]+/g' ~/.mozilla/firefox/*/sessionstore.js
Thanks to tybalt89 ( idea of the "for" statement ).
For perl purists, there's JSON and File::Slurp modules, buts that's not installed by default.
Require "grep -P" ( pcre ).
If you don't have grep -P, use that :
grep -Eo '"url":"[^"]+' $(ls -t ~/.mozilla/firefox/*/sessionstore.js | sed q) | cut -d'"' -f4
This is really not cli but I think it's neat.
For Mac OS X users only
Sometime you need to run firefox from the command just to rectify something about it.Means,if some of the addon broke you firefox setting or theme broke your ff setting then fall back to commandline i.e shell and type the mentioned command. It will open up an information box with few option along with the checkbox besides them(means you can select them) to start the web browser in safe mode.Besically deactivating all the addon and theme,except the default one.Once you are done/rectified thing ..close that session and reopen the browser normally.It should work.
Sqlite database keeps collecting cruft as time passes, which can be cleaned by the 'vacuum;' command. This command cleans up the cruft in all sqlite files relating to the user you have logged in as. This command has to be run when firefox is not running, or it will exit displaying the pid of the firefox running.
Check which files are opened by Firefox then sort by largest size (in MB). You can see all files opened by just replacing grep to "/". Useful if you'd like to debug and check which extensions or files are taking too much memory resources in Firefox.
killall -CONT -m firefox
Suspends all Firefox Threads. Results in Zero CPU load.
Useful when having 100+ Tabs open and you temporarily need the power elsewhere.
Be careful - might produce RACE CONDITIONS or LOCKUPS in other processes or FF itself.
matching is case sensitive.
Sometimes Firefox crashes or is bad finished and the message the process is still running appear while it's not. This also works when you sharing account from a NIS server and try to open the browser on multiple computers.
Ever since the switch to pulseaudio, Ubuntu users including myself have found themselves with no sound intermittently. To fix this, just use this command and restarts firefox or mplayer or whatever.
To install a theme use:
sudo firefox -install-global-theme /path/to/theme
You can get the .xpi or .jar file from the versions history on the add-on/theme page.
NOTE: may not work in your system (Debian-based is an example).