Admin's Choice » All Posts Fri, 18 May 2018 13:20:21 +0000 en-US <![CDATA[How to chmod a folder, its subfolders and files]]> Thu, 04 Jan 2018 04:54:39 +0000 Hemant Sharma chmod -R 755 can change the permissions recursively but it will change same permissions for everything , folders,subfolders and files.

To selectively change permission , use find command to get the directories or files and then change mode.

find directories and change mode to 755

$find /home/james -type d -exec chmod 755 {} \;

find directories and chand mode to 755

$find /home/james -type f -exec chmod 644 {} \;

]]> <![CDATA[How to create a symlink to a file in Unix and Linux]]> Thu, 04 Jan 2018 04:45:15 +0000 Hemant Sharma symlink in unix/linux are created using ln ( lInK ) command and follows the same syntax as cp and mv command

ln -s

file name has to be either local or with absolute path

-s stand for soft symlink which can span file systems as it just points to existing file name. File contents are lost if original file is deleted.

Without any option ln creates hard link , which is limited to current file system only and point to inode of existing file, file contents are available as long as there is one link exists.

]]> <![CDATA[How to find all files containing a specific text in Linux?]]> Thu, 04 Jan 2018 04:09:41 +0000 Hemant Sharma If you want to do a recursive search and return the line number of found results, grep is best choice.

This is the basic syntax for doing recursive (r ) , Line number (n) and whole word (w) search for pattern.

grep -rnw ‘/some/path/dir/’ -e ‘pattern’

the search can be refined with additional options to include and exclude file and directories.

–exclude *.log
–include *.sh
–exclude-dir /usr/lib
–include-dir /usr/local

for example
grep –exclude *.log -rnw ‘/some/path/dir/’ -e ‘pattern’