Terminal Commands Not Working

Joined
Jan 3, 2012
Messages
6
Reaction score
0
Points
1
Hi,

For some reason some terminal commands which I assume should be working by default are not working, including: netstat and lsof.

I am running on Snow Leopard, 10.6.8. I guess this might have something to with the terminal commands file? Any suggestions would be greatly appreciated.

Thanks,

Dan
 
Joined
Mar 17, 2008
Messages
6,879
Reaction score
191
Points
63
Location
Tucson, AZ
Your Mac's Specs
Way... way too many specs to list.
What do you mean by 'not working'?
 
Joined
Mar 17, 2008
Messages
6,879
Reaction score
191
Points
63
Location
Tucson, AZ
Your Mac's Specs
Way... way too many specs to list.
is /usr/sbin in your path?
 
OP
D
Joined
Jan 3, 2012
Messages
6
Reaction score
0
Points
1
Yes it is. I can't see netstat or lsof in there. Quite odd. Is there a way of installing these?
 
Joined
Mar 17, 2008
Messages
6,879
Reaction score
191
Points
63
Location
Tucson, AZ
Your Mac's Specs
Way... way too many specs to list.
They SHOULD be installed by default. I'm not aware of any method of installing them manually. I don't believe that either require xCode to be installed.
 
OP
D
Joined
Jan 3, 2012
Messages
6
Reaction score
0
Points
1
Bah. I can only find a netstat widget online. I have no idea why they're not there to begin with!
 
Joined
Mar 17, 2008
Messages
6,879
Reaction score
191
Points
63
Location
Tucson, AZ
Your Mac's Specs
Way... way too many specs to list.
Was this a new install? Used computer? etc?

could try a

sudo find / |grep lsof

and see it it's just in an oddball location I suppose
 
OP
D
Joined
Jan 3, 2012
Messages
6
Reaction score
0
Points
1
I've inherited it at work and it seems as though you're right. Having now found the folder where there progs are I can only open them and not use them as commands e.g., 'netstat -r' or 'lsof -i -P | grep -i "listen"'. Any ideas how to amend this? Thanks for your help.
 
Joined
Mar 17, 2008
Messages
6,879
Reaction score
191
Points
63
Location
Tucson, AZ
Your Mac's Specs
Way... way too many specs to list.
Sure, you can simply add the directory to your path. You'd just need to add something like

export PATH=/path/to/commands:$PATH

to your .profile or .bashrc , etc then restart your terminal login
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
I've no idea why this would have happened (why these binaries are in non-standard directories). I wonder how much is in non-standard locations...

Out of curiosity, where did you end up finding these tools?
 
Joined
Feb 26, 2010
Messages
2,116
Reaction score
123
Points
63
Location
Rocky Mountain High, Colorado
Your Mac's Specs
1.8 GHz i7 MBA 11" OSX 10.8.2
Are they executable? i.e.
Code:
ls -l netstat 
-r-xr-xr-x  1 root  wheel  218752 Jul 20 16:30 netstat*
The x bits should be set.
So they do have to be in the Path as dysfunction mentions, but they also have to be executable.
Code:
chmod 555 netstat
will change the file to an executable.
 
OP
D
Joined
Jan 3, 2012
Messages
6
Reaction score
0
Points
1
It was in a folder named /usr/tbin/. Netstat is executable thanks. So to be clear (as a nube) I'm exporting to .profile using the command: '
Code:
export PATH=/usr/tbin:$PATH
'. In which case it didn't work (having restarted terminal). Thanks again for the help.
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
The export command will only work for the session. You need to add that to your .bash_profile in your home directory such that the path is added every time you open up Terminal.

I don't understand why you have a /usr/tbin directory. Do you have /usr/sbin? If not, it's possible that sbin was moved to tbin (for whatever reason).
 
Joined
Mar 17, 2008
Messages
6,879
Reaction score
191
Points
63
Location
Tucson, AZ
Your Mac's Specs
Way... way too many specs to list.
Yes, if you have a .bash_profile you need to use that. If you don't, it should pick up .profile. Sounds like you have a .bash_profile.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top