×
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: Difference between revisions

    Content added Content deleted
    imported>DrOwl
    No edit summary
    imported>mutante
    m (wiki links to the manpages)
    Line 1: Line 1:
    just a quick dump of some usefull unix commands
    just a quick dump of some usefull [[unix]] commands


    ==List the top ten largest files==
    ==List the top ten largest files==


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


    == nslookup ==
    == nslookup ==
    nslookup will return infomation about domain names.
    [[nslookup]] will return infomation about domain names.


    nslookup
    nslookup
    Line 14: Line 14:


    == Host ==
    == Host ==
    host will return infomation about domain names.
    [[host]] will return infomation about domain names.


    host domain name
    host domain name
    Line 38: Line 38:
    Dig gets infomations from DNS
    Dig gets infomations from DNS


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


    axfr is a full zone tranfeer
    axfr is a full zone tranfeer
    Line 100: Line 100:
    ==List processes and ports:-==
    ==List processes and ports:-==


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


    Line 109: Line 109:
    ==Recursively chgrp:-==
    ==Recursively chgrp:-==


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


    ==Grep recursively ASCII files only:-==
    ==Grep recursively ASCII files only:-==
    Line 122: Line 122:
    ==Copying files from a remote machine without scp:-==
    ==Copying files from a remote machine without scp:-==


    ssh <user>@<remote> "cat /foo/bar/random.tar.gz" | cat >/local/dir/random.tar.gz
    [[ssh]] <user>@<remote> "cat /foo/bar/random.tar.gz" | cat >/local/dir/random.tar.gz


    [[Category:Unix]]

    Revision as of 06:03, 25 January 2007

    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.