Solaris
To list all internal HW (cdroms, disks, tape drives etc...) - and retrieve info on their state :# iostat -E
To list all installed packages :
# pkginfo
To install a package :
# pkgadd -d pkg-name
To list all installed patches :
# showrev -p
Setting ethx link speed
# mii-tool -v eth0shows the settings for the first ethernet network card (eth0)
# mii-tool -F 100baseTx-FD eth0
forces eth0 to 100Mb/Full Duplex
# ethtool -s eth0 autoneg off speed 1000 duplex full
forces eth0 in gigabit mode
# mii-tool -A eth0
brings eth0 back to autonegotiation
Setting the date
To set the date, you will use the "date" command, and provide the correct format :date MMDDhhmmYYYY
For instance, to set the date to January 25th, 16:21 in the year 2006
# date 012516212006
Installing ssh with public/private key authentication
# ssh-keygen -t dsaCreates the private and public keys
Copy the contents of the file ~/.ssh/id_dsa.pub in the distant machine where you want to connect to in ~/.ssh/authorized_keys. If the file already exists, simply paste the info on a new line.
# ssh-agent /bin/bash
or
# eval `ssh-agent`
on the local machine
then
# ssh-add
You can try connecting on the remote host; you should not be asked a pass. If you are.check the
/etc/ssh/sshd_config file. Something is too much, or is missing ;-)
USB stuff
mounting a usb device such as a key, or a digital camera :# mount -tvfat -oumask=0000 /dev/sda1 /mnt/usb
Tips for vi
say you want to replace all instances of a word in a text by another word:1,$s/word/other_word/
or if you wanted to remove all instances of the word, replacing it by nothing
:1,$s/word//
When transfering files from windoze to unix, it sometimes happens that the file format is altered,
resulting in ^M at the end of each line...
:1,$s/^V^M$//
will do the job
Here's a little explanation: 1,$ means from line 1 to the last line in the file
s stands for "substitution"
^V^M means Ctrl-V, Ctrl-M
$ means "at the end of the line"
1,$ could also be replaced by %
The '% ' sign means; from the first to last line of the file.
The crontab
minute (0-59)hour (0-23)
day of the month (1-31)
month of the year (1-12)
day of the week (0-6 with 0=Sunday)
Sendmail stuff
If you are looking in debuging mail issues and obtain verbose output on the outgoing mail, here's the way to get there :# sendmail -v -f user@return.address.org -t
To: user@some.domain.org
subject: blah blah
.
Here is the explanation of what is being done:
-v is for verbose output
-f is the recipient to which mail error messages are sent
-t is to specify that mails are sent to recipients found in headers (To: user@some.domain.org)
Networker stuff
To save a client from the server's command line, here is what you need to type :# savegrp -v -c client_name group_name
Here -v is to specify verbosity - you can add up to five "v" as such -vvvvv to have maximum verbosity. The -c tells the command that the next option will be the client_name. The group_name needs no CLI operator.
If you need to recover an NSR client from the server's CLI :
# recover -d destination -c client -s server -t date
In this case the -d option desingnates the destination directory for the restored files, -c and -s are respectively the client to restore and the server to restore from. As for the-t date, it is the browse time (the date at which you wish to find the file).
You can use the recover command interactively as well. In this case just type recover at your shell's promt and you can issue your options and commands from within.
If you're looking to list the volumes used for a particular pool, sorted out by date :
# mminfo -a -otm -r 'pool,volume,savetime,client' -q 'pool=pool_name' |more
As explained above, the result will be sorted by date, the oldest volumes at the top of the output. This explains the |more , which will thus show you your oldest volumes as your first screen avoiding you the hassle of going back in your TERM's history...
If you want to label and mount a volume from the command line :
# nsrmm -b zhong -f /Data/usbnsr/vol1 -m -l zhong.001
Operators are :
-f : file or device
-m : mount
-l : label your.label
Samba stuff
If you need to query a WINS server, it's funny, but it is "better" when using linux than M$Using nmblookup, you can specify the WINS server to query, while you can not using M$
# nmblookup -R -U 192.168.0.55 netforce
where -R is "recursive", -U "unicast", the IP 192.168.0.55 is the WINS server address and netforce is the client to query
In the same idea, if you wish to query for an IP address :
# nmblookup -R -U 55.25.9.20 -A 55.83.1.70
In this case 55.25.9.20 is the WINS server -A is to specify we are querying the server for an IP and not a NETBIOS name.
In order to mount a distant samba share, here is how you would succeed :
# mount -t smbfs -o username=your_samba_unsername //machine/share /mnt/smb
The -o indicates you are going to be sending options. The your_samba_unsername is the username on the distant smb machine. //machine/share is the distant machine's netbios name and share, while /mnt/smb is the local mount point
In this case, you will be promted to enter your password. You could automate this by providing your password during the mount command prefering automation to security. In this case your mount command would look like this :
# mount -t smbfs -o username=your_samba_unsername,password=password //machine/share /mnt/smb
LDAP
Most common queries will look something like this:$ ldapsearch -x -LLL -h 127.0.0.1 -b dc=example,dc=com sn=smith uid cn sn telephonenumber
Here is the explanation of what we're doing:
-x is for simple authentication (instead of SASL)
-LLL is for the output format - standard ldif
-h is to specify the host
-b is to specify the base of the search in the ldap tree
sn=smith is what we are looking for - the record(s) for users with "Smith" as a lastname (sn is surname)
uid cn sn telephonenumber are the attributes you want to "extract" from your search
In this case, the output for the above search would look like this:
dn: uid=jsmith,ou=people,dc=example,dc=com
uid: jsmith
cn: John Smith
sn: Smith
telephonenumber: 555-1234
Queries may be more complex and not limited to a simple search on a user's last name...For instance, we may be searching for users which have an e-mail address ending in example.com and located in Paris.
$ ldapsearch -x -LLL -h 127.0.0.1 -b dc=example,dc=com "(&(mail=*@example.com)(l=paris))" uid cn sn l mail telephonenumber
In this case, the output for the above search would look like this:
dn: uid=jsmith,ou=people,dc=example,dc=com
uid: jsmith
cn: John Smith
sn: Smith
l: Paris
mail: jsmith@example.com
telephonenumber: 555-1234
dn: uid=msmith,ou=people,dc=example,dc=com
uid: msmith
cn: Mike Smith
sn: Smith
l: Paris
mail: msmith@example.com
telephonenumber: 555-4321