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:
Solaris 'ls' command does not have a nice '--full-time' arg to make the time show after a year has passed. So I spit this out quick. It hates spaces in file names.
More recent versions of the date command finally have the ability to decode the unix epoch time into a human readable date. This function makes it simple to utilize this feature quickly.
A shell function using perl to easily convert Unix-time to text.
Put in in your ~/.bashrc or equivalent.
Tested on Linux / Solaris Bourne, bash and zsh. using perl 5.6 and higher.
(Does not require GNU date like some other commands)
PS: 'lustatus' gives the list of all alternate boot environments.
you must be in the directory to analyse
report all files and links in the currect directory, not recursively.
this find command ahs been tested on hp-ux/linux/aix/solaris.
Shell timeout variables (TMOUT) can be very liberal about what is classified as 'activity', like having an editor open. This command string will terminate the login shell for an user with more than a day's idle time.
this works on Solaris, so not better than the "only-GNU"-tool :-(
I think, there is no one-liner for this, that will work on all *nix-es
Find which package a file belongs to on Solaris along with it's packaging system metadata.
init states on solaris are numbered
init 0 boot with prompt
init 5 shutdown
init 6 reboot
% cat ph-vmstat.awk
# Return human readable numbers
function hrnum(a) {
b = a ;
if (a > 1000000) { b = sprintf("%2.2fM", a/1000000) ; }
else if (a > 1000) { b = sprintf("%2.2fK", a/1000) ; }
return(b) ;
}
# Return human readable storage
function hrstorage(a) {
b = a ;
if (a > 1024000) { b = sprintf("%2.2fG", a/1024/1024) ; }
else if (a > 1024) { b = sprintf("%2.2fM", a/1024) ; }
return(b) ;
}
OFS=" " ;
$1 !~ /[0-9].*/ {print}
$1 ~ /[0-9].*/ {
$4 = hrstorage($4) ;
$5 = hrstorage($5) ;
$9 = hrnum($9) ;
$10 = hrnum($10) ;
$17 = hrnum($17) ;
$18 = hrnum($18) ;
$19 = hrnum($19) ;
print ;
}
Lockstat will sample the kernel 977 times per second, and print out the functions that it sees executing on the CPU during the sample. The -s 10 switch tells lockstsat to not only print that function, but also show the call stack (up to 10 deep).
Needed to get the Mac of various devices on a solaris box, but didn't have root. This command used awk to display the Network device, the IP, and the MAC a line at a time.