No Such file or directory

Hi,

I am facing issue when I am trying to run any command from /usr/bin/ folder. I can see a link to the files exists in this folder but when I run giving absolute path it gives me below error.

1. $ /usr/bin/awk
-bash: /usr/bin/awk: No such file or directory

2. $ man awk
sh: /usr/bin/gunzip: No such file or directory
fgets: No such file or directory
Error reading man page /usr/share/man/man1/awk.1.gz
No manual entry for awk

Below command shows that the links exist in the folder

$ ls -ltr /usr/bin/awk
lrwxrwxrwx. 1 root root 14 Nov 28 10:16 /usr/bin/awk -> ../../bin/gawk

$ ls -ltr /usr/bin/gunzip
lrwxrwxrwx. 1 root root 16 Nov 28 10:25 /usr/bin/gunzip -> ../../bin/gunzip

Check if the actual gawk is present in /bin/gawk or whichever path it is pointing to.

--ahamed

Yes, I can see that is also present.

Do you have the right permissions to access /bin/awk?

'no such file or directory' can mean 'important library is missing'. Try 'ldd /bin/awk' and see if it can find all its libraries.

1 Like

Hi Corona,

When I run the command I get the below output.

$ ldd /bin/awk
        linux-vdso.so.1 =>  (0x00007fff06920000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00000036f2c00000)
        libm.so.6 => /lib64/libm.so.6 (0x00000036f4400000)
        libc.so.6 => /lib64/libc.so.6 (0x00000036f3000000)
        /lib64/ld-linux-x86-64.so.2 (0x00000036f2800000)

and when I am running the command without pointing to /usr/bin I am getting the below message. Seems like the commands are find just like the links are not working. Does that mean I have to rebuild the links? is there a quick way to rebuild them?

Thanks!!

$ /bin/awk
Usage: awk [POSIX or GNU style options] -f progfile [--] file ...
Usage: awk [POSIX or GNU style options] [--] 'program' file ...
POSIX options:          GNU long options:
        -f progfile             --file=progfile
        -F fs                   --field-separator=fs
        -v var=val              --assign=var=val
        -m[fr] val
        -O                      --optimize
        -W compat               --compat
        -W copyleft             --copyleft
        -W copyright            --copyright
        -W dump-variables[=file]        --dump-variables[=file]
        -W exec=file            --exec=file
        -W gen-po               --gen-po
        -W help                 --help
        -W lint[=fatal]         --lint[=fatal]
        -W lint-old             --lint-old
        -W non-decimal-data     --non-decimal-data
        -W profile[=file]       --profile[=file]
        -W posix                --posix
        -W re-interval          --re-interval
        -W source=program-text  --source=program-text
        -W traditional          --traditional
        -W usage                --usage
        -W use-lc-numeric       --use-lc-numeric
        -W version              --version

To report bugs, see node `Bugs' in `gawk.info', which is
section `Reporting Problems and Bugs' in the printed version.

gawk is a pattern scanning and processing language.
By default it reads standard input and writes standard output.

Examples:
        gawk '{ sum += $1 }; END { print sum }' file
        gawk -F: '{ print $1 }' /etc/passwd

The link looks ok to me. But do you have permission to navigate it? Post the result of the following command...

$ ls -ld / /bin /usr /usr/bin
drwxr-xr-x 36 root root  4096 Jan 23 15:05 /
drwxr-xr-x  2 root root  4096 Jun 25  2010 /bin
drwxr-xr-x 17 root root  4096 Jun 24  2010 /usr
drwxr-xr-x  2 root root 73728 May 17  2013 /usr/bin
$

Yes, I do have the sudo root privilege. Here is the output of the command

$ ls -ld / /bin /usr /usr/bin
dr-xr-xr-x. 25 root root  4096 Feb 14 17:06 /
dr-xr-xr-x.  2 root root  4096 Dec 13 03:50 /bin
drwxr-xr-x. 13 root root  4096 Nov 28 10:16 /usr
dr-xr-xr-x.  2 root root 20480 Dec 13 03:50 /usr/bin

Having read your other thread, please show us what you have mounted, and where.

In the first post for awk it was a link to gawk. You do have the gawk as well right?... why don't you unlink and create a link again?...

1 Like

What happens when you run a command in /usr/bin that is not symlinked? On my system "yes" is an example of that.

$
$ ls -l /usr/bin/yes
-rwxr-xr-x 1 root root 20352 Nov 27  2006 /usr/bin/yes
$ /usr/bin/yes | sed 2q
y
y
$

Also does /usr/bin/awk fail for root?

Also try this:

$
$ ls -l /usr/bin/awk | od -c
0000000   l   r   w   x   r   w   x   r   w   x       1       r   o   o
0000020   t       r   o   o   t       1   4       J   u   n       2   4
0000040           2   0   1   0       /   u   s   r   /   b   i   n   /
0000060   a   w   k       -   >       .   .   /   .   .   /   b   i   n
0000100   /   g   a   w   k  \n
0000106
$
$

Hi Perderabo,

It yes command is working exactly as your example.

# /usr/bin/yes | sed 2q
y
y

# ls -l /usr/bin/yes
-rwxr-xr-x. 1 root root 25664 May 16  2013 /usr/bin/yes

Ahamed101 - It seems like I have to create the links again. but a bit concerned if that is the actual cause of issue, because it was working fine previously before I mounted /tmp to another device and then mounted on /usr's device and now moved back to /'s device.

I don't follow that surgery you attempted on your filesystem, but assuming you got stuff back to the original location it should be working now. Try to manually recreate a single and see if that helps. I don't think it will help, but maybe it is worth a try. Try a different shell... maybe your shell's environment is screwed up. Also post the output from df -k .

1 Like

Thank you all for all your help. I created the links and everything seems to be back to normal again. :slight_smile: