There are some cases when you want to create compressed tar archive but you do not have enough disk space to keep original files and tar archive or you would like to speedup the process or you do not have GNU tar (which support x,z flags for compress the tar). In such case you can use one small trick which will save you some disk space and on the same time will speedup the process because or parallel run of the commands.
Instead of run:
tar czf file.tar.gz files_to_be_archived
you can run it on this way:
tar cf - files_to_be_archived|gzip -c >file.tar.gz
This will avoid creation of temporary intermediate file and run tar and gzip in parallel. Usage of dash (-) is good practice because in UNIX OS absence of name of file archive will send the output of command to real tape device.
You can find the original discussion in Unix StackExchange
Showing posts with label unix. Show all posts
Showing posts with label unix. Show all posts
How to create ZIP archive with relative paths
One question in SE site give me idea how to zip folder w/o including the current directory in the path. Here is the question:
And the answer I found was sample and effective:
The lesson is that people must learn how to use relative directories :)
P.S. Here is the link to the Q/A in SE .
I have a directory calledfolderthat looks like this:
I want to zip this directory intofolder -> root_folder -> some fileszipped_dir..
And the answer I found was sample and effective:
Try to use this command (you will get the idea)
Maybe there is other way, but this is fastest and simplest for me :)cd folder; zip -r ../zipped_dir.zip *
The lesson is that people must learn how to use relative directories :)
P.S. Here is the link to the Q/A in SE .
Sample firewall in AIX
To build firewall under AIX is sample, but as each host based firewall should be done careful
1. Prerequisites
To start firewall in AIX you need few packages to be installed:
- bos.msg.en_US.net.ipsec
- bos.net.ipsec.keymgt
- bos.net.ipsec.rte
- clic.rte.kernext
- clic.rte.lib
2. Start/Stop
to start the firewall its need to execute (as root) the follow command
/usr/sbin/mkdev -c ipsec -t 4
/usr/sbin/mkfilt -v 4 -u -z P
to stop it exec this command
/usr/sbin/rmdev -l ipsec_v4
The above commands are for IPv4. For IPv6 read the manual pages from IBM
3. Write first rule
Let permit ssh access to this machine from everywhere and log entire activity
genfilt -v 4 -a P -s 0.0.0.0 -m 0.0.0.0 -d my_local_IP -M 255.255.255.255 -g Y -c tcp -o any -p 0 -O eq -P 22 -r B -w I -l Y -f Y -i all
But we want to stop all the rest communications
genfilt -v 4 -a D -s 0.0.0.0 -m 0.0.0.0 -d my_local_IP -M 255.255.255.255 -g Y -c tcp -o any -p 0 -O any -P 0 -r B -w I -l N -f Y -i all
and activate the rules
mkfilt -v4 –u
4. Check the activated rule
lsfilt -v 4 -O
1 permit 0.0.0.0 0.0.0.0 0.0.0.0 0.0.0.0 no udp eq 4001 eq 4001 both both no all packets 0 all
2 *** Dynamic filter placement rule for IKE tunnels *** no
3 permit 0.0.0.0 0.0.0.0 my_local_IP 255.255.255.255 yes tcp any 0 eq 22 both both yes all packets 0 all
4 deny 0.0.0.0 0.0.0.0 0.0.0.0 0.0.0.0 yes all any 0 any 0 both both no all packets 0 all </p>
5. Final conclusion
This article is just a sample example how to build the firewall. For more detailed information please consult AIX documentation
1. Prerequisites
To start firewall in AIX you need few packages to be installed:
- bos.msg.en_US.net.ipsec
- bos.net.ipsec.keymgt
- bos.net.ipsec.rte
- clic.rte.kernext
- clic.rte.lib
2. Start/Stop
to start the firewall its need to execute (as root) the follow command
/usr/sbin/mkdev -c ipsec -t 4
/usr/sbin/mkfilt -v 4 -u -z P
to stop it exec this command
/usr/sbin/rmdev -l ipsec_v4
The above commands are for IPv4. For IPv6 read the manual pages from IBM
3. Write first rule
Let permit ssh access to this machine from everywhere and log entire activity
genfilt -v 4 -a P -s 0.0.0.0 -m 0.0.0.0 -d my_local_IP -M 255.255.255.255 -g Y -c tcp -o any -p 0 -O eq -P 22 -r B -w I -l Y -f Y -i all
But we want to stop all the rest communications
genfilt -v 4 -a D -s 0.0.0.0 -m 0.0.0.0 -d my_local_IP -M 255.255.255.255 -g Y -c tcp -o any -p 0 -O any -P 0 -r B -w I -l N -f Y -i all
and activate the rules
mkfilt -v4 –u
4. Check the activated rule
lsfilt -v 4 -O
1 permit 0.0.0.0 0.0.0.0 0.0.0.0 0.0.0.0 no udp eq 4001 eq 4001 both both no all packets 0 all
2 *** Dynamic filter placement rule for IKE tunnels *** no
3 permit 0.0.0.0 0.0.0.0 my_local_IP 255.255.255.255 yes tcp any 0 eq 22 both both yes all packets 0 all
4 deny 0.0.0.0 0.0.0.0 0.0.0.0 0.0.0.0 yes all any 0 any 0 both both no all packets 0 all </p>
5. Final conclusion
This article is just a sample example how to build the firewall. For more detailed information please consult AIX documentation
Audit (Solaris) - something you have, something you do not know - part 1
Audit subsystem in Solaris is very powerful and can give you a lot of information. In this first article I will give you example how to play with audit for monitoring user actions
1. Check the user i want to monitor
# id test1
uid=200(test1) gid=1(other)
2. And the actions I want to record
# cat /etc/security/audit_class
#
.....
# File Format:
#
# mask:name:description
#
0x00000000:no:invalid class
...
0xffffffff:all:all classes (meta-class)
Of course in above file you will see much more classes and you can set to monitor and audit only part of them, but for this example I will use monitoring all
3. Set user and classes
# cat /etc/security/audit_user
#
...
# username:always:never
#
root:lo:no
test1:all:no
So here I will monitor everything and no exceptions
4. Run bsmconv because of first usage of audit
# /etc/security/bsmconv
This script is used to enable the Basic Security Module (BSM).
Shall we continue with the conversion now? [y/n] y
bsmconv: INFO: checking startup file.
bsmconv: INFO: turning on audit module.
bsmconv: INFO: initializing device allocation.
The Basic Security Module is ready.
If there were any errors, please fix them now.
Configure BSM by editing files located in /etc/security.
Reboot this system now to come up with BSM enabled.
5. And reboot
# init 6
updating /platform/i86pc/boot_archive
6. Login as test1 do some actions and exit
login as: test1
Password:
Last login: Sun Sep 26 10:13:00 2010 from 10.1.0.1
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
$ pwd
/export/home/test1
$ ls
$ df -k .
Filesystem kbytes used avail capacity Mounted on
/dev/dsk/c1t0d0s7 248647 1042 222741 1% /export/home
$ /usr/sbin/mkfile 10m aa
$ ls -l
total 20496
-rw------- 1 test1 other 10485760 Sep 26 10:13 aa
$ exit
7. Check the audit file(s)
# cd /var/audit
# ls -l
total 128
-rw------- 1 root root 64370 Sep 26 10:16 20100926081119.20100926081640.sol01
8. Browse the content of this audit file
# praudit 20100926081119.20100926081640.sol01
...
header,134,2,execve(2),,sol01,2010-09-26 10:13:35.371 +02:00
path,/usr/sbin/mkfile
attribute,100555,root,bin,3,853,0
subject,test1,test1,other,test1,other,704,3761557250,9027 71168 10.1.0.1
return,success,0
header,102,2,open(2) - read,fe,sol01,2010-09-26 10:13:35.371 +02:00
path,/var/ld/ld.config
subject,test1,test1,other,test1,other,704,3761557250,9027 71168 10.1.0.1
return,failure: No such file or directory,-1
header,114,2,munmap(2),,sol01,2010-09-26 10:13:35.371 +02:00
argument,1,0xfef8e000,addr
argument,2,0x10000,len
subject,test1,test1,other,test1,other,704,3761557250,9027 71168 10.1.0.1
return,success,0
header,168,2,memcntl(2),,sol01,2010-09-26 10:13:35.371 +02:00
argument,1,0xfee80000,base
argument,2,0x1e4b0,len
argument,3,0x4,cmd
argument,4,0x3,arg
argument,5,0x0,attr
argument,6,0x0,mask
subject,test1,test1,other,test1,other,704,3761557250,9027 71168 10.1.0.1
return,success,0
header,114,2,munmap(2),,sol01,2010-09-26 10:13:35.372 +02:00
argument,1,0xfefb0000,addr
argument,2,0x8000,len
subject,test1,test1,other,test1,other,704,3761557250,9027 71168 10.1.0.1
return,success,0
header,139,2,open(2) - read,write,creat,trunc,,sol01,2010-09-26 10:13:35.386 +02:00
path,/export/home/test1/aa
attribute,100600,test1,other,7,5,0
subject,test1,test1,other,test1,other,704,3761557250,9027 71168 10.1.0.1
return,success,3
header,150,2,close(2),,sol01,2010-09-26 10:13:35.429 +02:00
argument,1,0x3,fd
path,/export/home/test1/aa
attribute,100600,test1,other,7,5,0
subject,test1,test1,other,test1,other,704,3761557250,9027 71168 10.1.0.1
return,success,0
...
As you can see clear here is executed command mkfile and created file, named aa in to the home directory of the user. Of course in above example I use only few of the features in the audit subsystem of Solaris, but in next article will try to present more in deep the options
1. Check the user i want to monitor
# id test1
uid=200(test1) gid=1(other)
2. And the actions I want to record
# cat /etc/security/audit_class
#
.....
# File Format:
#
# mask:name:description
#
0x00000000:no:invalid class
...
0xffffffff:all:all classes (meta-class)
Of course in above file you will see much more classes and you can set to monitor and audit only part of them, but for this example I will use monitoring all
3. Set user and classes
# cat /etc/security/audit_user
#
...
# username:always:never
#
root:lo:no
test1:all:no
So here I will monitor everything and no exceptions
4. Run bsmconv because of first usage of audit
# /etc/security/bsmconv
This script is used to enable the Basic Security Module (BSM).
Shall we continue with the conversion now? [y/n] y
bsmconv: INFO: checking startup file.
bsmconv: INFO: turning on audit module.
bsmconv: INFO: initializing device allocation.
The Basic Security Module is ready.
If there were any errors, please fix them now.
Configure BSM by editing files located in /etc/security.
Reboot this system now to come up with BSM enabled.
5. And reboot
# init 6
updating /platform/i86pc/boot_archive
6. Login as test1 do some actions and exit
login as: test1
Password:
Last login: Sun Sep 26 10:13:00 2010 from 10.1.0.1
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
$ pwd
/export/home/test1
$ ls
$ df -k .
Filesystem kbytes used avail capacity Mounted on
/dev/dsk/c1t0d0s7 248647 1042 222741 1% /export/home
$ /usr/sbin/mkfile 10m aa
$ ls -l
total 20496
-rw------- 1 test1 other 10485760 Sep 26 10:13 aa
$ exit
7. Check the audit file(s)
# cd /var/audit
# ls -l
total 128
-rw------- 1 root root 64370 Sep 26 10:16 20100926081119.20100926081640.sol01
8. Browse the content of this audit file
# praudit 20100926081119.20100926081640.sol01
...
header,134,2,execve(2),,sol01,2010-09-26 10:13:35.371 +02:00
path,/usr/sbin/mkfile
attribute,100555,root,bin,3,853,0
subject,test1,test1,other,test1,other,704,3761557250,9027 71168 10.1.0.1
return,success,0
header,102,2,open(2) - read,fe,sol01,2010-09-26 10:13:35.371 +02:00
path,/var/ld/ld.config
subject,test1,test1,other,test1,other,704,3761557250,9027 71168 10.1.0.1
return,failure: No such file or directory,-1
header,114,2,munmap(2),,sol01,2010-09-26 10:13:35.371 +02:00
argument,1,0xfef8e000,addr
argument,2,0x10000,len
subject,test1,test1,other,test1,other,704,3761557250,9027 71168 10.1.0.1
return,success,0
header,168,2,memcntl(2),,sol01,2010-09-26 10:13:35.371 +02:00
argument,1,0xfee80000,base
argument,2,0x1e4b0,len
argument,3,0x4,cmd
argument,4,0x3,arg
argument,5,0x0,attr
argument,6,0x0,mask
subject,test1,test1,other,test1,other,704,3761557250,9027 71168 10.1.0.1
return,success,0
header,114,2,munmap(2),,sol01,2010-09-26 10:13:35.372 +02:00
argument,1,0xfefb0000,addr
argument,2,0x8000,len
subject,test1,test1,other,test1,other,704,3761557250,9027 71168 10.1.0.1
return,success,0
header,139,2,open(2) - read,write,creat,trunc,,sol01,2010-09-26 10:13:35.386 +02:00
path,/export/home/test1/aa
attribute,100600,test1,other,7,5,0
subject,test1,test1,other,test1,other,704,3761557250,9027 71168 10.1.0.1
return,success,3
header,150,2,close(2),,sol01,2010-09-26 10:13:35.429 +02:00
argument,1,0x3,fd
path,/export/home/test1/aa
attribute,100600,test1,other,7,5,0
subject,test1,test1,other,test1,other,704,3761557250,9027 71168 10.1.0.1
return,success,0
...
As you can see clear here is executed command mkfile and created file, named aa in to the home directory of the user. Of course in above example I use only few of the features in the audit subsystem of Solaris, but in next article will try to present more in deep the options
Play with Solaris project
In this short article I will demonstrate few options of project subsystem in Solaris.
1. Create sample project
# projadd -p 101 -c "my first project" -K "process.max-data-size=(priv,32m,deny)" test1
where 101 is the ID (numeric) of the project
"my first project" is just a comment
test1 is the name of the project
and "process.max-data-size=(priv,32m,deny)" describe attributes. In this example i limit memory data segment to 32 megabytes. The string "priv" is definition who can modify the value and string "deny" define the action when the value is reached.For more info see manual page of resource_controls(5)
2. Check the project
# projects -l
system
projid : 0
comment: ""
users : (none)
groups : (none)
attribs:
...
test1
projid : 101
comment: "my first project"
users : (none)
groups : (none)
attribs: process.max-data-size=(priv,33554432,deny)
3. Test if its work
For this purpose I will use one sample C program to allocate memory and exec it
# newtask -p test1 ./a.out
allocated 2 bytes
allocated 4 bytes
allocated 8 bytes
allocated 16 bytes
allocated 32 bytes
allocated 64 bytes
...
allocated 4194304 bytes
allocated 8388608 bytes
allocated 16777216 bytes
and just in case check exit code :)
# echo $?
1
4. Modify the project to give more memory
projmod -p 101 -K "process.max-data-size=(priv,64m,deny)" test1
5. and check again
# newtask -p test1 ./a.out
allocated 2 bytes
allocated 4 bytes
allocated 8 bytes
allocated 16 bytes
allocated 32 bytes
allocated 64 bytes
...
allocated 4194304 bytes
allocated 8388608 bytes
allocated 16777216 bytes
allocated 33554432 bytes
As you can see all work perfect and we can start using projects in our daily work
1. Create sample project
# projadd -p 101 -c "my first project" -K "process.max-data-size=(priv,32m,deny)" test1
where 101 is the ID (numeric) of the project
"my first project" is just a comment
test1 is the name of the project
and "process.max-data-size=(priv,32m,deny)" describe attributes. In this example i limit memory data segment to 32 megabytes. The string "priv" is definition who can modify the value and string "deny" define the action when the value is reached.For more info see manual page of resource_controls(5)
2. Check the project
# projects -l
system
projid : 0
comment: ""
users : (none)
groups : (none)
attribs:
...
test1
projid : 101
comment: "my first project"
users : (none)
groups : (none)
attribs: process.max-data-size=(priv,33554432,deny)
3. Test if its work
For this purpose I will use one sample C program to allocate memory and exec it
# newtask -p test1 ./a.out
allocated 2 bytes
allocated 4 bytes
allocated 8 bytes
allocated 16 bytes
allocated 32 bytes
allocated 64 bytes
...
allocated 4194304 bytes
allocated 8388608 bytes
allocated 16777216 bytes
and just in case check exit code :)
# echo $?
1
4. Modify the project to give more memory
projmod -p 101 -K "process.max-data-size=(priv,64m,deny)" test1
5. and check again
# newtask -p test1 ./a.out
allocated 2 bytes
allocated 4 bytes
allocated 8 bytes
allocated 16 bytes
allocated 32 bytes
allocated 64 bytes
...
allocated 4194304 bytes
allocated 8388608 bytes
allocated 16777216 bytes
allocated 33554432 bytes
As you can see all work perfect and we can start using projects in our daily work
Implement IPMP on Solaris
Preamble
This document is intended to give fast overview and sample way to implement IPMP on SUN Solaris. IPMP play very important role in SUN strategy to provide high availability in Solaris. Basic idea is to have IP address why “switch” between physical interfaces in case of fail of one of them
Prerequisites
1. To implement IPMP you need to have on the machine 2 NICs with unique MAC addresses2. NICs in IPMP group should have same media type (i.e. Ethernet or ATM for example)
3. NICs should be be connected to the same switch or hub. In case of switch check if they are in same VLAN (if configured)
4. Loaded ip module to the interface
# ifconfig e1000g2 modlist
0 arp
1 ip
2 e1000g
5. If you do not have it execute
# ifconfig e1000g2 modinsert ip
6. Working gateway for IPs used in IPMP group
Setup
1. set in /etc/hostname.e1000g2 and /etc/hostname.e1000g3 the
appropriate parameters for to attach interfaces to the group named test
and set additional IP address
# cat /etc/hostname.e1000g2
sun3-2-1 netmask + broadcast + failover group test up addif sun3-2 netmask + broadcast + -failover deprecated up
# cat /etc/hostname.e1000g3
sun3-2-2 netmask + broadcast + failover group test up
2. activate the interfaces
# ifconfig e1000g2 plumb
# ifconfig e1000g3 plumb
# ifconfig e1000g2 `cat /etc/hostname.e1000g2 `
Setting netmask of e1000g2 to 255.255.255.0
Created new logical interface e1000g2:1
Setting netmask of e1000g2:1 to 255.255.255.0
# ifconfig e1000g3 `cat /etc/hostname.e1000g3 `
Setting netmask of e1000g3 to 255.255.255.0
3. Check what's happen with interfaces and IPs
# ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
e1000g1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet 192.168.1.88 netmask ffffff00 broadcast 192.168.1.255
ether 0:c:29:b2:8f:92
e1000g2: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 12
inet 10.0.1.12 netmask ffffff00 broadcast 10.0.1.255
groupname test
ether 0:c:29:b2:8f:9c
e1000g2:1: flags=9040843<UP,BROADCAST,RUNNING,MULTICAST,DEPRECATED,IPv4,NOFAILOVER> mtu 1500 index 12
inet 10.0.1.32 netmask ffffff00 broadcast 10.0.1.255
e1000g3: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 10
inet 10.0.1.22 netmask ffffff00 broadcast 10.0.1.255
groupname test
ether 0:c:29:b2:8f:b0
Final notes
Of course the above example give just very brief explanation and
sample configuration. For more information take a look on the official Oracle documentations.
Install Solaris from flash archive
Preamble
This document is created to show how to install Solaris OS from flash archive. This process is helpful in case of need to install many similar machines and/or speedup process of implementation of new system with all required software, patches, applications. Other purpose is to prepare fast recovery of important system(s) in DR plan.
Implementation
1. First step is to create repository for flash archive. For this
purpose can be used a local filesystem or NFS share. Be aware that you
need enough disk space to holding the archive.
# mkdir -p /export/flash
2. Next we should create flash archive of the system. This can be
long process depend of amount of data on the system, speed of disks and
processor(s). On average PC system it can take up to 30 minutes (or
more)
# flarcreate -n flash_archive_root -c -R / -x /export/flash /export/flash/inst_x86
Full Flash
Checking integrity...
Integrity OK.
Running precreation scripts...
Precreation scripts done.
Determining the size of the archive...
5359636 blocks
The archive will be approximately 1.46GB.
Creating the archive...
5359636 blocks
Archive creation complete.
Running postcreation scripts...
Postcreation scripts done.
Running pre-exit scripts...
Pre-exit scripts done.
3. Let’s check the archive
# flar -i /export/flash/inst_x86
archive_id=3eb5bd4ed799d662b120834f7f4de81e
files_archived_method=cpio
creation_date=20080831081410
creation_master=sol2
content_name=flash_archive_root
creation_node=sol2
creation_hardware_class=i86pc
creation_platform=i86pc
creation_processor=i386
creation_release=5.10
creation_os_name=SunOS
creation_os_version=Generic_127128-11
files_compressed_method=compress
files_archived_size=1574745535
files_unarchived_size=2744133632
content_architectures=i86pc
4. For the purpose of install it’s need to export via NFS the
directory, so check if NFS server is started and start if not and export
directory
# svcs -va|grep nfs
online - 8:52:09 45 svc:/network/nfs/cbd:default
online - 8:52:09 46 svc:/network/nfs/status:default
online - 8:52:09 47 svc:/network/nfs/mapid:default
online - 8:52:10 49 svc:/network/nfs/nlockmgr:default
online - 8:52:43 - svc:/network/nfs/rquota:default
online - 8:52:43 - svc:/network/nfs/client:default
online - 12:18:20 115 svc:/network/nfs/server:default
# share -o ro /export/flash/
5. Then start new system, follow the installation process and at the
moment of choose installation media select NFS, then enter the location
of archive in form
server:/path/to/directory
and the choose the archive you will use or
server:/path/to/flash/archive
Wait a while and you have freshly installed copy of the system from which we create flash archive
Conclusion
Of course this document show only in brief steps to accomplish the
task and do not go in deep in to the details, but give overview of the
process. For further information about flash archives, installation
process, NFS management, etc. refer to official SUN documentation and
related papers.
How to create package in Solaris
For this example I will be use apache web server, compiled from source and created as package
Create directory structure for package. For me /usr/src sound's good, but you can do it using your home directory
Create in InfoPath directory file pkginfo with content
Configure, compile and install the software on original place
Do some changes to be sure server will work fine
Create in InfoPath directory file, named prototype. To make it by hand is very hard, so we will use tool, named pkgproto executing
Add record to prototype file for creation of /var/adm/httpd directory
Add record to prototype file with information about pkginfo file
Create the package
Let's get little info about this new package
Now in directory /var/spool/pkg we get our package and we can pack it as tar, transfer somewhere and install
Create directory structure for package. For me /usr/src sound's good, but you can do it using your home directory
# cd /usr/src # mkdir RTNapache InfoPath
Create in InfoPath directory file pkginfo with content
ARCH=i386 CATEGORY=application NAME=Apache httpd server PKG=RTNapache VERSION=2.2.4 DESC=The Apache Project is a collaborative software development effort aimed at creating a robust, commercial-grade, featureful, and freely-available source code implementation of an HTTP (Web) server. VENDOR=Apache License Version 2.0, January 2004 http://www.apache.org/licenses/
- ARCH is architecture you build this package. Can be sparc, i386 or ppc - CATEGORY describe with keywords in which category is the package - NAME define brief name of our package - PKG is the name of package. Here is interest the fact 1st 4 letters should be unique - VERSION is the version of package. In this case this is the version of Apache httpd server - DESC is extensive text about the package - VENDOR describe the copyright of the package
Configure, compile and install the software on original place
# ./configure --prefix=/opt/RTNapache --enable-so –enable-mods-shared=most # make # make install # cd /opt/RTNapache/ # mv * /usr/src/RTNapache/ # cd .. # rmdir RTNapache
Do some changes to be sure server will work fine
Change index.html in /usr/src/RTNapache/htdocs to represent the situation with compiled software Change in /usr/src/RTNapache/conf/httpd.conf: - comment ServerAdmin line - set ErrorLog to be /var/adm/httpd because /opt is not the proper place for log files - set CustomLog to be /var/adm/httpd (same reason as above) Change permition of /usr/src/RTNapache/htdocs to be 755 to let user daemon to read web server content Change ownership of /usr/src/RTNapache to be root:root
Create in InfoPath directory file, named prototype. To make it by hand is very hard, so we will use tool, named pkgproto executing
# pkgproto ./RTNapache > InfoFiles/prototype
Add record to prototype file for creation of /var/adm/httpd directory
# echo "d none /var/adm/httpd 0644 root root" >> InfoFiles/prototype
Add record to prototype file with information about pkginfo file
# echo "i pkginfo=/usr/src/InfoFiles/pkginfo" >>InfoFiles/prototype
Create the package
# pkgmk -f InfoFiles/prototype -b /usr/src
Let's get little info about this new package
# cd /var/spool/pkg # pkginfo -d . application RTNapache Apache httpd server
Now in directory /var/spool/pkg we get our package and we can pack it as tar, transfer somewhere and install
Creation of sample zone in Solaris for hosting apache, part 2
For next example let's create another zone, named apache2, but this
time we will use apache server from Solaris and config file from
previous zone
# cp /zones/apache-zone.cfg /zones/apache2-zone.cfg
# zonecfg -z apache2 -f /zones/apache2-zone.cfg
# zoneadm -z apache2 install
# zoneadm -z apache2 boot
# cp /etc/apache2/httpd.conf-example /etc/apache2/httpd.conf
# groupadd w3
# useradd -g w3 w3
mkdir -p /var/run/apache2
# /usr/apache2/bin/apachectl start
# ps -efl|grep http
0 S root 4520 4062 0 50 20 dbbabae0 253 d6860820 09:44:33 pts/2 0:00 grep http
0 S w3 4516 4513 0 40 20 dbbaaa20 1456 d5465384 09:44:23 ? 0:00 /usr/apache2/bin/httpd -k start
0 S root 4513 3924 0 40 20 dbba9100 1421 d5ebbd16 09:44:22 ? 0:00 /usr/apache2/bin/httpd -k start
0 S w3 4517 4513 0 40 20 e8df5ae8 1456 d5465384 09:44:23 ? 0:00 /usr/apache2/bin/httpd -k start
0 S w3 4518 4513 0 40 20 e8df5288 1456 d5465384 09:44:23 ? 0:00 /usr/apache2/bin/httpd -k start
0 S w3 4514 4513 0 40 20 e8df4a28 1456 d5465384 09:44:23 ? 0:00 /usr/apache2/bin/httpd -k start
0 S w3 4515 4513 0 40 20 e8df41c8 1456 d5465384 09:44:23 ? 0:00 /usr/apache2/bin/httpd -k start
# telnet 192.168.30.101 80
Trying 192.168.30.101...
Connected to 192.168.30.101.
Escape character is '^]'.
get
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>501 Method Not Implemented</title>
</head><body>
Method Not Implemented
get to /index.html.en not supported.
<address>Apache/2.0.55 (Unix) DAV/2 Server at 192.168.30.101 Port 80</address>
</body></html>
Connection to 192.168.30.101 closed by foreign host.
and now we have 2 zones and 2 different web servers
# cp /zones/apache-zone.cfg /zones/apache2-zone.cfg
- edit file and change zonepath and IP address
- next will use this config file to initialize new zone
# zonecfg -z apache2 -f /zones/apache2-zone.cfg
# zoneadm -z apache2 install
# zoneadm -z apache2 boot
- add own users w3 with group w3 and create and edit config file. Do not forget to change IP address apache will listen and /etc/hosts for FQDN of host
# cp /etc/apache2/httpd.conf-example /etc/apache2/httpd.conf
# groupadd w3
# useradd -g w3 w3
- create directory /var/run/apache2, because it do not exist, but it's need to keep apache pid file or make some changes in apache config file
mkdir -p /var/run/apache2
- start server and test if it's work
# /usr/apache2/bin/apachectl start
# ps -efl|grep http
0 S root 4520 4062 0 50 20 dbbabae0 253 d6860820 09:44:33 pts/2 0:00 grep http
0 S w3 4516 4513 0 40 20 dbbaaa20 1456 d5465384 09:44:23 ? 0:00 /usr/apache2/bin/httpd -k start
0 S root 4513 3924 0 40 20 dbba9100 1421 d5ebbd16 09:44:22 ? 0:00 /usr/apache2/bin/httpd -k start
0 S w3 4517 4513 0 40 20 e8df5ae8 1456 d5465384 09:44:23 ? 0:00 /usr/apache2/bin/httpd -k start
0 S w3 4518 4513 0 40 20 e8df5288 1456 d5465384 09:44:23 ? 0:00 /usr/apache2/bin/httpd -k start
0 S w3 4514 4513 0 40 20 e8df4a28 1456 d5465384 09:44:23 ? 0:00 /usr/apache2/bin/httpd -k start
0 S w3 4515 4513 0 40 20 e8df41c8 1456 d5465384 09:44:23 ? 0:00 /usr/apache2/bin/httpd -k start
# telnet 192.168.30.101 80
Trying 192.168.30.101...
Connected to 192.168.30.101.
Escape character is '^]'.
get
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>501 Method Not Implemented</title>
</head><body>
Method Not Implemented
get to /index.html.en not supported.
<address>Apache/2.0.55 (Unix) DAV/2 Server at 192.168.30.101 Port 80</address>
</body></html>
Connection to 192.168.30.101 closed by foreign host.
and now we have 2 zones and 2 different web servers
Creation of sample zone in Solaris for hosting apache, part 1
Let's use ZFS for storage of zones to help better disk management
zpool create -f zones c0d1
zfs create zones/apache
mount
/zones on zones read/write/setuid/devices/exec/atime/dev.......
/zones/apache on zones/apache read/write/setuid/devices/exec/atime/dev.......
Change the mode of directory because of need of zone management software
bash-3.00# chmod 700 /zones/apache
Create zone, named apache
bash-3.00# zonecfg -z apache
apache: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:apache> create
zonecfg:apache> set zonepath=/zones/apache
zonecfg:apache> set autoboot=true
zonecfg:apache> add net
zonecfg:apache:net> set address=192.168.30.100/24
zonecfg:apache:net> set physical=pcn0
zonecfg:apache:net> end
zonecfg:apache> add inherit-pkg-dir
zonecfg:apache:inherit-pkg-dir> set dir=/opt
zonecfg:apache:inherit-pkg-dir> end
zonecfg:apache> info
zonepath: /zones/apache
autoboot: true
pool:
inherit-pkg-dir:
dir: /lib
inherit-pkg-dir:
dir: /platform
inherit-pkg-dir:
dir: /sbin
inherit-pkg-dir:
dir: /usr
inherit-pkg-dir:
dir: /opt
net:
address: 192.168.30.100/24
physical: pcn0
zonecfg:apache> commit
zonecfg:apache> export -f /zones/apache-zone.cfg
zonecfg:apache> exit
Now let's install the software in zone (this operation will take a while)
bash-3.00# zoneadm -z apache install
Preparing to install zone <apache>.
Creating list of files to copy from the global zone.
Copying <2361> files to the zone.
Initializing zone product registry.
Determining zone package initialization order.
Preparing to initialize <968> packages on the zone.
Initializing package <372> of <968>: percent complete: 38%......
Little check of situation
bash-3.00# df -k /zones/apache/
Filesystem kbytes used avail capacity Mounted on
zones/apache 12321792 70034 12251635 1% /zones/apache
bash-3.00# zoneadm list -v
ID NAME STATUS PATH
0 global running /
bash-3.00# zoneadm -z apache boot
bash-3.00# zoneadm list -v
ID NAME STATUS PATH
0 global running /
2 apache running /zones/apache
Some preparation tasks
bash-3.00# zlogin apache
[Connected to zone 'apache' pts/2]
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
# mkdir -p /www/src
bash-3.00# cd /zones/apache/root/www/src/
bash-3.00# cp /tmp/httpd-2.2.4.tar.gz .
# cd /www/src
# gzip -d httpd-2.2.4.tar.gz|tar
# tar xvf httpd-2.2.4.tar
# cd httpd-2.2.4
# ./configure --prefix=/www --enable-so –enable-mods-shared=all
<cut long listing>
# make
<cut long listing>
# make test
`test' is up to date.
# make install
<cut long listing>
# groupadd w3
# useradd -g w3 w3
# chown -R w3:w3 /www/htdocs
192.168.30.100 apache.example.net apache
let's run the http server
# /www/bin/apachectl start
check if the server is running
# ps -efl|grep htt
0 S w3 22380 22377 0 40 20 d39c2008 1136 d54cfd5c 01:24:41 ? 0:00 /www/bin/httpd -k start
0 S w3 22381 22377 0 40 20 d4e80940 1136 d54cfd5c 01:24:41 ? 0:00 /www/bin/httpd -k start
0 S w3 22378 22377 0 40 20 d4e73270 1136 d54cfd5c 01:24:41 ? 0:00 /www/bin/httpd -k start
0 S w3 22379 22377 0 40 20 d4e70890 1136 d54cfd5c 01:24:41 ? 0:00 /www/bin/httpd -k start
0 S root 22377 5541 0 40 20 d4e70030 1103 d49abb16 01:24:40 ? 0:00 /www/bin/httpd -k start
0 S root 22384 15053 1 50 20 d5182a18 253 d6880300 01:25:21 pts/2 0:00 grep htt
0 S w3 22382 22377 0 40 20 d5181958 1136 d54cfd5c 01:24:41 ? 0:00 /www/bin/httpd -k start
# telnet 192.168.30.100 80
Trying 192.168.30.100...
Connected to 192.168.30.100.
Escape character is '^]'.
GET
<html><body>
It works!
</body></html>
Connection to 192.168.30.100 closed by foreign host.
So our apache is running and working :-)
zpool create -f zones c0d1
zfs create zones/apache
mount
/zones on zones read/write/setuid/devices/exec/atime/dev.......
/zones/apache on zones/apache read/write/setuid/devices/exec/atime/dev.......
Change the mode of directory because of need of zone management software
bash-3.00# chmod 700 /zones/apache
Create zone, named apache
bash-3.00# zonecfg -z apache
apache: No such zone configured
Use 'create' to begin configuring a new zone.
- we start with initial creation of zone
zonecfg:apache> create
- set the path where zone will reside
zonecfg:apache> set zonepath=/zones/apache
- set autoboot flag to boot when server boot
zonecfg:apache> set autoboot=true
- add network IP and physical interface. Do not forget to set netmask
zonecfg:apache> add net
zonecfg:apache:net> set address=192.168.30.100/24
zonecfg:apache:net> set physical=pcn0
zonecfg:apache:net> end
- add external directory /opt to be part of zone (just in case)
zonecfg:apache> add inherit-pkg-dir
zonecfg:apache:inherit-pkg-dir> set dir=/opt
zonecfg:apache:inherit-pkg-dir> end
- get the config info about the zone (on screen)
zonecfg:apache> info
zonepath: /zones/apache
autoboot: true
pool:
inherit-pkg-dir:
dir: /lib
inherit-pkg-dir:
dir: /platform
inherit-pkg-dir:
dir: /sbin
inherit-pkg-dir:
dir: /usr
inherit-pkg-dir:
dir: /opt
net:
address: 192.168.30.100/24
physical: pcn0
- commit all the changes we made
zonecfg:apache> commit
- export the config for future usage or just for backup. Do not put it in /tmp, because on each boot this filesystem is purged
zonecfg:apache> export -f /zones/apache-zone.cfg
- and exit from the program
zonecfg:apache> exit
Now let's install the software in zone (this operation will take a while)
bash-3.00# zoneadm -z apache install
Preparing to install zone <apache>.
Creating list of files to copy from the global zone.
Copying <2361> files to the zone.
Initializing zone product registry.
Determining zone package initialization order.
Preparing to initialize <968> packages on the zone.
Initializing package <372> of <968>: percent complete: 38%......
Little check of situation
- diskspace
bash-3.00# df -k /zones/apache/
Filesystem kbytes used avail capacity Mounted on
zones/apache 12321792 70034 12251635 1% /zones/apache
- status of zones
bash-3.00# zoneadm list -v
ID NAME STATUS PATH
0 global running /
- boot our new zone
bash-3.00# zoneadm -z apache boot
- and check again zones status
bash-3.00# zoneadm list -v
ID NAME STATUS PATH
0 global running /
2 apache running /zones/apache
Some preparation tasks
- login in to the zone
bash-3.00# zlogin apache
[Connected to zone 'apache' pts/2]
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
- create some directories where we will place web server (we aware directories /lib, /opt, /platform, /sbin and /usr are mounted from global zone as readonly, but / (root) not so we put there our apache)
# mkdir -p /www/src
- copy the software (from other terminal :-)
bash-3.00# cd /zones/apache/root/www/src/
bash-3.00# cp /tmp/httpd-2.2.4.tar.gz .
- decompress and untar the archive (from with in zone)
# cd /www/src
# gzip -d httpd-2.2.4.tar.gz|tar
# tar xvf httpd-2.2.4.tar
- * configure and compile the software (its take a while)
# cd httpd-2.2.4
# ./configure --prefix=/www --enable-so –enable-mods-shared=all
<cut long listing>
# make
<cut long listing>
# make test
`test' is up to date.
# make install
<cut long listing>
- create user to manage files
# groupadd w3
# useradd -g w3 w3
# chown -R w3:w3 /www/htdocs
- edit /www/conf/httpd.conf to change User and Group from daemon to w3
- edit /etc/hosts to add line like this
192.168.30.100 apache.example.net apache
let's run the http server
# /www/bin/apachectl start
check if the server is running
- check process
# ps -efl|grep htt
0 S w3 22380 22377 0 40 20 d39c2008 1136 d54cfd5c 01:24:41 ? 0:00 /www/bin/httpd -k start
0 S w3 22381 22377 0 40 20 d4e80940 1136 d54cfd5c 01:24:41 ? 0:00 /www/bin/httpd -k start
0 S w3 22378 22377 0 40 20 d4e73270 1136 d54cfd5c 01:24:41 ? 0:00 /www/bin/httpd -k start
0 S w3 22379 22377 0 40 20 d4e70890 1136 d54cfd5c 01:24:41 ? 0:00 /www/bin/httpd -k start
0 S root 22377 5541 0 40 20 d4e70030 1103 d49abb16 01:24:40 ? 0:00 /www/bin/httpd -k start
0 S root 22384 15053 1 50 20 d5182a18 253 d6880300 01:25:21 pts/2 0:00 grep htt
0 S w3 22382 22377 0 40 20 d5181958 1136 d54cfd5c 01:24:41 ? 0:00 /www/bin/httpd -k start
- check service
# telnet 192.168.30.100 80
Trying 192.168.30.100...
Connected to 192.168.30.100.
Escape character is '^]'.
GET
<html><body>
It works!
</body></html>
Connection to 192.168.30.100 closed by foreign host.
So our apache is running and working :-)
Getting started using Solaris part 3
Examples
Let's login in to the system:
$ ssh root@192.168.8.128
Password:
Last login: Mon Mar 31 11:39:29 2008 Sun Microsystems Inc. SunOS 5.11 snv_70b October 2007
#
Next will be interest to check the user we are:
# id
uid=0(root) gid=0(root)
See where we are (path)
# pwd
/
Check the values of some variables
# echo $PATH "\n" $TERM
/usr/sbin:/usr/bin
cygwin
set the value of variable TERM
# TERM=vt100;export TERM
List the content of current directory
# ls -l
total 346
lrwxrwxrwx 1 root root 9 Nov 1 12:20 bin -> ./usr/bin
drwxr-xr-x 6 root sys 512 Nov 1 13:00 boot
drwxr-xr-x 2 root root 512 Nov 6 11:07 cdrom
drwxr-xr-x 67 root sys 4096 Nov 1 13:31 dev
drwxr-xr-x 2 root sys 512 Mar 31 11:38 devices
drwxr-xr-x 91 root sys 4608 Mar 31 11:40 etc
<SNIP>
drwxr-xr-x 4 root root 512 Nov 1 12:20 system
drwxrwxrwt 6 root sys 299 Mar 31 11:39 tmp
drwxr-xr-x 38 root sys 1024 Nov 1 13:07 usr
drwxr-xr-x 44 root sys 1024 Nov 5 14:35 var
go to directory using absolute path and the relative path
# cd /var/adm
# cd ../tmp
# pwd
/var/tmp
examine the content of file
# cat /etc/nsswitch.conf
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
<SNIP>
passwd: files
group: files
hosts: files
dns # Added by DHCP
ipnodes: files
networks: files
protocols: files
netmasks: files
bootparams: files
Let see the IP settings
# ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
e1000g0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet 10.0.2.10 netmask ffffff00 broadcast 10.0.2.255
ether 8:0:27:13:f7:38
and routing table
# netstat -rn
Routing Table: IPv4
Destination Gateway Flags Ref Use Interface
-------------------- -------------------- ----- ----- ---------- ---------
default 10.0.2.2 UG 1 0
10.0.2.0 10.0.2.10 U 1 0 e1000g0
224.0.0.0 10.0.2.10 U 1 0 e1000g0
127.0.0.1 127.0.0.1 UH 1 40 lo0
Get the list of opened ports
# netstat -a |grep LISTEN
*.sunrpc *.* 0 0 49152 0 LISTEN
*.ssh *.* 0 0 49152 0 LISTEN
<SNIP>
localhost.32807 *.* 0 0 49152 0 LISTEN
localhost.32808 *.* 0 0 49152 0 LISTEN
localhost.32809 *.* 0 0 49152 0 LISTEN
localhost.32810 *.* 0 0 49152 0 LISTEN
*.ssh *.* 0 0 49152 0 LISTEN
*.32794 *.* 0 0 49152 0 LISTEN
stop the sendmail (because we will not use this server for this purpose)
# svcadm disable sendmail
and check again for daemon listening on port 25
# netstat -an|grep 25|grep tcp
#
Conclusion
Above you see only very brief overview of the functions, commands and details of Solaris operating system. If you need more indeep knowledge go to SUN doc site Solaris 10 Operating System, search for information, spread in Internet. check and apply for courses in your area, play with x86 version, using virtual machine, ask questions.
Let's login in to the system:
$ ssh root@192.168.8.128
Password:
Last login: Mon Mar 31 11:39:29 2008 Sun Microsystems Inc. SunOS 5.11 snv_70b October 2007
#
Next will be interest to check the user we are:
# id
uid=0(root) gid=0(root)
See where we are (path)
# pwd
/
Check the values of some variables
# echo $PATH "\n" $TERM
/usr/sbin:/usr/bin
cygwin
set the value of variable TERM
# TERM=vt100;export TERM
List the content of current directory
# ls -l
total 346
lrwxrwxrwx 1 root root 9 Nov 1 12:20 bin -> ./usr/bin
drwxr-xr-x 6 root sys 512 Nov 1 13:00 boot
drwxr-xr-x 2 root root 512 Nov 6 11:07 cdrom
drwxr-xr-x 67 root sys 4096 Nov 1 13:31 dev
drwxr-xr-x 2 root sys 512 Mar 31 11:38 devices
drwxr-xr-x 91 root sys 4608 Mar 31 11:40 etc
<SNIP>
drwxr-xr-x 4 root root 512 Nov 1 12:20 system
drwxrwxrwt 6 root sys 299 Mar 31 11:39 tmp
drwxr-xr-x 38 root sys 1024 Nov 1 13:07 usr
drwxr-xr-x 44 root sys 1024 Nov 5 14:35 var
go to directory using absolute path and the relative path
# cd /var/adm
# cd ../tmp
# pwd
/var/tmp
examine the content of file
# cat /etc/nsswitch.conf
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
<SNIP>
passwd: files
group: files
hosts: files
dns # Added by DHCP
ipnodes: files
networks: files
protocols: files
netmasks: files
bootparams: files
Let see the IP settings
# ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
e1000g0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet 10.0.2.10 netmask ffffff00 broadcast 10.0.2.255
ether 8:0:27:13:f7:38
and routing table
# netstat -rn
Routing Table: IPv4
Destination Gateway Flags Ref Use Interface
-------------------- -------------------- ----- ----- ---------- ---------
default 10.0.2.2 UG 1 0
10.0.2.0 10.0.2.10 U 1 0 e1000g0
224.0.0.0 10.0.2.10 U 1 0 e1000g0
127.0.0.1 127.0.0.1 UH 1 40 lo0
Get the list of opened ports
# netstat -a |grep LISTEN
*.sunrpc *.* 0 0 49152 0 LISTEN
*.ssh *.* 0 0 49152 0 LISTEN
<SNIP>
localhost.32807 *.* 0 0 49152 0 LISTEN
localhost.32808 *.* 0 0 49152 0 LISTEN
localhost.32809 *.* 0 0 49152 0 LISTEN
localhost.32810 *.* 0 0 49152 0 LISTEN
*.ssh *.* 0 0 49152 0 LISTEN
*.32794 *.* 0 0 49152 0 LISTEN
stop the sendmail (because we will not use this server for this purpose)
# svcadm disable sendmail
and check again for daemon listening on port 25
# netstat -an|grep 25|grep tcp
#
Conclusion
Above you see only very brief overview of the functions, commands and details of Solaris operating system. If you need more indeep knowledge go to SUN doc site Solaris 10 Operating System, search for information, spread in Internet. check and apply for courses in your area, play with x86 version, using virtual machine, ask questions.
Getting started using Solaris part 2
First steps
As first step you should become familiar with some command, used to work with Solaris OS
Command man is your first friend. Do not be shame to use it (I personally use this command at least few times each day). Exit the command by pressing key q
man man - will give you details about the command (man in this case)
man -s 5 some_command - search for information in section 5
man -M /some/hidden/place command - search for information about the command adding directory not mentioned in MANPATH environment variable
Here and below use man command to get full list of keys, features, etc. of the command
Command ls help you list the content of directory
ls -l - show long listing including size, rights, etc
ls -a - show hidden files (which name start with . (dot)
ls -r - show listing in reverse order
ls -t - show listing, sorted by time
Command cd help you navigate through the directories
cd - go to your home directory
cd / - go to the root directory
cd .. - go to one directory up
cd test - go to subdirectory test (relative to current directory)
cd /var/tmp - go to directory /var/tmp (absolute path)
cd - - go to previous direcory (before last cd command, symbol after cd is dash)
Command file help you identify the type of file
Command more paginate file showing one page at the time on the screen
Command cat display the content of the to the standard output
Command tail show you the tail of the file (few last lines), with key f can get and display the new lines, appended to the file
Command vi is text editor
Command mkdir create new directory
Command rm remove file or directory
Command mv is used to move or rename file or directory
As first step you should become familiar with some command, used to work with Solaris OS
Command man is your first friend. Do not be shame to use it (I personally use this command at least few times each day). Exit the command by pressing key q
man man - will give you details about the command (man in this case)
man -s 5 some_command - search for information in section 5
man -M /some/hidden/place command - search for information about the command adding directory not mentioned in MANPATH environment variable
Here and below use man command to get full list of keys, features, etc. of the command
Command ls help you list the content of directory
ls -l - show long listing including size, rights, etc
ls -a - show hidden files (which name start with . (dot)
ls -r - show listing in reverse order
ls -t - show listing, sorted by time
Command cd help you navigate through the directories
cd - go to your home directory
cd / - go to the root directory
cd .. - go to one directory up
cd test - go to subdirectory test (relative to current directory)
cd /var/tmp - go to directory /var/tmp (absolute path)
cd - - go to previous direcory (before last cd command, symbol after cd is dash)
Command file help you identify the type of file
Command more paginate file showing one page at the time on the screen
Command cat display the content of the to the standard output
Command tail show you the tail of the file (few last lines), with key f can get and display the new lines, appended to the file
Command vi is text editor
Command mkdir create new directory
Command rm remove file or directory
Command mv is used to move or rename file or directory
Getting started using Solaris part 1
Introduction
Solaris is a UNIX flavor like AIX, HP-UX, IRIX and many more. It's based on SYSV architecture. This OS can be run on 2 different processors: SPARC and x86 (32 or 64 bits). The OS itself can be downloaded as ISO image (CD's or DVD) for SPARC or x86 platform from Oracle site: Solaris 10 Solaris 11 and can be used for free (for noncommercial) with some limitations.
For fans of FOSS exist variant, named OpenSolaris, which include most of the features of Solaris, but have excluded the copyrighted materials and code.
Installation
1. Get in mind you can use only command line, Bourne shell and vi. (Actually this should be step with number zero, but wiki format do not enable it ;-)
2. Before use of OS you should install it. For this purpose you need SPARC or x86 machine, CD's or DVD and some time. Currently you can use also visualization software. If you do not want to be badly surprised please check the Hardware Compatibility List (HCL)
3.Installation process is in generally smooth and easy, but you should get some decisions:
- Core System Support - minimal installation, but to do some work you need to install additional software: Practical guide for minimalistic Solaris installation
- End User Solaris - all from above group plus Common Desktop Environment
- Developer Solaris - all from above group plus libraries, include files, man pages, and programming tools, need for software development support, but without compiler(s)
- Entire Solaris - all from above group plus additional network services
- Entire Solaris Software Group Plus OEM Support - all from above group plus additional hardware drivers
Of course you can install software after finish of the installation process, but sometime dependencies requirements in Solaris can be nightmare for newbies
- IP address of the machine (static or acquired via DHCP)
- network mask
- default gateway
- name service: NIS, NIS+, LDAP, DNS or none
be aware when you set anything different from none you should have network access to the service and service up and running, otherwise you should wait a lot in process of installation
- hostname of server
- usage of kerberos
- default gateway
- locales you need/want to install
And at the end do the installation itself :-)
For more detailed instructions for the installation process please consult Solaris Installation Guide
Solaris is a UNIX flavor like AIX, HP-UX, IRIX and many more. It's based on SYSV architecture. This OS can be run on 2 different processors: SPARC and x86 (32 or 64 bits). The OS itself can be downloaded as ISO image (CD's or DVD) for SPARC or x86 platform from Oracle site: Solaris 10 Solaris 11 and can be used for free (for noncommercial) with some limitations.
For fans of FOSS exist variant, named OpenSolaris, which include most of the features of Solaris, but have excluded the copyrighted materials and code.
Installation
1. Get in mind you can use only command line, Bourne shell and vi. (Actually this should be step with number zero, but wiki format do not enable it ;-)
2. Before use of OS you should install it. For this purpose you need SPARC or x86 machine, CD's or DVD and some time. Currently you can use also visualization software. If you do not want to be badly surprised please check the Hardware Compatibility List (HCL)
3.Installation process is in generally smooth and easy, but you should get some decisions:
- How to split the existing disk(s), how big should be filesystems, etc. For starting point and some suggestions read SUN documentations and/or this document: Suggestions and ideas about filesystem sizing on Solaris
- Prepare self for installation process i.e. if you have less that 512 MB of memory process will be in text mode, otherwise will try to start in graphical mode. The both methods are similar, excluding the fact in graphical mode you can open new terminal and make some checks, etc. In text mode you have only one screen.
- Decide what software group you will install, additional software, etc. For Solaris 10 you can choose from next software groups:
- Core System Support - minimal installation, but to do some work you need to install additional software: Practical guide for minimalistic Solaris installation
- End User Solaris - all from above group plus Common Desktop Environment
- Developer Solaris - all from above group plus libraries, include files, man pages, and programming tools, need for software development support, but without compiler(s)
- Entire Solaris - all from above group plus additional network services
- Entire Solaris Software Group Plus OEM Support - all from above group plus additional hardware drivers
Of course you can install software after finish of the installation process, but sometime dependencies requirements in Solaris can be nightmare for newbies
- Next step is to collect information about the network settings
- IP address of the machine (static or acquired via DHCP)
- network mask
- default gateway
- name service: NIS, NIS+, LDAP, DNS or none
be aware when you set anything different from none you should have network access to the service and service up and running, otherwise you should wait a lot in process of installation
- hostname of server
- usage of kerberos
- default gateway
- Then you should get information about
- locales you need/want to install
And at the end do the installation itself :-)
For more detailed instructions for the installation process please consult Solaris Installation Guide
Solaris commands for process management - truss
truss – for tracing user/library/system calls and signals
bash-3.2# truss ls
execve("/usr/bin/ls", 0x0804759C, 0x080475A4) argc = 1
sysinfo(SI_MACHINE, "i86pc", 257) = 6
mmap(0x00000000, 32, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANON, -1, 0) = 0xFEFF0000
mmap(0x00000000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0) = 0xFEFB0000
mmap(0x00000000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0) = 0xFEFA0000
memcntl(0xFEFBE000, 13408, MC_ADVISE, MADV_WILLNEED, 0, 0) = 0
memcntl(0x08050000, 3784, MC_ADVISE, MADV_WILLNEED, 0, 0) = 0
resolvepath("/usr/lib/ld.so.1", "/lib/ld.so.1", 1023) = 12
resolvepath("/usr/bin/ls", "/usr/bin/ls", 1023) = 11
sysconfig(_CONFIG_PAGESIZE) = 4096
stat64("/usr/bin/ls", 0x08047180) = 0
open("/var/ld/ld.config", O_RDONLY) Err#2 ENOENT
stat64("/lib/libsec.so.1", 0x08046A30) = 0
resolvepath("/lib/libsec.so.1", "/lib/libsec.so.1", 1023) = 16
open("/lib/libsec.so.1", O_RDONLY) = 3
Shows you system calls made by a process along with parameters of the function - very good for program execution traces. Use -u a.out to see user-level function calls. Note "a.out" is typed literally as "a.out" - not replaced with the name of the program
bash-3.2# truss ls
execve("/usr/bin/ls", 0x0804759C, 0x080475A4) argc = 1
sysinfo(SI_MACHINE, "i86pc", 257) = 6
mmap(0x00000000, 32, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANON, -1, 0) = 0xFEFF0000
mmap(0x00000000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0) = 0xFEFB0000
mmap(0x00000000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0) = 0xFEFA0000
memcntl(0xFEFBE000, 13408, MC_ADVISE, MADV_WILLNEED, 0, 0) = 0
memcntl(0x08050000, 3784, MC_ADVISE, MADV_WILLNEED, 0, 0) = 0
resolvepath("/usr/lib/ld.so.1", "/lib/ld.so.1", 1023) = 12
resolvepath("/usr/bin/ls", "/usr/bin/ls", 1023) = 11
sysconfig(_CONFIG_PAGESIZE) = 4096
stat64("/usr/bin/ls", 0x08047180) = 0
open("/var/ld/ld.config", O_RDONLY) Err#2 ENOENT
stat64("/lib/libsec.so.1", 0x08046A30) = 0
resolvepath("/lib/libsec.so.1", "/lib/libsec.so.1", 1023) = 16
open("/lib/libsec.so.1", O_RDONLY) = 3
Shows you system calls made by a process along with parameters of the function - very good for program execution traces. Use -u a.out to see user-level function calls. Note "a.out" is typed literally as "a.out" - not replaced with the name of the program
Solaris commands for process management - pwdx
pwdx – list working directory for process, like pwd command
bash-3.2# pwdx 867
867: /var/spool/clientmqueue
Can be helpful in case of strange errors when unmount some filesystem
bash-3.2# pwdx 867
867: /var/spool/clientmqueue
Can be helpful in case of strange errors when unmount some filesystem
Solaris commands for process management - pwait
pwait – wait till process finish
# ps -efl|grep name 0 S root 875 1 0 45 20 d4188950 1298 d553ab16 22:17:58 ? 0:00 /usr/sbin/named # pwait 875 (in this moment from another terminal I execute svcadm disable dns/server)
Maybe this command will be great in some specific scripts
# ps -efl|grep name 0 S root 875 1 0 45 20 d4188950 1298 d553ab16 22:17:58 ? 0:00 /usr/sbin/named # pwait 875 (in this moment from another terminal I execute svcadm disable dns/server)
Maybe this command will be great in some specific scripts
Solaris commands for process management - ptree
ptree - print the tree of processes
No need for comments :-)
bash-3.2# ptree
11 /lib/svc/bin/svc.startd
343 /usr/lib/saf/sac -t 300
356 /usr/lib/saf/ttymon
362 /usr/lib/saf/ttymon -g -d /dev/console -l console -T sun-color -m ldterm,ttcomp
13 /lib/svc/bin/svc.configd
74 devfsadmd
128 /usr/lib/sysevent/syseventd
129 /usr/lib/crypto/kcfd
150 /usr/lib/power/powerd
155 /usr/lib/picl/picld
214 /lib/svc/method/iscsi-initiator
230 /usr/sbin/cron
281 /usr/bin/VBoxService
304 /usr/sbin/rpcbind
308 /usr/lib/autofs/automountd
309 /usr/lib/autofs/automountd
340 /usr/lib/inet/inetd start
355 /usr/lib/utmpd
363 /usr/lib/fm/fmd/fmd
375 /usr/lib/ssh/sshd
405 /usr/sbin/syslogd
421 /usr/sadm/lib/smc/bin/smcboot
424 /usr/sadm/lib/smc/bin/smcboot
425 /usr/sadm/lib/smc/bin/smcboot
493 /usr/dt/bin/dtlogin -daemon -udpPort 0
494 /usr/openwin/bin/fbconsole -n -d :0
502 /usr/X11/bin/Xorg :0 -depth 24 -nolisten tcp -nobanner -auth /var/dt/A:0-iUaO9a
564 /usr/dt/bin/dtlogin -daemon -udpPort 0
623 /bin/ksh /usr/dt/bin/Xsession
707 /usr/dt/bin/sdt_shell -c unset DT; DISPLAY=:0; /usr/dt/bin/dt
709 -sh -c unset DT; DISPLAY=:0; /usr/dt/bin/dtsession_res -mer
721 /bin/ksh /usr/dt/config/Xsession2.jds
723 /usr/bin/gnome-session
<snip>
No need for comments :-)
bash-3.2# ptree
11 /lib/svc/bin/svc.startd
343 /usr/lib/saf/sac -t 300
356 /usr/lib/saf/ttymon
362 /usr/lib/saf/ttymon -g -d /dev/console -l console -T sun-color -m ldterm,ttcomp
13 /lib/svc/bin/svc.configd
74 devfsadmd
128 /usr/lib/sysevent/syseventd
129 /usr/lib/crypto/kcfd
150 /usr/lib/power/powerd
155 /usr/lib/picl/picld
214 /lib/svc/method/iscsi-initiator
230 /usr/sbin/cron
281 /usr/bin/VBoxService
304 /usr/sbin/rpcbind
308 /usr/lib/autofs/automountd
309 /usr/lib/autofs/automountd
340 /usr/lib/inet/inetd start
355 /usr/lib/utmpd
363 /usr/lib/fm/fmd/fmd
375 /usr/lib/ssh/sshd
405 /usr/sbin/syslogd
421 /usr/sadm/lib/smc/bin/smcboot
424 /usr/sadm/lib/smc/bin/smcboot
425 /usr/sadm/lib/smc/bin/smcboot
493 /usr/dt/bin/dtlogin -daemon -udpPort 0
494 /usr/openwin/bin/fbconsole -n -d :0
502 /usr/X11/bin/Xorg :0 -depth 24 -nolisten tcp -nobanner -auth /var/dt/A:0-iUaO9a
564 /usr/dt/bin/dtlogin -daemon -udpPort 0
623 /bin/ksh /usr/dt/bin/Xsession
707 /usr/dt/bin/sdt_shell -c unset DT; DISPLAY=:0; /usr/dt/bin/dt
709 -sh -c unset DT; DISPLAY=:0; /usr/dt/bin/dtsession_res -mer
721 /bin/ksh /usr/dt/config/Xsession2.jds
723 /usr/bin/gnome-session
<snip>
Solaris commands for process management - pstop
pstop – temporary hold process
# ps -efl|grep ssh
0 S root 554 356 0 40 20 d419b870 1800 d4c87e72 21:03:52 ? 0:00 /usr/lib/ssh/sshd
0 S root 356 1 0 40 20 d4195320 834 d49f3432 21:02:46 ? 0:00 /usr/lib/ssh/sshd
0 S root 560 554 0 40 20 d41931a0 1747 d4c87ab2 21:05:03 ? 0:02 /usr/lib/ssh/sshd
0 S root 812 809 0 40 20 d418a270 1746 d50402f2 22:09:00 ? 0:00 /usr/lib/ssh/sshd
0 S root 809 356 0 40 20 d4189a10 1801 d4c874f2 22:08:47 ? 0:00 /usr/lib/ssh/sshd
# pstop 356
# ssh localhost (here I stop with ctrl-C ssh client after 5 minutes of waiting)
# prun 356
# ssh localhost
The authenticity of host 'localhost (127.0.0.1)' can't be established. RSA key fingerprint is da:14:db:bc:2f:e0:0f:ef:f6:3f:12:0e:f4:77:0c:00. Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (RSA) to the list of known hosts.
Password:
Last login: Wed Jun 13 22:09:00 2007 from gateway Sun Microsystems Inc. SunOS 5.10 Generic January 2005
# ps -efl|grep ssh
0 S root 554 356 0 40 20 d419b870 1800 d4c87e72 21:03:52 ? 0:00 /usr/lib/ssh/sshd
0 S root 356 1 0 40 20 d4195320 834 d49f3432 21:02:46 ? 0:00 /usr/lib/ssh/sshd
0 S root 560 554 0 40 20 d41931a0 1747 d4c87ab2 21:05:03 ? 0:02 /usr/lib/ssh/sshd
0 S root 812 809 0 40 20 d418a270 1746 d50402f2 22:09:00 ? 0:00 /usr/lib/ssh/sshd
0 S root 809 356 0 40 20 d4189a10 1801 d4c874f2 22:08:47 ? 0:00 /usr/lib/ssh/sshd
# pstop 356
# ssh localhost (here I stop with ctrl-C ssh client after 5 minutes of waiting)
# prun 356
# ssh localhost
The authenticity of host 'localhost (127.0.0.1)' can't be established. RSA key fingerprint is da:14:db:bc:2f:e0:0f:ef:f6:3f:12:0e:f4:77:0c:00. Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (RSA) to the list of known hosts.
Password:
Last login: Wed Jun 13 22:09:00 2007 from gateway Sun Microsystems Inc. SunOS 5.10 Generic January 2005
Solaris commands for process management - psig
psig – list signals that can be handled by process
bash-3.2# psig 867
867: /usr/lib/sendmail -Ac -q15m
HUP caught 0x809b340 RESTART,SIGINFO
INT ignored
QUIT ignored
ILL default
TRAP default
ABRT default
EMT default
FPE default
KILL default
BUS default
SEGV default
SYS default
PIPE ignored
ALRM caught sm_tick RESTART,SIGINFO
TERM caught 0x809b2af RESTART,SIGINFO
USR1 caught 0x8081a32 RESTART,SIGINFO
USR2 default
CLD caught reapchild RESTART,SIGINFO
<snip>
bash-3.2# psig 867
867: /usr/lib/sendmail -Ac -q15m
HUP caught 0x809b340 RESTART,SIGINFO
INT ignored
QUIT ignored
ILL default
TRAP default
ABRT default
EMT default
FPE default
KILL default
BUS default
SEGV default
SYS default
PIPE ignored
ALRM caught sm_tick RESTART,SIGINFO
TERM caught 0x809b2af RESTART,SIGINFO
USR1 caught 0x8081a32 RESTART,SIGINFO
USR2 default
CLD caught reapchild RESTART,SIGINFO
<snip>
Solaris commands for process management - pstack
pstack – get backtrace stack of process for debugging purposes
bash-3.2# pstack 706
706: /usr/dt/bin/dsdm
fedcc3e5 pollsys (8046b60, 1, 0, 0)
fed7559a pselect (4, 8046c00, fee323d8, fee323d8, 0, 0) + 18e
fed75890 select (4, 8046c00, 0, 0, 0) + 82
fee5ab6b _XWaitForReadable (80651d0) + cf
fee5a991 _XRead (80651d0, 8046cf0, 20) + a9
fee89811 _XReadEvents (80651d0) + 1e9
fee65b12 XNextEvent (80651d0, 80475a0) + 46
08052976 main (1, 80476a0, 80476a8) + 1cc
080517fa ???????? (1, 80477b0, 0, 80477c1, 80477d4, 8047808)
This command can sometimes be very helpful for debugging daemons. You can see the function call stack by thread, in real-time
bash-3.2# pstack 706
706: /usr/dt/bin/dsdm
fedcc3e5 pollsys (8046b60, 1, 0, 0)
fed7559a pselect (4, 8046c00, fee323d8, fee323d8, 0, 0) + 18e
fed75890 select (4, 8046c00, 0, 0, 0) + 82
fee5ab6b _XWaitForReadable (80651d0) + cf
fee5a991 _XRead (80651d0, 8046cf0, 20) + a9
fee89811 _XReadEvents (80651d0) + 1e9
fee65b12 XNextEvent (80651d0, 80475a0) + 46
08052976 main (1, 80476a0, 80476a8) + 1cc
080517fa ???????? (1, 80477b0, 0, 80477c1, 80477d4, 8047808)
This command can sometimes be very helpful for debugging daemons. You can see the function call stack by thread, in real-time
Subscribe to:
Posts (Atom)
Should I trust AI
Should I trust AI? So far no, sorry. I tested for the moment (May, 2025) most advanced model for programming and ask very simple question:...
-
There are some cases when you want to create compressed tar archive but you do not have enough disk space to keep original files and tar arc...
-
To build firewall under AIX is sample, but as each host based firewall should be done careful 1. Prerequisites To start firewall in AIX yo...
-
Should I trust AI? So far no, sorry. I tested for the moment (May, 2025) most advanced model for programming and ask very simple question:...