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.
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:
Allows you to change the value of an environment variable only for the execution of the command in the line. (corrected)
Allows you to preserve your files when using cp, mv, ln, install or patch. When the target file exists, it will generate a file named XXX.~N~ (N is an auto-incremental number) instead of deleting the target file.
populate the auth.hosts file with a list of IP addresses that are authorized to be in use and when you run this command it will return the addresses that are pingable and not in the authorized list.
Can be combined with the "Command line Twitter" command to tweet unauthorized access.
if you wanted to create a new folder called "red" that was a symbolic link from /home/music/ to /home/hobbies/art then you would type:
ln -s /home/hobbies/art /home/music/red
if you had a symbolic link called "oldLink" in the current folder then you would want to do
unlink oldLink
You can use wildcard with rpm search but you have to do 2 things:
1. use "-a" switch (means "all") with query ("-q") switch - argument is a pattern to use while searching for package names of all installed packages
2. protect wildcards, so that shell could not eat them - escape it with backslash ("\") or enclose all pattern between apostrophes ("'"):
rpm -qa 'co*de'
As you can see above it is possible to insert wildcards into middle of the pattern.
If you want, you can add "-i" or another rpm query options, "-i" will print package information for all installed packages matching pattern.
manview searches man pages on the internets in case the man command doesn't work for some reason or if you think the man pages in Cornell's flavor of Solaris might differ from yours. It dumps the manpage info from lynx to less, so it ends up looking remarkably like a real manpage. Put it in your .bash_profile or .bashrc, and then you can use it like a regular command: typing "manview ssh" will give you the manpage for ssh.
Replace (as opposed to insert) hex opcodes, data, breakpoints, etc. without opening a hex editor.
HEXBYTES contains the hex you want to inject in ascii form (e.g. 31c0)
OFFSET is the hex offset (e.g. 49cf) into the binary FILE
This will let you know what filesets or fixes (if any) are missing in order to be considered "at" a given technology level in AIX.
This is quite usefull in Unix system share via NFS or AppleTalk with OSX clients that like to populate your filesystem with these pesky files
Next time you are using your shell, try typing ctrl-x e (that is holding control key press x and then e). The shell will take what you've written on the command line thus far and paste it into the editor specified by $EDITOR. Then you can edit at leisure using all the powerful macros and commands of vi, emacs, nano, or whatever.
This assumes you have the 'rpm', 'rpm2cpio' and 'cpio' packages installed. This will extract the contents of the RPM package to your current directory. This is useful for working with the files that the package provides without installing the package on your system. Might be useful to create a temporary directory to hold the packages before running the extraction:
mkdir /tmp/new-package/; cd /tmp/new-package
After typing cd directory [enter] ls [enter] so many times, I figured I'd try to make it into a function. I was surprised how smoothly I was able to integrate it into my work on the command line.
Just use cdls as you would cd. It will automatically list the directory contents after you cd into the directory. To make the command always available, add it to your .bashrc file.
Not quite monumental, but still pretty convenient.
Jan Nelson from Grockit came up with this for us when we needed to rename all of our fixtures.
Removes all unversioned files and folders from an svn repository. Also:
svn status --no-ignore | grep ^I | awk '{print $2}' | xargs rm -rf
will remove those files which svn status ignores. Handy to add to a script which is in your path so you can run it from any repository (a la 'svn_clean.sh').
What this does is, if I type ?ssh ? then hit the page-up key, it will complete the line to the last time in my history file that I typed ssh. Hitting page up again will go to the 2nd to last time I typed it. Incredibly handy if you ever type the same commands more than once.
credit goes to http://www.sharms.org/blog/2009/03/10/make-your-bash-shell-cool-again/
echo "\"\e[6~\": history-search-forward" >> ~/.inputrc