Tell me more ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I was recently browsing my Fedora's /bin folder and noticed a binary named [. I did try to search the internet for more information on that, but I couldn't find anything useful. Running it through strace doesn't seem to produce anything useful for closer inspection too.

What is that? Should I be alarmed? Could it be the result of a system compromise? Should I run it? Does it belong to any package?

share|improve this question
2  
[ -f /bin/[ ] && printf "%s\n" "Don't panic" –  jasonwryan 9 hours ago
 
@jasonwryan Yeah, it took me a while to figure it out. I couldn't find much information for it on the net, and Google didn't help much. Posted it here in hopes that it might help the next one who's in my shoes. –  NlightNFotis 9 hours ago
3  
Run man [ to see what the [ command is! –  Gilles 9 hours ago
 
@Gilles To be honest, I did and it mentioned something about bash, and figured that might be something else. It's not the first thing that comes to your mind when you see a binary with a name you've never seen before in your file system - or to put it another way, you have to find something more concrete to clear the doubts in your head. –  NlightNFotis 9 hours ago
 
Related: Confusing use of && and || operators –  slm 8 hours ago
show 1 more comment

1 Answer

The [ binary residing under the /bin tree in many GNU/Linux distributions is not something to be alarmed off. At least in my Fedora 19 it is a part of the coreutils package, as demonstrated below:

$ rpm -qf /bin/[
coreutils-8.21-13.fc19.x86_64

and is a synonym for test to allow for expressions like [ expression ] to be written in shell scripts or even interactive usage.

share|improve this answer
7  
Note that shells like bash have a builtin test and [ and do not invoke the external binary. –  jordanm 9 hours ago
 
@jordanm, today most shells have them (and many other simple, common operations) as builtins. But that wasn't allways so (or is so in all shells). It might even be mandated by POSIX. –  vonbrand 5 hours ago
 
@vonbrand pubs.opengroup.org/onlinepubs/009695399/utilities/test.html You are right. A test command [ is required by this specification. –  yegle 2 hours ago
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.