Find Anything On your Linux Server

in #tutorial7 years ago

In Linux you there are different commands to find or locate files, directories , word, sentences.etc..., in this tutorial i am going to show you some commands that are really helpful for finding different types of files and commands


Source

(The Level is beginner)

grep

grep command is another one to help you find a word or sentence in a file that matches a regular expression, grep is a very powerful tool to do a search through all the files and output what you are looking for. imagine you get are looking for a specific word in your binary files, the only thing you need to do is executing this command:

grep "the Specific word or sentence" /* -R # it is going to search through root directory and all the sub directories of root

find

by 'find' command you are able to search through directories and find files and directories based on their name, size, type, etc...
find command is one of the useful commands that can become handy when you are writing the script to administer your rver, for example, you can write a script to monitor your directories and find the files that start by a name and their size is bigger than 1GB

Some Examples:

find / -name my file # searching for a file named myfile in / directory
find / -size +1G # Searching for files, greater than 1GB
find / -size -1G # Searching for files, smaller than 1GB
find / -type d -name mydirectory # searching for directories named mydirectory.

you can search for blocks, characters, symbolic files ,etc..
there is lots of option with find command that you can use and make your script more powerful, "man find" is the manual for the find command

locate

locate command is a very fast search engine that benefits from a database, and the database get updated regularry , it means if you create a new file, you wont find the file for a period of time, or run the updatedb command manually

locate testfile

as you see after the updatedb command the specific file is found

whatis

shows description about the commands

whatis test # shows the description about test command

whereis

whereis command will locate the programs, by this command you will be able to see where your binaries.

I hope these command that are basically used for searching, help you to do a better job at administrating your Linux based systems and powerful scripts.

Sort:  

Great post ! Today i just lost my job...i worked really hard as a waiter for like 10 years in a restaurant...worked night after night shifts but still they decide they don't need my services anymore and that they don't have money to pay me so they just kick me out . It was really hard for me to find this job because i don't have much education....i did't go to college...
The real problem is that i have a debt of 759 $ to my apartment rent and if i don't pay till the end of the month they gonna kick me out from my own home. I don't have friends and my family won't lend me any money...
My only hope now to raise this money is steemit...i like it alot here and the community is very nice...

Please if anybody would like to help me , a upvote would be awesome and would help me tremendously to raise the money i need .

Thank you very much for your help and i hope you have a great day .

Start learning Linux, you'll find a better paying job in no time! irancrypto's post is the first step!

Congratulations @irancrypto! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

You got your First payout

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

Tip: if your grep outputs colour, the command is aliased to something like grep --color=auto. You can check with the alias command.

There's nothing wrong with that, until you start using pipe (|) to use grep's output in other commands. The --color switch adds ANSI characters for colour and this can have unexpected results.

To be safe, unset the alias (check ~/.bashrc, ~/.profile or one of the other files that's sourced on login) or run \grep. The \ in front of it will run the actual command, not the aliased command.

nice tip ,thank you @slash-es

Great a post..., Are u usually Used Linux?

Coin Marketplace

STEEM 0.20
TRX 0.12
JST 0.029
BTC 61358.50
ETH 3378.70
USDT 1.00
SBD 2.52