Mittwoch, 10. Dezember 2008

Einige nützliche befehle opensolaris

Processor info : /usr/sbin/psrinfo -pv
Architecture info : /usr/bin/isainfo
Summary system info : /usr/sbin/prtdiag
Disk primary partitions : /sbin/fdisk /dev/rdsk/c*d*p0
Detailed hardware info from BIOS: /usr/sbin/smbios
Detailed Kernel Statistics : /usr/bin/kstat
displays summary usage /usr/bin/kstat -h
list all modules & stats /usr/bin/kstat -l

Print solaris VTOC table : /usr/sbin/prtvtoc /dev/dsk/c*d*s2
Accurate measure of free memory
Login as root
Execute /usr/bin/mdb -k
Enter command ::memstat
CTRL+D to come out of mdb

Closer to actual estimate of process memory usage excluding the mmap-ed shared libs. (Look at the total for the 4th column labeled "Anon". Also add in any non-Anon memory usage for the process itself) :
/usr/bin/pmap -x

See the function call stack of a running process :
/usr/bin/pstack

See which libraries a process is using :
/usr/bin/pldd

See the command line arguments with which the process was started :
/usr/bin/pargs

See the process hierarchy :
/usr/bin/ptree
/usr/bin/ptree 1 gives the entire process hierarchy for the system.

Change Desktop resolution dynamically -
Execute /usr/X11/bin/xrandr to list possible resolutions
Execute /usr/X11/bin/xrandr -s to set the resolution
In addition Xfce and KDE provide their own stuff for this.

Look at network stack parameters
/usr/sbin/ndd
eg: /usr/sbin/ndd /dev/tcp \? displays all tcp parameters
Other network devices are: /dev/ip, /dev/udp, /dev/icmp, /dev/ip6
/dev/tcp6, /dev/ipsecah, /dev/ipsecesp, /dev/sctp, /dev/sctp6

Set network stack parameters -
/usr/sbin/ndd -set
Only root can do this and be very careful about playing with this.

Multiple virtual consoles in Command Line login -
Use the GNU screen utility /usr/foss/bin/screen utility. After
executing screen you can use CTRL-AC to create a new console,
CTRL-AA to alternate between two consoles, CTRL-A to
switch to a console with a particular number.


Setting up a static IP Address configuration

BeleniX enables NWAM (Network Auto-magic) by default so it should auto-detect your connected network interfaces and configure via DHCP. If you need to configure a static IP then you must first disable NWAM using: svcadm disable nwamThen follow these steps to configure static IP (The BeleniX package repository will soon include the JDS GUI tools for network configuration).

Non-Persistent static IP configuration

/sbin/ifconfig may be used in the following way:
ifconfig broadcast netmask In addition /usr/bin/netprof can be used to have network profiles. One needs to create a profile in /etc/netprof/ directory using one of the files as a template. This is fairly easy to do. Subsequently one needs to execute /usr/bin/netprof to select and activate the profile. But if configuration needs to persist across reboots without having to run netprof or ifconfig every time one needs to follow the below procedure.

Persistent static IP configuration:

  • Select a name for your host and enter it in the /etc/nodename file. This file must have exactly one entry, which is the hostname. Example: echo belenix-box-1 > /etc/nodename
  • Edit /etc/hosts and add your hostname to ip address mapping. If you are in a domain, you may want to add another entry with the fully qualified domain name as well. Example:
    127.0.0.1 localhost
    192.168.0.150 belenix-box-1 belenix-box-1.yourdomain.com loghost

  • Determine which interface will be connected to the network. Lets assume that your hme0 network interface is connected to the network. Then create a file called /etc/hostname.hme0 which contains the hostname as in step (1): Example: echo belenix-box-1 > /etc/hostname.hme0
  • Create or edit the /etc/defaultrouter file and enter the IP Address of the default router. This will have been provided to your by your network admin or ISP. Example: echo 192.168.0.1 > /etc/defaultrouter
  • Now you need to setup name resolution. Typically you'll want to use DNS and the list of nameservers will have been provided to you by your network admin or ISP. So you will have to setup /etc/nsswitch.conf and /etc/resolv.conf. Example: Our example /etc/resolv.conf contains the following lines:
    domain yourdomain.com
    search yourdomain.com
    nameserver 208.67.222.222
    nameserver 208.67.220.220
    These details will be different in your case. Execute: /usr/bin/cp /etc/nsswitch.conf.dns /etc/nsswitch.conf
    Now you can reboot and the settings will automatically take effect. You can also perform the following tests to confirm that everything is fine:
    $ ping
    $ ping
    $ ping
    $ ping
    You can also activate the configuration without rebooting. After doing the above 6 steps execute an ifconfig command as mentioned in the beginning to directly configure the IP address on the network interface. Then execute "svcadm enable dns/client" and things should begin to work. Later versions of BeleniX is expected to contain a Network configurtion UI to avoid having to manually perform these steps. Example:
    • Perform steps 1 - 5
    • Execute:
      /sbin/ifconfig hme0 192.168.0.150 broadcast 192.168.0.255 netmask 255.255.255.0
    • Add default route:
      /sbin/route add default 192.168.0.1 <- The gateway ip
    • If you do not have default gateway info:
      /sbin/route add default belenix-box-1
    • Execute: svcadm enable dns/client

Adding and Deleting users

You can add users easily via the graphical KDE User Manager(KUser) utility or you can do it manually via the command line. If you want to use command line the text below will be of help: The /usr/sbin/useradd command can be used to add users. Example:
/usr/sbin/useradd -d /export/home/fubar -m -u 1000 -g fugroup -e 10/10/2010 -s /usr/bin/ksh fubar
This example illustrates several options:
-d Sets the user's home directory. On OpenSolaris local users should have home directory under /export/home as /home is used by the automounter.
-m Instructs to automatically create user's home directory
-s Sets the user's shell to /usr/bin/ksh. This is optional and shell defaults to /bin/sh if this is left out.
-u Optionally sets the user's id. An ID is auto-generated if this is left out.
-g Optionally add the user to the given group.
-e Set the expiry date of the user account. Date formats are mentioned in /etc/datemsk
The last item is the username.
The /usr/sbin/userdel command can be used to delete users. Example: /usr/sbin/userdel -r fubar The -r optional switch also deletes the user's home directory.