×
Create a new article
Write your page title here:
We currently have 3,189 articles on s23. Type your article name above or create one of the articles listed here!



    s23
    3,189Articles
    in:

    Unix/Usefull Commands

    Revision as of 06:03, 25 January 2007 by imported>mutante (wiki links to the manpages)

    just a quick dump of some usefull unix commands

    List the top ten largest files

    du -sk * | sort -rn | head -10

    nslookup

    nslookup will return infomation about domain names.

    nslookup

    nslookup -d {server}
    


    Host

    host will return infomation about domain names.

    host domain name


    -t querytype

                    Allows you to specify a particular querytype of information
                    to be looked up.  The arguments are defined in the man page
                    for named(8).  Currently-supported types include: ``a,
                    ``ns, ``md, ``mf, ``cname, ``soa, ``mb, ``mg,
                    ``mr, ``null, ``wks, ``ptr, ``hinfo, ``minfo,
                    ``mx, ``uinfo, ``uid, ``gid, ``unspec. Additional-
                    ly, the wildcard, which may be written as either ``any or
                    ``*, can be used to specify any (all) of the above types.
                    Types must be given in lower case.  Note that the default is
                    to look first for ``a, and then ``mx, except that if the
                    verbose option is turned on, the default is only ``a. The
                    ``-t option is particularly useful for filtering informa-
                    tion returned by host; see the explanation of the ``-l op-
                    tion, below, for more information.
    

    dig

    Dig gets infomations from DNS

    dig @{servers NS} {server} [axfr|MX|NS|any]

    axfr is a full zone tranfeer

    any will retreave every thing it can


    example of finding out about a domain name

    $ host -t NS microsoft.com
    microsoft.com name server ns3.msft.net.
    microsoft.com name server ns4.msft.net.
    microsoft.com name server ns5.msft.net.
    microsoft.com name server ns1.msft.net.
    microsoft.com name server ns2.msft.net.
    
    $ dig @ns3.msft.net microsoft.com any
    
    ; <<>> DiG 9.3.2 <<>> @ns3.msft.net microsoft.com any
    ; (1 server found)
    ;; global options:  printcmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 259
    ;; flags: qr aa rd; QUERY: 1, ANSWER: 12, AUTHORITY: 0, ADDITIONAL: 5
    
    ;; QUESTION SECTION:
    ;microsoft.com.                 IN      ANY
    
    ;; ANSWER SECTION:
    microsoft.com.          3600    IN      A       207.46.232.182
    microsoft.com.          3600    IN      A       207.46.197.32
    microsoft.com.          172800  IN      NS      ns4.msft.net.
    microsoft.com.          172800  IN      NS      ns5.msft.net.
    microsoft.com.          172800  IN      NS      ns1.msft.net.
    microsoft.com.          172800  IN      NS      ns2.msft.net.
    microsoft.com.          172800  IN      NS      ns3.msft.net.
    microsoft.com.          3600    IN      SOA     dns.cp.msft.net. msnhst.microsoft.com. 2007010701 300 600 2419200 3600
    microsoft.com.          3600    IN      MX      10 mailb.microsoft.com.
    microsoft.com.          3600    IN      MX      10 mailc.microsoft.com.
    microsoft.com.          3600    IN      MX      10 maila.microsoft.com.
    microsoft.com.          3600    IN      TXT     "v=spf1 mx include:_spf-a.microsoft.com include:_spf-b.microsoft.com include:_spf-c.microsoft.com include:_spf-ssg.microsoft.com ~all"
    
    ;; ADDITIONAL SECTION:
    ns4.msft.net.           3600    IN      A       207.46.66.126
    ns5.msft.net.           3600    IN      A       65.55.238.126
    ns1.msft.net.           3600    IN      A       207.68.160.190
    ns2.msft.net.           3600    IN      A       65.54.240.126
    ns3.msft.net.           3600    IN      A       213.199.144.151
    
    ;; Query time: 12 msec
    ;; SERVER: 213.199.144.151#53(213.199.144.151)
    ;; WHEN: Mon Jan  8 04:25:11 2007
    ;; MSG SIZE  rcvd: 502
    


    Ill try to add info about waht all this means.


    List processes and ports:-

    ps -e -o pid= | xargs -i pfiles {} | xargs -i perl -e ' if
    (@ARGV[0]=~/^\d+.*$|port/){if (@ARGV[0]!~/mode/) {print @ARGV[0]."\n"}}' "{}"
    

    Rename files with 'tr':-

    for i in *.xml; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done
    
    

    Recursively chgrp:-

    find . -group 501 -exec chgrp 500 {} \;
    

    Grep recursively ASCII files only:-

    find . -type f -print -exec file {} \; | grep ASCII | awk -F: '{print $1}'
    | xargs -i grep --with-filename searchstring {}
    

    Sum memory usage of process:-

    ps -aux | grep java | awk '{sum = sum + $5} END {print sum}'
    

    Copying files from a remote machine without scp:-

    ssh <user>@<remote> "cat /foo/bar/random.tar.gz" | cat >/local/dir/random.tar.gz
    
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.