SEARCHING http://stackoverflow.com/questions/16956810/finding-all-files-containing-a-text-string-on-linux https://en.wikipedia.org/wiki/Binary_prefix https://linuxjourney.com/lesson/stderr-standard-error-redirect stdin, stdout and stderr is 0, 1, and 2 respectively. Searching outside home folder could be restricted - therefore being root would be useful FIND (man find) from current location find . -name searching from given location find /home -name turn off case sensitive during searching find /home -iname search folder by name, errors redirect to "black hole" find / -type d -name find /var -type d -name *run* 2> /dev/null search from multiple folders find /opt /usr /var -name "*.log" -type f search different types of files find . -type f \( -name "*.txt" -o -name "*.sh" \) # *.txt and *.sh files find . -type f \( -name "*cache" -o -name "*xml" -o -name "*html" \) # three type of files search files that does not correspond to the pattern find . -type f -not -name "*.html" in addition the result can be filtered using grep search specific type of files find /etc -type f -name "*.log" N: find /etc/ -name "*.log" search using specific permissions 777 find /etc -type f -perm 0777 … all files that do not have permissions 777 find /etc -type f ! -perm 0777 … permissions SGID, 644: find / -perm 2644 with sticky bit, permissions 551: find / -perm 1551 SUID permissions: find / -perm /u=s SGID permissions: find / -perm /g=s only with reading permissions: find /home -perm /u=r executable files find /home -perm /a=x search all files with permissions 777 and change them to 644 find /your/path -type f -perm 0777 -print -exec chmod 644 {} \; in case of web server, the permissions usually are: folders: 755 files: 644 search all folders with permissions 777 and change them to 755 find /your/path -type d -perm 777 -print -exec chmod 755 {} \; find and delete one file find . -type f -name "filename" -exec rm -f {} \; search and remove multiple files find . -type f -iname "*.txt" -exec rm -f {} \; find . -type f -iname "*.wav" -exec rm -f {} \; search empty files find /tmp -type f -empty search empty folders find /tmp -type d -empty search hidden files find /tmp -type f -name ".*" search file belonging to user find /home -user root -name filename search all files belonging to user find /home -user root find /your/path -type d -user student -print -exec chown root: {} \; search all files belonging to group find /home -group developers search specific types of user files find /home -user root -iname "*.txt" find all files that has been changed in last 10 days find /home -mtime 10 search files that has been used in last 10 days find /home -atime 10 search files that has been used in last 10-20 days find /home -mtime +10 -mtime -20 search files that state has been changed during last 60 minutes find / -cmin -60 find all files that has been changed last one hour find / -mmin -60 find all files that has been viewed in last one hour find /etc -amin -60 search files by size find /var/log/ -size 2M search files between 2MB-10MB find /usr -size +2M -size -10M search and delete all files in size 100 MB find /tmp -size +100M -exec rm -rf {} \; find and delete files with specific types and size find /tmp -type f -name *.exe -size +10M -exec rm {} \; GREP (search by content) shows also found file path grep [OPTIONS] PATTERN [FILE...] grep [OPTIONS] [-e PATTERN]... [-f FILE]... [FILE...] search IP-address from log files recursively (-R) with symlinks, non-case sensitive (-i) grep 192.168.56.200 /var/log/ -iR grep -rnw /etc/grub.d/ -e "set -e" -r recursively without symlinks -n line numbers in file -w whole words compare results: grep -rnw '/usr/include/' -e "CONNTRACK" grep -rn '/usr/include/' -e "CONNTRACK" can be extended by including (--include) or excluding (--exclude) grep --include=\*.{c,h} -rnw '/path/to/somewhere/' -e "pattern" only .c ja .h type of files will be searched e.g.: grep --include=\*.{c,h} -rnw '/usr/src/' -e "linux" | grep nfs filter in turn from results "nfs" (Network File System) grep --exclude=*.o -rnw '/path/to/somewhere/' -e "pattern" grep --exclude=*.o -rnw '/etc/' -e "set -e" .o type of files will be excluded also folders can be included (--include-dir) or excluded (--exclude-dir): grep --exclude-dir={dir1,dir2,*.dst} -rnw '/path/to/somewhere/' -e "pattern" show the filename, not result: grep -Ril whenever needed, filter result in turn: N: grep -Ril system '/usr/src/' | grep ethernet not case sensitive (-i) grep -inR "string" 'location' filtering using pipe: dmesg | grep usb looking location and other information whereis bash which bash type bash stat /bin/bash look the file type file /bin/bash More complex searches ------------------- search regular files (f) and run (-exec) text search "set -e" among found results and display full output find /etc/grub.d/ -type f -exec grep "set -e" {} \; -print for programmers - ack - http://beyondgrep.com to install: sudo apt update && sudo apt install ack-grep && sudo apt clean man ack ack [options] PATTERN [FILE...] ack -f [options] [DIRECTORY...] or simply: ack 'search string' 'location' (apostrophes are especially needed when path contains spaces) e.g.: ack nameserver /etc/