Commands by kev (116)

What's this? is the place to record those command-line gems that you return to again and again. 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.

Share Your Commands

Check These Out

Find files that are older than x days
Find files that are older than x days in the working directory and list them. This will recurse all the sub-directories inside the working directory. By changing the value for -mtime, you can adjust the time and by replacing the ls command with, say, rm, you can remove those files if you wish to.

loop over a set of items that contain spaces
If you want to operate on a set of items in Bash, and at least one of them contains spaces, the `for` loop isn't going to work the way you might expect. For example, if the current dir has two files, named "file" and "file 2", this would loop 3 times (once each for "file", "file", and "2"): $ for ITEM in `ls`; do echo "$ITEM"; done Instead, use a while loop with `read`: $ ls | while read ITEM; do echo "$ITEM"; done

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

Found how how much memory in kB $PID is occupying in Linux
The "proportional set size" is probably the closest representation of how much active memory a process is using in the Linux virtual memory stack. This number should also closely represent the %mem found in ps(1), htop(1), and other utilities.

Copy files for backup storage
Backup a whole directory copying only updated files.

Disable sleep mode via cli and systemd (Centos, Debian Ubuntu?)
This causes computer to never power off or go into sleep mode. Disables sleep mode linux.

SVN Clean
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 '').

Show Mac OS X version information

type partial command, kill this command, check something you forgot, yank the command, resume typing.
Example : $ vim /etc/fstab ## damn $ $ sudo ## like a boss. Example 2 : $ sudo vim /root/bin/ ##uh... autocomplete doesn't work... $ $ sudo ls /root/bin ##ah! that's the name of the file! $ sudo vim /root/bin/ ##resume here! Thanks readline!

Toggle between directories
switch to previous directory or toggle

Stay in the loop…

Follow the Tweets.

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.


Subscribe to the feeds.

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: