-

  • - (528)
  • (259)
  • (195)
  • (100)
  • (89)
  • " " (67)
  • (64)
  • (57)
  • (50)
  • (47)
  • (33)
  • (26)
  • (23)
  • (19)
  • (18)
  • (16)
  • ;) (10)
  • (9)
  • (3)
  • - (2)
  • (2)

 -

 - e-mail

 

 -

   CommonReader

 -

 LiveInternet.ru:
: 27.02.2008
: 1387
: 780
: 4145

:


Solaris

, 30 2008 . 17:23 +

, . .

 Unix Commands

  1. at

  2. at 5pm FriDAy
    at 0815 tomorrow
    at 8:15pm jan24
  3. awk

  4. to add up fields:
      awk '{ total += $2 } END {print total}' erdas.mk4tape
  5. crontab file format:

  6. min   hr   day month day_of_week (0=Sun)
    0-59 0-23 1-31  1-12 0-6
  7. dd

  8. To copy a dump format tape from one machine to another
    sin at qws1 % foreach i ( 1 2 3 4 5 6 7 8 )
      rsh server dd if=/dev/nrst9 ibs=126b | dd of=/dev/nrst10 obs=126b
  9. find

  10. To find SUID and SGID files:
      find . \( -perm -04000 -o -perm -2000 \) -ls
    Find without descending into subdirs:
      find . \( -type d ! -name . -prune \) -o \( -type f -name "xx*" \) -ok rm {} \;
  11. sar

  12. To see today's CPU data between 11am and 4.30pm:
      sar -s 11 -e 16:30 -u
    sar options:
      -u CPU (wait for IO)
      -g page scan
      -b buffer cache (hit ratio)
      -p paging
      -r mem and swap
      -w swap
      -d disk
      -m msg/semaphore
      -q run queue
      -v process, inode & file descrip
      -k kernel memory usage
  13. sed

  14. delete all lines containing 'NFS'
      sed -e /NFS/d sourcefile

    print only lines starting with 'brian'

      sed -n -e /^brian/p sourcefile
      ( NB this is the same as grep "^brian" sourcefile)

    make horizontal cuts in large files:

      sed -n -e '12700,$p' file > file.2
      (this writes lines 12700 to end of file into file.2)

    make a global string substitution:

      sed -e 's/borg/mcenroe/g' file1 > file2

  15. sort

  16. sort passwd file by UID :
      sort -t: -k3n /etc/passwd
    Combined alphabetic/dictionary (f) and numeric (n) sort:
      sort -k2n -k1f fil2  (old syntax: sort +1n -0 +0f fil2 )
      dfg 0
      parm 3
      Set 3
      Tutu 3
      tutu 3
      Arch 17
      ergeg 17
      sdf 17
      Tutu 17
      tutu 17
      sdfgg 240
      5asdc 310
      asdc 310
      Dxp 310
  17. split

  18. e.g. split a binary into 1.4MB chunks:
      uuenode mybinary mybinary | split -b 1400k
    and to re-join the bits :
      cat xa? | uudecode
  19. tar

  20. To copy a tree, preserving symlinks:
    cd fromdir; tar cf - . | (cd todir; tar xvfBp -)

    or, from one machine to another:
    iws2# tar cf - /export/tools/imagine |dd bs=20b | rsh iws6 tar xvBfb - 20

    or
    tar cvfb - 20 /home/localdisk/SCTR9401_D01 | rsh iws5 tar xvBfb - 20

    To install a tar file from a remote tape drive :
    target% cd targetdirectory
    target% rsh -n tapeserver dd if=/dev/rmt/0 bs=20b | tar xvBfb - 20
     
     

  21. tr

  22. convert lower-case to upper:
      cat file | tr [a-z] [A-Z]
    change colons to newlines:
      tr : "\n"

  23. vi

  24. Editing multiple files (adding some text in this case)
      foreach person (alc bar gri igu jeu bon tac lag wyn)
      ? echo Editing $person
      ? vi -c "/OPENWINHOME\
      :r image/zxc" $person/.cshrc
      ? end

    Miscellaneous vi commands:
    :e!     go to previous file
    :e!     undo all mods on this file
    :args     show list of files being edited
    :rew     'rewind' back to first edited file
    "f4yy     yank 4 lines to buffer f
    "fp         put buffer f
    :w %.new     % is current filename
    !3!sort            run a Unix command on 3 lines
    /Alan/;/tree/     find 'tree' after 'alan'
    dwwP             swap words
    map z izxc^V<Esc>     do an insert mapping macro on key z

    Global replace:
    :%s/old/new/g     (% means all lines)
    or
    :g/old/s//new/g
    OR
    :g//s/old/new/gc      (c is to confirm each replacement, type 'y' to accept)

     

  25. xauth

  26. xauth list
    xauth add noah:0 MIT-MAGIC-COOKIE-1 7fe87df87

     

Solaris commands

  1. adb

  2. adb -P AdbPrompt -kw /dev/ksyms /dev/mem
  3. lpadmin

  4. To add access to a printer 'psi' on a remote printserver :
      lpadmin -p psi -s printserver
      lpadmin -p psi -I any
      accept psi
      enable psi
  5. lpstat

  6. Show complete configuration of a printer 'psi'
    lpstat -p psi -D -l
  7. ndd

  8. ndd /dev/hme ?             -see what's available
    ndd /dev/hme link_speed          -read a value
    ndd -set /dev/hme instance 1     -set a value
  9. patchadd

  10. patchadd [-d] /tmp/105632-09     (-d means no backout)
  11. pkgchk

  12. To list files contained in a SUNW package
    pkgchk -l SUNWdoc|grep "Pathname:"|more
  13. prtconf -shows system configuration info

  14. /usr/sbin/prtconf -vp    ( -p shows PROM info )
  15. prtdiag -shows hardware info (CPU temperature, fans etc. on Enterprise machines)

  16. /usr/platform/sun4u/sbin/prtdiag -v
  17. psrinfo    -shows CPUs' state: quick way to check how many CPUs a machine has
  18. showrev - show software versions installed

  19. showrev -p    ( -p shows patches installed )


Miscellaneous commands

To read man pages :

    nroff -man lpstat.man | more -s

Check login history for a specific user:

    last john
    ac -w /var/adm/wtmp -d john
    who /var/adm/wtmp

Pretty PostScript print:

    mp -A4 -l file.txt | lp

or

    /usr/lib/lp/postscript/postprint -n 2 file.txt | lp

ksh arithmetic (e.g. to print a sequence of numbers):

    i=23
    while [ $i -le 127 ]
    do echo "$i \c"
    i=$(($i+1))
    done

kernel memory usage:

    sar -k 1
    crash  then type kmastat
    netstat -k | grep arena (on 2.6 or older only)

set file descriptor limits (in /etc/system):

    set rlim_fd_cur=512
    set rlim_fd_max=1024
     

NIS

To modify NIS ypservers list:

    cd /var/yp/yourdomainname
    /usr/etc/yp/makedbm -u ypservers > ypservers.tmp
    vi ypservers.tmp
    /usr/etc/yp/makedbm ypservers.tmp ypservers
    /usr/etc/yp/yppush ypservers


How to pull NIS maps from master (SunOS)

    for map in bootparams ethers.byaddr ethers.byname group.bygid group.byname hosts.byaddr hosts.byname mail.aliases mail.byaddr netgroup.byhost netgroup.byuser netgroup netid.byname netmasks.byaddr networks.byaddr networks.byname passwd.byname passwd.byuid protocols.byname protocols.bynumber publickey.byname rpc.bynumber services.byname timezone.byname ypservers
    do
    /usr/etc/yp/ypxfr -h bws3 $map
    done


How to check domain/master etc (NIS)

    /usr/etc/yp/yppoll -d weusc passwd.byuid
    Domain weusc is supported.
    Map passwd.byuid has order number 821988686.
    The master server is bws3

NIS+

Set up NIS+ master server:

    root@server2# nisserver -r -d weusc.org.
    root@server2# nispopulate -F -p /etc -d weusc.org.


Set up NIS+ clients:
root@sws1# nisclient -i -d weusc.org. -h nis_server
and then reboot.

Setting up a NIS+ replica
set up replica as client first, then start rpc.nisd [-Y] (-Y for NIS compatibility)
then on master :
nisserver -R -d weusc.org. -h replica_hostname

Removing NIS+
change nsswitch.conf
then

    /etc/init.d/rpc stop
    rm /etc/.rootkey
    rm /var/nis          (/var/nis/data means a NIS+ server)
    rm /etc/defaultdomain
    /etc/init.d/rpc start


Adding NIS+ admins:

    nisgrpadm -l admin
    nisgrpadm -a admin rsincla
    nisgrpadm -r admin jspence


Delete contents of a NIS+ table:

    nistbladm -R services.org_dir.weusc.org.


Populate a single table: (in this case, populate services table from the file (-F) /etc/services:

    nispopulate -F -p /etc -d weusc.org. -l rewopas2 services


MERGE the contents of a file with an existing table:

    root@server# nisaddent -mv -f /etc/nis/services services
    merging /etc/nis/services into table services.org_dir.weusc.org.
    adding/updating internal4 51204/udp
    adding/updating NC_trap1 51001/udp
    adding/updating erdas-security 1530/tcp
    ...


Also useful:

    nisping -C weusc.org.
    niscat passwd.org_dir


Creating a new table (copied from/usr/lib/nis/nissetup):

server# nistbladm -D access=og=rmcd,nw=r -c automount_map key=S,nogw= value=,nogw= auto_direct.org_dir.weusc.org.

Adding new lines to auto_direct:

    server# vi /etc/auto_direct
    server# nispopulate -F -p /etc -d weusc.org. auto_direct


Networking

  1. Net boot e.g. boot linux on a Sun box

  2. on server, create /tftpboot/redhat51.img and set up tftp, ethers, bootparams etc.
    on client,
    devalias linux net:159.167.93.23,redhat51.img,159.167.93.30,
                                      server's IP                           client's IP
  3. snoop

  4. snoop -x0 -p5 see all of packet 5
  5. spray

  6. spray -l 1502 -c 100000 hostname
  7. TCP wrappers

  8. # entries are of the form (use in conjunction with /etc/hosts.deny):
    # ALL: hosta, hostb, .some.domain
    # or
    # in.ftpd, in.telnetd: ALL
    # Take care with the quoted newline form. The \ must be the last
    # character on the line. You don't need a \ on the last line of a
    # block (ie. only after a comma)
    in.telnetd: 192.168.67.,195.92.21.,\
          192.168.7.
    in.fingerd: ALL
    in.ntalkd: LOCAL

DiskSuite
Mirroring root etc:

    metainit -f d10 1 1 c0t0d0s0
    metainit d20 1 1 c1t0d0s0
    metainit d0 -m d10

.. and so on for /usr, /var etc.

    metaroot d10 (changes vfstab for root only)
    [lockfs -fa]
    reboot
    metattach d0 d20


Unmirroring

    metastat d6 (make sure state is OK)
    umount /opt
    metadetach d6 d26
    metaclear d26
    metaclear -r d6

    edit vfstab


Concatenating

    umount /opt
    metainit d15 2 1 c0t0d0s5 1 c0t1d0s5
    mount /dev/md/dsk/d15 /opt
    growfs -M /opt /dev/md/rdsk/d15
     

To add a third slice to /opt:

    metattach d15 c0t10d0s6
    and then growfs again

-
:  

: [1] []
 

:
: 

: ( )

:

  URL