LPIC-1 Exercise Question on Libraries

SBlackLinux

New Member
Joined
Oct 16, 2019
Messages
3
Reaction score
0
Credits
0
Hi all. New to the forum and a bit of a newbie, but trying to learn. I have searched for an answer but haven't found one, so hoping someone can assist.

The Dynamic Libraries chapter in Tuxcademy's LPIC-1 manual has the following exercise:

"Find a statically-linked executable on your system."

So I believe I can use the file command to get something like this (example from the manual):

$ file sqrttest-static
sqrttest-static: ELF 32-bit LSB executable, Intel 80386,
version 1 (SYSV), statically linked, for GNU/Linux 2.6.8,
not stripped

So I thought about using:

ls -R / | xargs file | grep "statically"

This seems ludicrously inefficient and returns no results anyway. How would be best to do this please? Can a command return a list of executables that have statically linked libraries?

Thank you,
Stu
 


Off the top of my head - this would be the simplest way to do it:
Code:
find / -executable -type f -exec file {} \; | \grep -i "statically"

Or another equivalent would be:
Code:
find / -executable -type f | xargs file | \grep -i "statically"

I'm not sure offhand which of the two would be faster, but both will list all executable files and use the file command to determine the type of each file. Before using grep to filter the results to show only the statically linked executables.[/code]
 
Off the top of my head - this would be the simplest way to do it:
Code:
find / -executable -type f -exec file {} \; | \grep -i "statically"

Or another equivalent would be:
Code:
find / -executable -type f | xargs file | \grep -i "statically"

I'm not sure offhand which of the two would be faster, but both will list all executable files and use the file command to determine the type of each file. Before using grep to filter the results to show only the statically linked executables.[/code]

Thank you very much for taking the time to reply. I will try this out later. :) Not familiar with the curly brackets yet, so will have to read up on that.
 
Thank you very much for taking the time to reply. I will try this out later. :) Not familiar with the curly brackets yet, so will have to read up on that.
No problem. Glad to help!

In the -exec section of the find command I posted - the curly brackets are used as a placeholder for the results from find.
So this:
Code:
-exec file {} \;

Means:
Code:
-exec file /path/to/found_file \;

So each time a file is found - we run the file command and pass it the path to each executable.
 
Last edited:

Members online


Top