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:
Linux offers an interesting option to restrict the use of dmesg. It is available via /proc/sys/kernel/dmesg_restrict.
You can check the status with:
Alternatively you can use sysctl:
sudo sysctl -w kernel.dmesg_restrict=1
To make your change persistent across reboot, edit a fille in /etc/sysctl.d/.
Easiest way to get the external IP address.
Allows you to have a list of the domains on the server.
Rainbow Stream is a smart and nice Twitter client on terminal.
Almost everything you can do with a GUI application can be done, even viewing an image.
- Tab-autocomplete, history browsing
- Beautiful built-in themes and custom configuration support
- Tweet's images directly on your terminal.
# AllInOne: Update what packages are available, upgrade to new versions, remove unneeded packages
# (some are no longer needed, replaced by the ones from ap upgrade), check for dependencies
# and clean local cached packages (saved on disk but not installed?,some are needed? [this only cleans unneeded unlike ap clean]).
# aliases (copy into ~/.bashrc file):
a r='ap autoremove -y'
a up='ap update'
a u='up && ap upgrade -y --show-progress && r && ap check && ap autoclean'
# && means "and run if the previous succeeded", you can change it to ; to "run even if previous failed".
I'm not sure if ap check should be before or after ap upgrade -y, you can also change the alias names.
# To expand aliases in bash use ctrl alt e or see this ow.ly/zBKHs
# For more useful aliases go to ow.ly/zBMOx
Simply sourcing .bashrc does not function correctly when you edit it and change an alias for a function or the other way round with the *same name*.
I therefor use this function. Prior to re-sourcing .bashrc it unsets all aliases and functions.
printTextInColorRed foo bar
foo bar [in red color]
It starts in the current working directory.
It removes the empty directory and its ancestors (unless the ancestor contains other elements than the empty directory itself).
It will print a failure message for every directory that isn't empty.
This command handles correctly directory names containing single or double quotes, spaces or newlines.
If you do not want only to remove all the ancestors, just use:
find . -empty -type d -print0 | xargs -0 rmdir
After installing Termbeamer (see termbeamer.com) you can use it to share a terminal session with one or more others even from behind a firewall or NAT.
When your ssh session hanged (probably due to some network issues) you can "kill" it by hitting those 3 keys instead of closing the entire terminal.
Changes your group to the default group, has the same effect as sourcing your profile/rc file (in any shell) or logging out and back in again.
You may want to just use the shortcut "." instead of "source"
Any changes to BASH shell made in .bashrc will be active in the current terminal window from the moment you execute this command, ie. aliases, prompt settings etc. No need to restart terminal.
(In BASH 'source' simile to 'eval' lets you generally execute any bunch of commands stacked in a text file).
This will change your terminal foreground colour.Depending on the system, tput uses the terminfo or termcap database, as well as looking into the environment for the terminal type.
You can use "setb" to set terminal background colour
One person does `mkfifo foo; script -f foo' and another can supervise real-time what is being done using `cat foo'.
In Mac OS X, by default, you have to click the mouse on a Terminal window before you can type in it. You can change this behavior to mimic the X11 behavior of focusing on the window on mouseover.
Continue a current job in the background and detach it from current terminal
Often times you run a command in the terminal and you don't realize it's going to take forever. You can open a new terminal, but you lose the local history of the suspended one. You can stop the running command using , but that may produce undesirable side-effects. suspends the job, and (assuming you have no other jobs running in the background) %1 resumes it. Appending & tells it to run in the background.
You now have a job running concurrently with your terminal. Note this will still print any output to the same terminal you're working on.
Tested on zsh and bash.