How to search recursively whole Linux system ?

Lets have a quick tip to search our whole system for some specific file or a file which contains a specific text.

To search a file containing a text say “nglinux”, we can search using below command.

1. Using grep recursive option if available.

[root@nglinux ~]# grep -ir "nglinux" / | head -5
/root/.bash_history:ls -l /usr/nglinux/
/root/.bash_history:ls -l /mnt/nglinux/
/root/.bash_history:ls -l /media/nglinux/
/root/.bash_history:cd /mnt/nglinux/
/root/.bash_history:cd ../hgfs/nglinux\ data/
/root/.bash_history:mount /dev/sr0 /mnt/nglinux/
[root@nglinux ~]# 

2. Using find and xargs in case grep recursive function not available.

[root@nglinux ~]# find / -type f -print | xargs grep -i "nglinux" | head -5
/root/.bash_history:ls -l /usr/nglinux/
/root/.bash_history:ls -l /mnt/nglinux/
/root/.bash_history:ls -l /media/nglinux/
/root/.bash_history:cd /mnt/nglinux/
/root/.bash_history:cd ../hgfs/nglinux\ data/
/root/.bash_history:mount /dev/sr0 /mnt/nglinux/
xargs: grep: terminated by signal 13
[root@nglinux ~]# 

I hope you liked the article, please feel free to post any further suggestions/feedback or comments.

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments