10 ways to finding things in linux
Basically i am talking about Linux terminal and without installing any new programs. I will also not use any programming languages. I am not digging into regexp details, please refer to their documentations. Many programs have their own regexp and syntax so I usually pipe the output to the input of egrep or such to satisfy my needs. This document is for reference and only states how i use them. These are obviously not the only ways.
1. ls (dir also does things similar) : List the contents. Ls is the first command I use to search in Linux. Obviously the very basic but also, very useful if you know in which directory your file is. This command was written partly by Richard stallman himself. To do a simple search just type ls followed by the file name. Other examples:
# To search file names with a fixed file-type (Using Wildcard)
# Here I am searching for mp3 files in my current directory
ls -C *.mp3
* this matches everything that has a ‘.mp3’ anywhere in the filename and puts it in a column (-C).
# To search for file whose filetype and first starting character I remember
# I am searching for mp3 files whose first character is y
ls | egrep ‘^[Yy].*.mp3$’
* this matches everything starting(‘^’ for starting character) with a ‘Y or y’ and any number (here ‘*’ for any number of times) of character (here ‘.’ for any character) following it which ends in “.mp3” (here $ as end of line).
2. locate : Locate is a command line file search utility which finds file by it’s name until regexp is used. Unlike ls, locate searches for files in all directories. But it has a major drawback. It uses a database(‘/var/lib/mlocate/mlocate.db’) to search from, which might not be updated all the time.
# To update the database use
updatedb
3. who (also, finger and w) : While a little different, it searches for users who are logged into the computer right now. Finger provides a little more detail
# To find out who logged into the system after the computer booted type:
who -a -H
4. whatis (apropos and man) : These commands searches for discription about some binaries, files whose manual pages are available. It is very useful to find out if an application is installed which additionally displays descriptions (short description in whatis and broader and long description in apropos and a complete manual with man) of the application. whatis and apropos supports regex and wildcards.
# To find out if ls is installed in your system with whatis type:
whatis ls
# To do the same with apropos
apropos -e ls
(More …)
Javin @ FIX Protocol Tutorial 1:48 pm on February 22, 2011 Permalink |
Thanks for this nice article. here is my list of top 10 basic networking command in unix I would rather say very useful and practical unix linux networking commands 🙂
Thanks
Javin Paul
FIX Protocol tutorial
warcraft 2 9:59 pm on February 22, 2011 Permalink |
It was something of great contentment discovering your site the other day. I arrived here now hoping to come across interesting things. And I was not let down. Your ideas in new techniques on this subject material were topical and an excellent help to me personally. Thank you for creating time to create these things and then for sharing your thoughts.
linuxhospital 3:09 am on May 12, 2013 Permalink |
Good one 🙂 Very helpfull