Linux:
![]()
I’ve finally got around to building an RSS feed for my study resource. I will update the feed as I add articles, but don’t be alarmed if the addition frequency is somewhat erratic. New stuff will come.
I’ve just posted my latest study piece. This one’s on Unix/Linux permissions.
[ Link: Unix/Linux Permissions ]

OS X’s kernel isn’t strictly Unix-based. It’s called XNU, and it’s a monolithic (non micro) hybrid of both Mach And BSD kernel components. What’s quite interesting is how many people (including myself up until a little while ago) think that OS X has a pure Unix (BSD) kernel.
But that’s not the case. In fact, XNU is actually an acronym for “X is Not Unix”.
In other words, while Apple’s marketing team loves to play the Unix card at every turn, its developers explicitly made a distinction between the OS X’s kernel and a true Unix kernel.
Wikipedia goes on to mention, however, that this distinction will become far less dramatic in the event that OS X becomes POSIX compliant in Leopard.
xargs vs. exec {}There is a bit of a debate in some circles about using xargs vs. the -exec {} option that’s built into find itself. To me, however, it’s not much of a debate; -exec isn’t nearly as good as xargs for what I use find for. I tend to use it to perform tasks involving many files. “Move all these files there”, “copy all those directories there”, “Delete these links.”, etc.
This is where-execbreaks down andxargsshows its superiority. When you use-execto do the work you run a separate instance of the called program for each element of input. So iffindcomes up with 10,000 results, you runexec10,000 times. Withxargs, you build up the input into bundles and run them through the command as few times as possible, which is often just once. When dealing with hundreds or thousands of elements this is a big win forxargs.
That’s all nice and stuff, but you probably want to see it in action, right? Let’s run some numbers. Below is a listing of 1,668 .jpg files on my OS X system using both -exec and xargs:
# time find . -name "*.jpg" -exec ls {} \;
real 0m6.618s user 0m1.465s sys 0m4.396sHmm, that’s not bad — seven seconds for over around 1,600 files, right? Let’s try it with
xargs.
# time find . -name "*.jpg" -print0 | xargs -0 ls
real 0m1.120s user 0m0.594s sys 0m0.527sThat's one (1) second vs seven (7) seconds. Seriously;
xargs is the way to go.
If you’re a Unix geek you need to check out this thread:
lsof is one of the most powerful Linux/Unix tools out there, but it’s relatively unknown and unused. I’ve just completed a short guide to some of its most useful functions. If you’re into *nix at all and are not familiar with this incredible tool, go have a gander.
I don’t have any idea why I didn’t know this before, but in Firefox you can search within a given web page by pressing the "/" key (that’s a forward slash). For those that are *nix-literate, you’ll recognize this as the way to search within .vi
Actually, that's how I discovered the option; I was about to look for soemthing on a page and I subconsciously pressed the / key as if I were in vi.
I saw the search bar pop up on the bottom, but it didn't sink in for like 5 seconds. I was like, "Did I really just see that?" Once I confirmed that I wasn't seeing things I backtracked to figure out why I pressed that key to search in the first place, and more importantly -- why it worked.
That's when it struck me -- it's how you search in vi! Wow. Very cool. To add to the novelty, the search bar goes away in a few seconds if you don't actually use it. Yes, definitely cool.:
Now this is a cool project — mapping the functionality of multiple types of *nix. If you’re a *nix geek, this site is a must.
tcpdump Tutoriallsof Introductiongit Primerfind Command lsof Commandtar Referencelsof TutorialDaniel Miessler | 1999-2012 | Share Alike
Powered by Linode