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:
This is the fastest method to search the Debian package database.
Requires the dlocate package. The dlocate db updates periodically, but you may force an update with
# dlocate-update
This command puts all the flags of the USE variable actually used by the packages you emerged to the file "use", and those which are unused but available to the file "notuse"
Like symlinked directories, you can mount a directory at a different location. For example mounting a directory from one location in to the http root without having to make your program follow symlinks or change permissions when reading.
can display the commands and their output to another user who is connected to another terminal, by example pts/3
'dpkg -S' just matches the string you supply it, so just using 'ls' as an argument matches any file from any package that has 'ls' anywhere in the filename. So usually it's a good idea to use an absolute path. You can see in the second example that 12 thousand files that are known to dpkg match the bare string 'ls'.
cdrecord -scanbus will tell you the (x,y,z) value of your cdr (for example, mine is 3,0,0)
Sometimes "ls" is just too slow, especially if you're having problems with terminal scroll speed, or if you're a speed freak. In these situations, do an echo * in the current directory to immediately see the directory listing. Do an echo * | tr ' ' '\n' if you want a column. Do an alias ls='echo *' if you want to achieve higher echelons of speed and wonder. Note that echo * is also useful on systems that are so low in memory that "ls" itself is failing - perhaps due to a memory leak that you're trying to debug.
I've seen some versions of hostname that don't have the -i option, so this may not work everywhere. When available, it's a better alternative than using ifconfig and wasting eyeball muscle to search for the address, and it's definitely simpler than using awk/sed.
Optionally, you can create a new function to do this with a custom command. Edit $HOME/.bashrc and add:
myssh () { ssh $1 | tee sshlog ; }
Save it.
At command prompt:
myssh [email protected]
List all file opened by a particular command based on it's command name.
Its not mine... I get from textlive migration in gentoo : http://www.gentoo.org/proj/en/tex/texlive-migration-guide.xml
In Redhat, xmlstarlet is called just xml which can be found in xmlstarlet RPM.
If you're like me and want to keep all your music rated, and you use xmms2, you might like this command.
I takes 10 random songs from your xmms2 library that don't have any rating, and adds them to your current playlist. You can then rate them in another xmms2 client that supports rating (I like kuechenstation).
I'm pretty sure there's a better way to do the grep ... | sed ... part, probably with awk, but I don't know awk, so I'd welcome any suggestions.
For users looking to simplify management of large entries in files and directories, this command is the key to fun and simplicity. Using the power sort, only a couple of seconds are necessary to accomplish what would take minutes or hours in ?standard? client applications.
I use this to pull the last commit date for everything in my repo, so I can tell the client which files haven't been touched or updated since the repo was created. Another way to do it is to use svn log, but that does not pull the "kind" attribute. It does, however, give you the commit message. Both are very useful.
Sometimes you need to use a port that is already opened by some program , and you don't know who to "kill" for it to release - so, now you do !
Use the find command to match certain files and summarise their total size in KBytes.
Greps located files for an expression.
Example greps all LaTeX files for 'foo':
locate *.tex | xargs grep foo
To avoid searching thousands of files with grep it could be usefull to test first how much files are returned by locate:
locate -c *.tex
After every line in targetfile (empty lines included) insert in a line from addfile. "Save" results to savefile. Addfile should be longer than targetfile since this doesn't loop back to the top of addfile.
/^/R addfile -- says for every line that matches "has a start of line" output a line from the file addfile.
> savefile (optional) -- redirect output to savefile file.