Pages

Welcome to My Blog

This is to share my IT experience with friends all around the world.
I have been working in Linux Fedora Systems for more than 8 years. Its fun to share knowledge and learn..
As everyone knows when a problem arises in your systems "googling" is the way that many depend on..

All the posts here are my working experiences during my working life.. So you can count on it..

I have added the references where I got help in solving IT issues


Thursday, May 26, 2011

Short & Sweeet

Under this topic I would like to state some useful tips in services and systems. Hope this will be a huge collection on commands/shortcuts one day...

  • Finding the DNS bind version of a DNS server
  • Command: dig version.bind txt chaos @dnsserver_ip
  • Stop displaying BIND version to outsiders in version.bind query
  • Just insert ' version "whatever you wan't to display for version queries"; ' to the options{}; E.g. options { directory "/var/named"; version "< HIDDEN >"; };
  • Display the directories (folders) in Linux
  • There are few ways of doing this in Linux.
    • ls -d */
    • This will display the directories in the current working directory
    • tree -d
    • This will list the directories in tree structure
    • echo */
    • This also displays the directories in a line. For example you can give the location as echo /home/* (which lists all the home folders of the users.)
  •   Accessing Zipped/Tar contents in Linux 
         Processing a .tar or .zip file, without decompressing it, is required in many occasions. Following commands are useful to extract data from a compressed archive.
    • tar -t
    • This will display or list the files/directories in the compressed archive.
    • zcat file1 | grep -e "test"
    • This will list all lines containing 'test' in the archived file file1. Similar to gunzip -c
       
File Contents filtering
    • cut 
                Very useful command to display the fields of a file.

    • grep
Few of very rare commands
Following commands are very rarely used but useful. Check whether you are familiar with them
  • ss
       This is very similar to netstat -nr but gives more information
  • pstree
  • This will display all the processes running currently along with associated child processes in tree format 
  • space
  • Space is a command which can be used to cheat history command. If you type the command with a space before the command, that command will not be listed with history command
Useful commands to 
  • check changed files in a directory (including sub directories) within a week and save details in to a file
find /path/to/the/directoty -mtime -7 -ls > changed_files
  • remove unwanted contents and send the details to someone
sed '/contents_to_be_removed/d' changed_files | nail -s "Changed files" -c cc_to@yourdomain someone@yourdomain
     
Here the 'find' command will list the files changed within a week time in the given directory and its subdirectories and the details will be written to the changed_files file. Later if you identifies any unwanted data in the listed file details, you can delete using 'sed' command the the patten of the content which should be deleted. The 'nail' command can be used to send the filtered content to someone and -c switch can be used to cc the mail to some other mail recipient.
 
 
 

Good reference

    No comments:

    Post a Comment