Thursday, April 25, 2019

How to symlink a file in Linux? [SOLVED]

How to create symlink for a file/directory ?

Today I will show you how to create a symlink to a file or folder.
In linux, a symbolic link, also known as a symlink or a soft link, is a special kind of file (entry) that points to the actual file or directory on a disk (like a shortcut in Windows)

So lets create one: 

in order to create a new symlink try below


ln -s /path/to/file /path/to/symlink


To create or update a symlink:
ln -sf /path/to/file /path/to/symlink


How to list all symlink in a directory ?
Now you have created a symlink. To see present symlink for current directory you can try below command:

ls -la /var/www/ | grep "\->"

This will list all the links present in the current directory.

Let me know if this resolves your problem 😃



Tags:

Friday, April 19, 2019

Search in all files for specific string on Linux [SOLVED]

If you want to search a word in all of your files on your linux you need to run grep command. This command has some parameters. All explained below:

grep -rnw '/path/to/somewhere/' -e 'pattern'
  • -r or -R is recursive,
  • -n is line number, and
  • -w stands for match the whole word.
  • -l (lower-case L) can be added to just give the file name of matching files.
Along with these, --exclude--include--exclude-dir flags could be used for efficient searching:
  • This will only search through those files which have .c or .h extensions:
    grep --include=\*.{c,h} -rnw '/path/to/somewhere/' -e "pattern"
    
  • This will exclude searching all the files ending with .o extension:
    grep --exclude=*.o -rnw '/path/to/somewhere/' -e "pattern"
    
  • For directories it's possible to exclude a particular directory(ies) through --exclude-dirparameter. For example, this will exclude the dirs dir1/, dir2/ and all of them matching *.dst/:
    grep --exclude-dir={dir1,dir2,*.dst} -rnw '/path/to/somewhere/' -e "pattern"
    
This works very well for me, to achieve almost the same purpose like yours.
For more options check man grep

There appears to be trouble with your network connection. Retrying... [SOLVED]

So recently I was facing an issue while adding Yarn package to my application. Every time I was doing Yarn add it was showing me error like There appears to be trouble with your network connection. So problem is, this happens when your network is too slow or the package being installed is too large, and yarn just assumes it's a network problem. Lets try increasing Yarn network timeout!

To resolve this problem all you need to do is:

yarn add <yourPackage> --network-timeout 100000


Now if problem still exists then you need to add proxy.
To add proxy just do below.

$ yarn config set proxy http://your_company_proxy_url:port
$ yarn config set https-proxy http://localhost:3128

example $ yarn config set https-proxy http://proxy.example.com:8080

Add a comment below if problem still exists :) Will be happy to help you!