LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 10-20-2014, 04:39 AM   #1
trollog
Member
 
Registered: Oct 2014
Posts: 151

Rep: Reputation: Disabled
explain file in /bin


slack 14.1

ls /bin/

shows a file.. (literally) '['

Second file, after the symlink to 'Mail' and before 'arch'

What is this file?
Executable, but does nothing.
Looks evil.
Does it have a valid purpose?


ls -l /bin
total 10784

lrwxrwxrwx 1 root root 14 Dec 3 2013 Mail -> /usr/bin/mailx*
-rwxr-xr-x 1 root root 36648 Feb 26 2013 [*
-rwxr-xr-x 1 root root 6896 Aug 7 2013 arch*
lrwxrwxrwx 1 root root 4 Dec 3 2013 awk -> gawk*
-rwxr-xr-x 1 root root 33512 Feb 26 2013 base64*
-rwxr-xr-x 1 root root 28008 Feb 26 2013 basename*
-rwxr-xr-x 1 root root 973688 Sep 26 15:05 bash*

..
 
Old 10-20-2014, 04:48 AM   #2
ReaperX7
LQ Guru
 
Registered: Jul 2011
Location: California
Distribution: Slackware64-15.0 Multilib
Posts: 6,558
Blog Entries: 15

Rep: Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097
It's part of coreutils.

[ - A synonym for test; this program permits expressions like [ expression ].
 
3 members found this post helpful.
Old 10-20-2014, 04:57 AM   #3
trollog
Member
 
Registered: Oct 2014
Posts: 151

Original Poster
Rep: Reputation: Disabled
Learn something new every day..

Thanks.
 
Old 10-20-2014, 06:31 AM   #4
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557

Rep: Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762
Next time you want to know from which package a binary or library comes grep /var/log/packages, e.g.

Code:
$ grep -F "bin/[" /var/log/packages/*
/var/log/packages/coreutils-8.19-i486-1:bin/[
 
4 members found this post helpful.
Old 10-20-2014, 07:06 AM   #5
//////
Member
 
Registered: Nov 2005
Location: Land of Linux :: Finland
Distribution: Arch Linux && OpenBSD 7.4 && Pop!_OS && Kali && Qubes-Os
Posts: 824

Rep: Reputation: 350Reputation: 350Reputation: 350Reputation: 350
i remember first time i saw it, i was kinda sure i was compromised / one of my scripts were malfunctioning and created it. that was several years ago.
 
Old 10-20-2014, 07:11 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,897

Rep: Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318
it still has a man page.
 
Old 10-20-2014, 11:06 AM   #7
wadsworth
Member
 
Registered: Aug 2007
Distribution: Slackware64 13.37
Posts: 215

Rep: Reputation: 65
I don't have a man page for it here.

But I'm running Slackware64 14.0. Maybe that's why?
 
Old 10-20-2014, 04:15 PM   #8
Stephen Morgan
Member
 
Registered: Feb 2011
Location: England
Distribution: Slackware
Posts: 164

Rep: Reputation: 19
My -current also has no manpage, although there is of course a manpage for test.
 
Old 10-20-2014, 10:13 PM   #9
the3dfxdude
Member
 
Registered: May 2007
Posts: 733

Rep: Reputation: 358Reputation: 358Reputation: 358Reputation: 358
It's a bash built-in: do 'help [' and you'll get a complete description. The /bin program is for some other context?
 
1 members found this post helpful.
Old 10-20-2014, 11:47 PM   #10
ponce
LQ Guru
 
Registered: Aug 2004
Location: Pisa, Italy
Distribution: Slackware
Posts: 7,102

Rep: Reputation: 4178Reputation: 4178Reputation: 4178Reputation: 4178Reputation: 4178Reputation: 4178Reputation: 4178Reputation: 4178Reputation: 4178Reputation: 4178Reputation: 4178
Code:
$ /bin/[ --help
Usage: test EXPRESSION
  or:  test
  or:  [ EXPRESSION ]
  or:  [ ]
  or:  [ OPTION
Exit with the status determined by EXPRESSION.

      --help     display this help and exit
      --version  output version information and exit

An omitted EXPRESSION defaults to false.  Otherwise,
EXPRESSION is true or false and sets exit status.  It is one of:

  ( EXPRESSION )               EXPRESSION is true
  ! EXPRESSION                 EXPRESSION is false
  EXPRESSION1 -a EXPRESSION2   both EXPRESSION1 and EXPRESSION2 are true
  EXPRESSION1 -o EXPRESSION2   either EXPRESSION1 or EXPRESSION2 is true

  -n STRING            the length of STRING is nonzero
  STRING               equivalent to -n STRING
  -z STRING            the length of STRING is zero
  STRING1 = STRING2    the strings are equal
  STRING1 != STRING2   the strings are not equal

  INTEGER1 -eq INTEGER2   INTEGER1 is equal to INTEGER2
  INTEGER1 -ge INTEGER2   INTEGER1 is greater than or equal to INTEGER2
  INTEGER1 -gt INTEGER2   INTEGER1 is greater than INTEGER2
  INTEGER1 -le INTEGER2   INTEGER1 is less than or equal to INTEGER2
  INTEGER1 -lt INTEGER2   INTEGER1 is less than INTEGER2
  INTEGER1 -ne INTEGER2   INTEGER1 is not equal to INTEGER2

  FILE1 -ef FILE2   FILE1 and FILE2 have the same device and inode numbers
  FILE1 -nt FILE2   FILE1 is newer (modification date) than FILE2
  FILE1 -ot FILE2   FILE1 is older than FILE2

  -b FILE     FILE exists and is block special
  -c FILE     FILE exists and is character special
  -d FILE     FILE exists and is a directory
  -e FILE     FILE exists
  -f FILE     FILE exists and is a regular file
  -g FILE     FILE exists and is set-group-ID
  -G FILE     FILE exists and is owned by the effective group ID
  -h FILE     FILE exists and is a symbolic link (same as -L)
  -k FILE     FILE exists and has its sticky bit set
  -L FILE     FILE exists and is a symbolic link (same as -h)
  -O FILE     FILE exists and is owned by the effective user ID
  -p FILE     FILE exists and is a named pipe
  -r FILE     FILE exists and read permission is granted
  -s FILE     FILE exists and has a size greater than zero
  -S FILE     FILE exists and is a socket
  -t FD       file descriptor FD is opened on a terminal
  -u FILE     FILE exists and its set-user-ID bit is set
  -w FILE     FILE exists and write permission is granted
  -x FILE     FILE exists and execute (or search) permission is granted

Except for -h and -L, all FILE-related tests dereference symbolic links.
Beware that parentheses need to be escaped (e.g., by backslashes) for shells.
INTEGER may also be -l STRING, which evaluates to the length of STRING.

NOTE: [ honors the --help and --version options, but test does not.
test treats each of those as it treats any other nonempty STRING.

NOTE: your shell may have its own version of test and/or [, which usually supersedes
the version described here.  Please refer to your shell's documentation
for details about the options it supports.

Report [ bugs to bug-coreutils@gnu.org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
For complete documentation, run: info coreutils '[ invocation'
note in particular the part after the Synopses in the following extract from the info file
Code:
File: coreutils.info,  Node: test invocation,  Next: expr invocation,  Prev: true invocation,  Up: Conditions

16.3 `test': Check file types and compare values
================================================

`test' returns a status of 0 (true) or 1 (false) depending on the
evaluation of the conditional expression EXPR.  Each part of the
expression must be a separate argument.

   `test' has file status checks, string operators, and numeric
comparison operators.

   `test' has an alternate form that uses opening and closing square
brackets instead a leading `test'.  For example, instead of `test -d
/', you can write `[ -d / ]'.  The square brackets must be separate
arguments; for example, `[-d /]' does not have the desired effect.
Since `test EXPR' and `[ EXPR ]' have the same meaning, only the former
form is discussed below.

   Synopses:

     test EXPRESSION
     test
     [ EXPRESSION ]
     [ ]
     [ OPTION

   Due to shell aliases and built-in `test' functions, using an
unadorned `test' interactively or in a script may get you different
functionality than that described here.  Invoke it via `env' (i.e.,
`env test ...') to avoid interference from the shell.

   If EXPRESSION is omitted, `test' returns false.  If EXPRESSION is a
single argument, `test' returns false if the argument is null and true
otherwise.  The argument can be any string, including strings like
`-d', `-1', `--', `--help', and `--version' that most other programs
would treat as options.  To get help and version information, invoke
the commands `[ --help' and `[ --version', without the usual closing
brackets.  *Note Common options::.

   Exit status:

     0 if the expression is true,
     1 if the expression is false,
     2 if an error occurred.

* Menu:

* File type tests::             -[bcdfhLpSt]
* Access permission tests::     -[gkruwxOG]
* File characteristic tests::   -e -s -nt -ot -ef
* String tests::                -z -n = == !=
* Numeric tests::               -eq -ne -lt -le -gt -ge
* Connectives for test::        ! -a -o
 
1 members found this post helpful.
Old 10-21-2014, 02:02 AM   #11
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
No, /bin/[ is not a shell builtin. bash does have both '[' and '[[' as builtins -and they are the ones that usually get used in scripts, unless /bin/[ gets called explicitly with the full path. The same is true for 'test' and /bin/test. And, /bin/[ is not simply a copy of /bin/test -although some systems might have /bin/[ as a link to /bin/test.
If you run '/bin/[ --help' you will not get the same results as '/bin/test' or 'help [' (from the bash command line).
So, in short, '[' & 'test' (from shell) and '/bin/[' & '/bin/test' are four separate things -each with slightly different features. And, of course, the double '[[' is only available as a shell builtin. One other helpful thing is to use the shell built-in 'type' instead of 'which' in order to identify which binary is really being used.
 
3 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] coopying bin file in buff problem not copying whole bin rohaanembedded Programming 1 07-10-2013 05:37 AM
-bash: /usr/bin/yum: /usr/bin/python: bad interpreter: No such file or director irlogo Red Hat 5 03-12-2012 04:38 AM
[SOLVED] bash: /usr/local/bin/xdsi: /usr/bin/wish: bad interpreter: No such file or directory Berwhale Linux - Newbie 2 09-15-2011 02:59 PM
Installing .bin-files, leave the file in /usr/local/bin/ ? lagu2653 Linux - Software 1 11-08-2005 08:30 PM
bin/bash:usr/bin/lpr NO SUCH FILE OR DIRECTORY Adibe_Hamm Linux - Newbie 3 10-14-2003 02:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 04:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration