Useful commands in linux

Commands used to find files in Linux:

  • find, example: find / -name “textToSearch” where / is the root directory in this case and you can changed it to match your desired directory and the -name is telling that we are searching on file name.
  • which, is great for binaries, example: which filename, it returns the binary path of the filename
  • whereis, same as which,
  • locate, example: locate filename

Commands used to create hardlinks and symbolic links:

  • ln /etc/hosts computers –  The file that we want to hard link to is hosts and the destination file is computers
  • ln -s /etc/hosts computersSym – The file that we want to symbolink link to is hosts and the destination file is computersSym

tar command:

tar cvzf /root/etc.tar /etc  – this command creates an etc.tar file of /etc directory  in /root directory, where c-create, v-verbose, f-file, z-compress

tar tvf – is used to check the content of a compressed file, t-test

tar xvf /root/etc.tar -C / etc/wgetrc – is used to extract the wgetrc file, -C / is telling that the file is being extracted to /etc directory

To check a file for its extension use the following command:

file exampleFile.ext