LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-06-2003, 08:24 AM   #1
buddy
LQ Newbie
 
Registered: Dec 2002
Location: Montreal
Distribution: Mdk9
Posts: 20

Rep: Reputation: 0
Best Method for searching


Hey there folks,

Providing that locate and where are not enabled - whats the best method to perform a search - [grep?]

Cheers
 
Old 01-06-2003, 08:29 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
depends what kind of a search.... if you want to find files, the "find"
 
Old 01-06-2003, 08:32 AM   #3
buddy
LQ Newbie
 
Registered: Dec 2002
Location: Montreal
Distribution: Mdk9
Posts: 20

Original Poster
Rep: Reputation: 0
"Find isn't enabled"

I have the barest of bones... finding files is the idea

So lets recap - locate, where, find. -> all disabled
 
Old 01-06-2003, 09:50 AM   #4
stickman
Senior Member
 
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552

Rep: Reputation: 53
Ok, having find disabled was not mentioned in your first message. Given your situation, you could use cd, ls, and grep in a shell script; however, it's not going to be efficient. Why did you disable find (probably the best tool for the job) when you apparently need that functionality.
 
Old 01-06-2003, 11:26 AM   #5
buddy
LQ Newbie
 
Registered: Dec 2002
Location: Montreal
Distribution: Mdk9
Posts: 20

Original Poster
Rep: Reputation: 0
Ok lets first clarify that "I" did not disable find ;O)

I'm simply asking the question because the system I'm being forced to administer - has been bared boned - and almost nothing is on the system - kind of funny actually - but just the same merits a question - what can one use to search? I just want to know the other possibilities...

Cheers
 
Old 01-06-2003, 11:33 AM   #6
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 270Reputation: 270Reputation: 270
Well for files, having find, locate and where not installed, you could always install find. That is what I would suggest, as its probably the best suited for the job.
 
Old 01-06-2003, 11:37 AM   #7
buddy
LQ Newbie
 
Registered: Dec 2002
Location: Montreal
Distribution: Mdk9
Posts: 20

Original Poster
Rep: Reputation: 0
thanks mates - question - if my system was comprimized[and assuming they have a prompt] - would not a locate,grep or find command allow for easier find of files - instead of someone having to "know" exactly how the system is setup? Just thought I'd throw it out there?
 
Old 01-06-2003, 06:13 PM   #8
stickman
Senior Member
 
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552

Rep: Reputation: 53
Security by obscurity is not a solution. Unless the person who setup the system went out of their way to make major system changes, the majority of the system files are going to be in common locations. While not terribly efficient, an attacker could probably simulate the find command with a for loop, ls, cd, and grep. Removing unnecessary utilities can be done to make a system more secure, there is a point where it will impede on an admin's ability to work on a system.
 
Old 01-06-2003, 06:38 PM   #9
moon69
LQ Newbie
 
Registered: Jan 2003
Location: USA
Posts: 18

Rep: Reputation: 0
I never use find.
try:
cd / (cd to root)
ls -Llt somefile* | more

or you could redirect the output to a file to view easier this way:
ls -LLt somefile* >> newfile.txt

the upper case L makes the ls look into sub directories also; lower case l says long listing and t sorts by time. To get a reverse order try adding a lowercase r to the command.
Hope this helps.
Moon
 
Old 01-06-2003, 06:47 PM   #10
moon69
LQ Newbie
 
Registered: Jan 2003
Location: USA
Posts: 18

Rep: Reputation: 0
Opps, I posted to fast. You also mentioned grep. grep is a great tool. But it searches for text inside of files, not file names. The ls command I just posted assumed you were looking for a file name somewhere in your file system. If your looking for text inside of a file use grep. for example if I want to find how my ftp is set up, I'd cd to my /etc directory. and then do:
grep ftp * | more

the * says look inside every file in this directory for the text string ftp.

everyfile with the characters ftp inside it would be listed in the output. pretty slick.

Hope some of this helped .....
Moon
 
Old 01-06-2003, 08:47 PM   #11
stickman
Senior Member
 
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552

Rep: Reputation: 53
Quote:
Originally posted by moon69
the upper case L makes the ls look into sub directories also
What shell/distro are you using? I'm used to -L dealing with symbolic links.
 
Old 01-07-2003, 12:56 AM   #12
moses
Senior Member
 
Registered: Sep 2002
Location: Arizona, US, Earth
Distribution: Slackware, (Non-Linux: Solaris 7,8,9; OSX; BeOS)
Posts: 1,152

Rep: Reputation: 50
grep searches what is given to it, if it receives stdin, then it
searches stdin. If it receives a filename, then it searches the
filename.
Code:
cd /
for i in `ls`; do cd $i; echo $i/`ls | grep "reboot"`; cd ..; done
will find any instance of reboot in the first level of the directory
tree. You can easily extend this to find files in the directory tree.
This is stupidly slow, and any cracker can do it without the
find/locate command. If you can do it, a cracker can do it.
Security works by making it difficult for the punk to get on your
system, but once they're on, you had better have made backups.
As has been said, obscurity is not security, it just makes your
job more difficult. Do it right and make sure the system is as safe
from the outside as possible, then make sure you perform
backups.
 
Old 01-07-2003, 07:01 AM   #13
moon69
LQ Newbie
 
Registered: Jan 2003
Location: USA
Posts: 18

Rep: Reputation: 0
Opps. My bad. I didn't have my RH 7.2 box close by and relied on my elusive memory.
Uppercase L does show symbolic links.
Uppercase R traverses down through all sub dir's.
I've just tried this so I KNOW it works this time.

try:
ls -lR
then pipe it to more, or redirect it to a file as i mentioned in the earlier post.

Sorry for the mistake.

Moon69
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Method Not Allowed: The requested method POST is not allowed for the URL /writedhcp.p WiWa Linux - Networking 15 01-06-2011 02:20 PM
The method for loading from CD Metablade Linux - Newbie 11 10-12-2005 03:59 PM
best rar method icga Linux - Software 5 07-26-2005 10:54 AM
best backup method slightcrazed Linux - General 9 06-26-2003 04:23 PM
A Different Method Bigun Linux - Networking 2 05-23-2003 06:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:59 PM.

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