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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
01-06-2003, 08:24 AM
|
#1
|
LQ Newbie
Registered: Dec 2002
Location: Montreal
Distribution: Mdk9
Posts: 20
Rep:
|
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
|
|
|
01-06-2003, 08:29 AM
|
#2
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417
|
depends what kind of a search.... if you want to find files, the "find"
|
|
|
01-06-2003, 08:32 AM
|
#3
|
LQ Newbie
Registered: Dec 2002
Location: Montreal
Distribution: Mdk9
Posts: 20
Original Poster
Rep:
|
"Find isn't enabled"
I have the barest of bones... finding files is the idea
So lets recap - locate, where, find. -> all disabled
|
|
|
01-06-2003, 09:50 AM
|
#4
|
Senior Member
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552
Rep:
|
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.
|
|
|
01-06-2003, 11:26 AM
|
#5
|
LQ Newbie
Registered: Dec 2002
Location: Montreal
Distribution: Mdk9
Posts: 20
Original Poster
Rep:
|
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
|
|
|
01-06-2003, 11:33 AM
|
#6
|
LQ Guru
Registered: Jan 2001
Posts: 24,149
|
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.
|
|
|
01-06-2003, 11:37 AM
|
#7
|
LQ Newbie
Registered: Dec 2002
Location: Montreal
Distribution: Mdk9
Posts: 20
Original Poster
Rep:
|
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?
|
|
|
01-06-2003, 06:13 PM
|
#8
|
Senior Member
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552
Rep:
|
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.
|
|
|
01-06-2003, 06:38 PM
|
#9
|
LQ Newbie
Registered: Jan 2003
Location: USA
Posts: 18
Rep:
|
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
|
|
|
01-06-2003, 06:47 PM
|
#10
|
LQ Newbie
Registered: Jan 2003
Location: USA
Posts: 18
Rep:
|
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
|
|
|
01-06-2003, 08:47 PM
|
#11
|
Senior Member
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552
Rep:
|
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.
|
|
|
01-07-2003, 12:56 AM
|
#12
|
Senior Member
Registered: Sep 2002
Location: Arizona, US, Earth
Distribution: Slackware, (Non-Linux: Solaris 7,8,9; OSX; BeOS)
Posts: 1,152
Rep:
|
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.
|
|
|
01-07-2003, 07:01 AM
|
#13
|
LQ Newbie
Registered: Jan 2003
Location: USA
Posts: 18
Rep:
|
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
|
|
|
All times are GMT -5. The time now is 12:59 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|