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:
Finds all files in /home owned by UID 1056 and changes to 2056.
This command specifies the size in Kilobytes using 'k' in the -size +(N)k option. The plus sign says greater than. -exec [cmd] {} \; invokes ls -l command on each file and awk strips off the values of the 5th (size) and the 9th (filename) column from the ls -l output to display. Sort is done in reversed order (descending) numerically using sort -rn options.
A cron job could be run to execute a script like this and alert the users if a dir has files exceeding certain size, and provide file details as well.
finds all forms instanciated into a symfony project, pruning svn files.
or, to process a single directory:
for f in *; do mv $f `echo $f |tr '[:upper:]' '[:lower:]'`; done
or, for a single directory:
for f in *.c; do mv $f "`basename $f .c`".C; done
tar options may change ;)
c to compress into a tar file, z for gzip (j for bzip) man tar
-print0 and -0t are usefull for names with spaces, \, etc.
this will find text in the directory you specify and give you line where it appears.
For quick validation of folder's file-contents (structure not taken into account) - I use it mostly to check if two folders' contents are the same.
Great for finding which jar some pesky class is hiding in!
For a python project, sometimes I need to clean all the compiled python files. I have an alias 'rmpyc' to this command. This really saves me a lot of typing and hunting throughout the folders to delete those files.
Useful for a cron job that runs nightly, gzipping or alternatively deleting files from a specific directory that are older than 10 days (in this case)
Very useful for finding all files over a specified size, such as out of control log files chewing up all available disk space. Fedora Core x specific version.
Note the g for global in the perl expression; without it, only the first occurrence in the name would be replaced.
This will check all .HTML file contents for the word "Hacked" and dump it to hacklog.txt. This is great for located all those files affected by nasty Joomla exploits. Change the .HTML to any other extension you wish to check, and of course the word "HACKED" for other searches.
##Dependancies: bash coreutils
Many executables in $PATH have the keyword somewhere other than the beginning in their file names. The command is useful for exploring the executables in $PATH like this.
find ${PATH//:/ } -executable -type f -printf "%f\n" |grep admin
lpadmin
time-admin
network-admin
svnadmin
users-admin
django-admin
shares-admin
services-admin
Find all files that contain string XXX in them, change the string from XXX to YYY, make a backup copy of the file and save a list of files changed in /tmp/fileschanged.
* lowQ/ is the output directory
* pass quality level from 1 to 100
find -printf '%u\n' | sort | uniq #just users
find -printf '%g\n' | sort | uniq #just groups
On Windows 2000 or later, this command will give a listing of all the registered Windows services. You can then know what the name of a command is in order to start and stop it.
e.g.
sc start Apache2.2
or
net start Apache2.2
Please note that sc will allow the SERVICE_NAME only, while net will allow both SERVICE_NAME and DISPLAY_NAME.
Note that the space between the = and the next word are important. Not very unixy, that.
http://www.ss64.com/nt/sc.html