How can I locate an executable file?

acidrain

Executive Member
Joined
Jan 7, 2007
Messages
5,975
Im trying to locate the executable file for my squid server to edit into a script im running for web logging but I can't seem to find it. I tried using "locate squid" but more results pop up than my terminal allows to browse so that fails and I've looked in pretty much all the obvious folders.

Also am i wrong for looking for the "cog" icon as im assuming that's what the exe file would look like and have yet to find it.

Thanks
 

warchylde

Expert Member
Joined
Mar 29, 2010
Messages
2,011
Depends on how it was configured. What OS you have it running on? What version?
 

acidrain

Executive Member
Joined
Jan 7, 2007
Messages
5,975
Ubuntu 10.10 and it came pre-loaded as when setting up and doing the whole apt-get it said it was already installed so just located the .conf file and ran in system
 

warchylde

Expert Member
Joined
Mar 29, 2010
Messages
2,011
you should be able to simply do

sudo service squid start

or do you want to edit the script that starts it?
 

acidrain

Executive Member
Joined
Jan 7, 2007
Messages
5,975
ok here's the script as is,

Code:
#!/bin/bash
 
#Get current date
TODAY=$(date +%d/%m/%Y)
 
#Get one week ago today
YESTERDAY=$(date --date "1 month ago" +%d/%m/%Y)
 
/usr/local/bin/sarg -l /var/log/squid/access.log -o /var/www/html/sarg/reports/monthly -z -d $YESTERDAY-$TODAY
 
[U][B]/usr/local/squid/bin/squid -k rotate[/B][/U]
 
exit 0

Now the part in bold is the incorrect path as i've checked it. I can run the squid service just don't know where the path is for that exe
 

warchylde

Expert Member
Joined
Mar 29, 2010
Messages
2,011
ok fair enough can I assume you haven't worked with a linux filesystem before?
 

acidrain

Executive Member
Joined
Jan 7, 2007
Messages
5,975
you assume correct... fairly knew to the whole thing and when googling only found a forum which suggested using whereis squid but all the paths didn't seem to hold the file. Either that or im looking for the wrong thing
 

warchylde

Expert Member
Joined
Mar 29, 2010
Messages
2,011
ok I am going to try and explain this (figured most of it out myself) so that it makes a little sense at least initially so that you can get started. Some of my explanation may not be 100% correct but it will give a starting point.

the linux file system is mostly text like files (can be many different types of text files in different scripting languages etc) there are others of course (binary files) but the ones you are interested in in this case are files set as executable.

Think of linux exe files as batch files (that can have absolutely any extension you wish). The way this is indicated is by setting the permissions on the file with a command chmod (this is an abbreviation of change mode). You can designate any file you wish as an executable and be able to "trigger" it like a batch file. So in essence what you are looking for are the batch files that start squid. In this case the actual location of this is /usr/sbin/squid (and in this case it is actually a binary file) there are situations where you won't have a binary/application file. Your config file will tell this binary/application file (note i say file not exe) what settings to load and control it's functions.

You with me so far?
 

acidrain

Executive Member
Joined
Jan 7, 2007
Messages
5,975
yup, sounds exactly what im looking for

there is a squid file in /usr/sbin/ but by type it shows "Shared Library" and icon is a piece of paper with 1's and 0's
 

warchylde

Expert Member
Joined
Mar 29, 2010
Messages
2,011
yup, sounds exactly what im looking for

there is a squid file in /usr/sbin/ but by type it shows "Shared Library" and icon is a piece of paper with 1's and 0's

The 1's and 0's indicate that it's a binary file. LOL and you are using the gui :p I started out that way too. You will soon learn to appreciate SSH much more :) what exactly do you want to do with the squid file?
 

acidrain

Executive Member
Joined
Jan 7, 2007
Messages
5,975
Well i don't want to do anything to it, i just want the script to call up squid and ask to rotate the log.

I'm assuming the reason behind this is to prevent the log from becoming too big
 

acidrain

Executive Member
Joined
Jan 7, 2007
Messages
5,975
As for the 1's and 0's, thats probably where my confusion came as i thought the "cog" icon was binary only files. Now I've learnt something :)
 

warchylde

Expert Member
Joined
Mar 29, 2010
Messages
2,011
Yep squid logs can grow very big very fast.... squid has it's own rotation settings for logs. You can edit this file at /etc/logrotate.d/squid if you wanna fiddle.

Tip: anytime you want to edit a config file like this always make a copy of the file first
 

acidrain

Executive Member
Joined
Jan 7, 2007
Messages
5,975
Sweet, well thanks for your help. Seems that was the file indeed :D

Infact looking at /etc/logrotate.d/squid file it has the path right there
 

warchylde

Expert Member
Joined
Mar 29, 2010
Messages
2,011
No problem :) another tip - search for cron and logrotate (that script you are accessing now is scheduled with cron)
 

sn3rd

Expert Member
Joined
Jan 18, 2008
Messages
4,305
Although solved, you could have tried the following alternatives:
Code:
$ find / -name "squid" | less

Or if you wanted to use locate, make sure you do updatedb first. And if there are too many records, use a pager, or use regex to narrow your search:
Code:
$ updatedb
and then
Code:
$ locate squid | less
or
Code:
locate squid | grep <insert expression here>

Of course, if you're using Gnome, you could also run the search from Nautilus, Windows-style.
 

walter_l

Active Member
Joined
Feb 3, 2010
Messages
85
Odd to see that no-one has mentioned which(1). It searches for a given executable (only) in the directories listed in the $PATH environmental variable. So if you can tab-complete the name of the executable on the command-line, you can use which(1) to determine exactly where it is run from.

Code:
$ which squid
/usr/sbin/squid
 

Kasyx

Expert Member
Joined
Jun 6, 2006
Messages
2,565
Odd to see that no-one has mentioned which(1). It searches for a given executable (only) in the directories listed in the $PATH environmental variable. So if you can tab-complete the name of the executable on the command-line, you can use which(1) to determine exactly where it is run from.

Code:
$ which squid
/usr/sbin/squid

You beat me to it :p
 
Top