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:
This is great when you need to reboot the system-server, or your own daemon that has gone crazy
Certain Flash video players (e.g. Youtube) write their video streams to disk in /tmp/ , but the files are unlinked. i.e. the player creates the file and then immediately deletes the filename (unlinking files in this way makes it hard to find them, and/or ensures their cleanup if the browser or plugin should crash etc.) But as long as the flash plugin's process runs, a file descriptor remains in its /proc/ hierarchy, from which we (and the player) still have access to the file. The method above worked nicely for me when I had 50 tabs open with Youtube videos and didn't want to have to re-download them all with some tool.
handels @, ?, whitespaces in names.
replace "?" and "add" by "!" and "rm" for svn mass remove.
---> I m looking for a nicer way to write it, perhaps with something using " perl -ne '`blahblah` if /\?(.*)/' "
# define user pid to kill
PID=httpd ;
# kill all pids
ps aux | grep $PID | grep -v grep | awk '{print $2}' | xargs kill -9
This is actually quite slow~
P.S. change `seq 2 100` to `seq 2 1000` and try
It grabs the PID's top resource users with $(ps -eo pid,pmem,pcpu| sort -k 3 -r|grep -v PID|head -10)
The sort -k is sorting by the third field which would be CPU. Change this to 2 and it will sort accordingly.
The rest of the command is just using diff to display the output of 2 commands side-by-side (-y flag) I chose some good ones for ps.
pidstat comes with the sysstat package(sar, mpstat, iostat, pidstat) so if you don't have it, you should.
I might should take off the timestamp... :|
When working with jailed environments you need to copy all the shared libraries to your jail environment. This is done by running ldd on a binary which needs to run inside the jail. This command will use the output from ldd to automatically copy the shared libraries to a folder of your choice.
See who is using a specific port. Especially when you're using AIX. In Ubuntu, for example, this can easily be seen with the netstat command.
It remove the square bracket and convert UNIX time to human readable time for all line of a stream (or file).
Rather then editing the /etc/sysconfig/iptables file, or during a kickstart doing some awk/sed magic, easily add a rule in the correct place within iptables
This is also perl-less, and only uses AWK as its postprocessor. Tested with GAWK and MAWK.
If you are installing some new package. You can first go through the step by step install and then take the commands that you ran from history to create shell script which can used to install the package on other machines say test or production.
This command does a basic find with size. It also improves the printout given (more clearer then default)
Adjusting the ./ will alter the path.
Adjusting the "-size +100000k" will specify the size to search for.
This command displays the CPU idle + used time using stats from /proc/stat.
kded --version return this
Qt: 3.3.8b
KDE: 3.5.10
KDE Daemon: $Id: kded.cpp 711061 2007-09-11 09:42:51Z tpatzig $
awk -F: ................. Awk Field separator
NR == 2 ................. Register Number, second line
{print $2} ............... second field
sed 's/\s\+//g' .......... remove one space or more \s\+ changing by nothing
Detect duplicate UID in you /etc/passwd (or GID in /etc/group file).
Duplicate UID is often forbidden for it can be a security breach.
basically create a .pot file from a po-file, ready for translating
This will extract the differing CSS entries of two files. I've left the initial character (plus or space) in output to show the real differing line, remove the initial character to get a working CSS file. The output CSS file is usable by either adding it in a below the to original.css, or by only using the output but adding @import url("original.css"); in the beginning.
This is very useful for converting Wordpress theme copies into real Wordpress child themes.
Could exclude common lines within entries too, I guess, but that might not be worth the complexity.