Difference between revisions of "Useful Commands"
(15 intermediate revisions by the same user not shown) | |||
Line 12: | Line 12: | ||
== Set network interfaces with unique MAC addresses == | == Set network interfaces with unique MAC addresses == | ||
− | So you have a Sun Sparc server with multiple network interfaces. You'd expect them to have different MAC addresses right? Wrong! By default they will present the same MAC address. In order to force the machine to use a different MAC address you need to do either of the following | + | So you have a Sun Sparc server with multiple network interfaces. You'd expect them to have different MAC addresses right? Wrong! By default they will present the same MAC address. In order to force the machine to use a different MAC address for each interface you need to do either of the following: |
From the OpenBoot PROM ('ok' prompt): | From the OpenBoot PROM ('ok' prompt): | ||
Line 22: | Line 22: | ||
eeprom "local-mac-address?=true" | eeprom "local-mac-address?=true" | ||
+ | == Deleting unusual file names via Inode number == | ||
− | + | Ok, so you've accidentally created a file with a special character in it's name, like ~ or ` or something just as stupid. How do you delete it when the shell won't let you escape the character. Delete it via it's Inode number. | |
− | + | 1. Find out it's inode number: | |
− | |||
− | |||
ls -ali | ls -ali | ||
− | + | 2. Delete it like so: | |
find . -inum INODE_NUMBER -ok rm '{}' \; | find . -inum INODE_NUMBER -ok rm '{}' \; | ||
+ | |||
+ | == Turn off all unnecessary Network Services == | ||
+ | |||
+ | I've never used this, but I can see where it would be handy when you first build a box. It turns off all unnecessary network services in one fell swoop: | ||
+ | |||
+ | netservices limited | ||
+ | |||
+ | |||
+ | == Cloning a Disk with ufsdump and ufsrestore == | ||
+ | |||
+ | I've found this useful a few times where you want to clone a disk. | ||
+ | |||
+ | 1. Mount the slice you want to copy to | ||
+ | |||
+ | mount /dev/dsk/c0t0d0s6 /mnt | ||
+ | |||
+ | 2. Use ufsdump and ufsrestore to copy the data | ||
+ | |||
+ | ufsdump 0f - /dev/dsk/c0t0d0s6 | (cd /mnt; ufsrestore xvf -) | ||
+ | |||
+ | 3. Repeat for all disk slices (except swap of course). | ||
+ | |||
+ | |||
+ | == How much RAM is installed? == | ||
+ | |||
+ | Although you can use the 'top' command to do the same thing, as top isn't installed on all systems you may need this: | ||
+ | |||
+ | /usr/sbin/prtconf | grep -i "Memory Size" | ||
+ | |||
+ | |||
+ | == Mounting an ISO image == | ||
+ | |||
+ | 1. Upload your ISO image to the box in question. | ||
+ | |||
+ | 2. Use the lofiadm command to create a mountable device out of you ISO image | ||
+ | |||
+ | lofiadm -a <DOWNLOADED DIRECTORY>/isoimage.iso /dev/lofi/1 | ||
+ | |||
+ | 3. Mount the new device as you would any mountable device | ||
+ | |||
+ | mount -F hsfs -o ro /dev/lofi/1 /mnt | ||
+ | |||
+ | 4. Once you've finished with it, unmount | ||
+ | |||
+ | umount /mnt | ||
+ | |||
+ | 5. Delete the device you created in step 1: | ||
+ | |||
+ | lofiadm -d /dev/lofi/1 | ||
+ | |||
+ | 6. Now you can safely delete your ISO image. | ||
+ | |||
+ | |||
+ | == Determining which files are installed by a package == | ||
+ | |||
+ | |||
+ | This has proven useful when you inherit a build from someone else and they have a custom package that you don't know about and need to install somewhere else. | ||
+ | |||
+ | pkgchk -l ''package_name'' | egrep “Pathname|Type” | ||
+ | |||
+ | == Determining which package installed a particular file == | ||
+ | |||
+ | pkgchk -l -p /path/to/file |
Latest revision as of 05:41, 28 February 2017
These are a number of useful commands that I have found over the years. See the 'man' pages for more detail.
Contents
- 1 Running 64-bit or 32-bit Solaris?
- 2 Set network interfaces with unique MAC addresses
- 3 Deleting unusual file names via Inode number
- 4 Turn off all unnecessary Network Services
- 5 Cloning a Disk with ufsdump and ufsrestore
- 6 How much RAM is installed?
- 7 Mounting an ISO image
- 8 Determining which files are installed by a package
- 9 Determining which package installed a particular file
Running 64-bit or 32-bit Solaris?
This command is more relevant with older versions of Solaris, as these days Solaris is 64-bit by default. However, if you're running an older version of Solaris and need to know if it's running in 64-bit or 32-bit mode, here's how you find out:
/usr/bin/isainfo -kv
Set network interfaces with unique MAC addresses
So you have a Sun Sparc server with multiple network interfaces. You'd expect them to have different MAC addresses right? Wrong! By default they will present the same MAC address. In order to force the machine to use a different MAC address for each interface you need to do either of the following:
From the OpenBoot PROM ('ok' prompt):
setenv local-mac-address? true
From the OS:
eeprom "local-mac-address?=true"
Deleting unusual file names via Inode number
Ok, so you've accidentally created a file with a special character in it's name, like ~ or ` or something just as stupid. How do you delete it when the shell won't let you escape the character. Delete it via it's Inode number.
1. Find out it's inode number:
ls -ali
2. Delete it like so:
find . -inum INODE_NUMBER -ok rm '{}' \;
Turn off all unnecessary Network Services
I've never used this, but I can see where it would be handy when you first build a box. It turns off all unnecessary network services in one fell swoop:
netservices limited
Cloning a Disk with ufsdump and ufsrestore
I've found this useful a few times where you want to clone a disk.
1. Mount the slice you want to copy to
mount /dev/dsk/c0t0d0s6 /mnt
2. Use ufsdump and ufsrestore to copy the data
ufsdump 0f - /dev/dsk/c0t0d0s6 | (cd /mnt; ufsrestore xvf -)
3. Repeat for all disk slices (except swap of course).
How much RAM is installed?
Although you can use the 'top' command to do the same thing, as top isn't installed on all systems you may need this:
/usr/sbin/prtconf | grep -i "Memory Size"
Mounting an ISO image
1. Upload your ISO image to the box in question.
2. Use the lofiadm command to create a mountable device out of you ISO image
lofiadm -a <DOWNLOADED DIRECTORY>/isoimage.iso /dev/lofi/1
3. Mount the new device as you would any mountable device
mount -F hsfs -o ro /dev/lofi/1 /mnt
4. Once you've finished with it, unmount
umount /mnt
5. Delete the device you created in step 1:
lofiadm -d /dev/lofi/1
6. Now you can safely delete your ISO image.
Determining which files are installed by a package
This has proven useful when you inherit a build from someone else and they have a custom package that you don't know about and need to install somewhere else.
pkgchk -l package_name | egrep “Pathname|Type”
Determining which package installed a particular file
pkgchk -l -p /path/to/file