Save info   Get password
Home Submit your blog Edit Account Rules RSS-Archive Contact
  • My SysAd Blog blog

    Owner: My SysAd Blog
    URL: http://www.mysysad.com
    Join Date: Fri, 20 Oct 2006 04:43:18 -0500
    Rating:1
    Site Description:
    My UNIX-based blog covers a collection of tips for installations, programming, scripting, configuration, SQL, maintenance, troubleshooting, and command line syntax. What exactly is UNIX? Unix stands for UNiplexed Information and Computing System--original
    Site statistics: Click here



Copying a File/Directory
1970-01-01 00:59:59
Copy a file or directory is very easy. Well, it's always easy once you know... You will need to use the the cp (copy) utility. It's a very easy utility to use.Here are some quick points.cp originalfile newfile -- Copies contents of originalfile into newfile. The permissions and attribute information are not preserved.cp -p originalfile newfile -- same as above, except the permission and attribute information are preserved.cp -pr originaldirectory newdirectory -- same as above, except the permissions/attribute information are preserved. One big thing here, the -r is recursive. It copies the directory and its contents.e.g.#cp esofthub.dat esofthub1.dat (permissions not preserved and user/group information possibly different)#cp -p esofthub.dat esofthub1.dat (permissions and attribute information preserved)#cp -pr esofthub_dir esofthub1_dir (permissions and attribute information preserved)
Read more: Copying , Directory

Detailed Hardware Specification Information --- Solaris
1970-01-01 00:59:59
Customer requested detailed information on 1.2GHz CPU's which are installed in a SB 2000 workstation. The information was procured with the following command:#prtfruBe forewarned that the output can be fairly verbose.
Read more: Hardware , Solaris , Specification

Dump File System and Suggested Backup Schedule
1970-01-01 00:59:59
How to dump (archive) a file system to tape?To dump the entire root filesystem -- level 0 (full dump):ufsdump 0cfu /dev/rmt/0 /dev/rdsk/c0t0d0s0If you want to dump an all the file systems:Use Bourne Shell at the prompt#sh#for i in 0 1 3 4 6 7 (These numbers represent the partitions you have configured as file systems)#do#ufsdump 0cfu /dev/rmt/0 /dev/rdsk/c0t0d0s$i#echo $i done#doneSuggested and a common backup schedule: Sun Mon Tue Wed Thu FriWeek 1: Full 5 5 5 5 3Week 2: 5 5 5 5 3Week 3: 5 5 5 5 3Week 4: 5 5 5 5 3For the incremental backups:Use Bourne Shell at the prompt.#sh#for i in 0 1 3 4 6 7 (These numbers represent the partitions you have configured as file systems)#do#ufsdump 5cfu /dev/rmt/0 /dev/rdsk/c0t0d0s$i (If Friday's tape, use 3 instead of 5)#echo $i done#done
Read more: Schedule , System

Restore OS After Major File System Crash
1970-01-01 00:59:59
How to restore a file system?#/usr/lib/fs/ufs/ufsrestore 0f - /dev/rdsk/c0t0d0s7 | (cd /export/opt; ufsrestore xf -)Restore incremental backups from tape:Use Bourne Shell at the command line#sh#for i in 0 1 3 4 6 7 (These numbers represent the partitions you have configured as file systems)#do#/usr/lib/fs/ufs/ufsrestore 5cfu /dev/rmt/0 /dev/rdsk/c0t0d0s$i (If Friday's tape, use 3 instead of 5)#echo $i done#doneRepeat incremental backup process until incremental archives are exhausted.
Read more: Major , System

How to remove a file or directory?
1970-01-01 00:59:59
#rm filename (removes a single file)#rm filename* (removes everything that matches filename. e.g. filename1, filename2, filename.bak)#rm -rf /home/esofthub/directoryname (the -r deletes directoryname recursively and all its contents)#rm * ((wildcard *) removes everything within a directory -- make sure you're in the right directory!!)#rmdir /home/esofthub/directoryname (deletes empty directories)


Split Up a Big Binary or ASCII File and Email
1970-01-01 00:59:59
We had to email a 75 megabyte binary file to the states. Unfortunately, the email server doesn't allow for attachments over 10MB. We had to split it up and have it reconstituted at the distant end.Here's what we did:#split -b 5m FileToBeSplitThis instance splits FileToBeSplit into 16X 5MB segments named xaa xab xac...xap.Now reconstitute at the distant end:#cat xaa xab xac xad xae xaf xag xah xai xaj xak xal xam xan xao xap > ReconstitutedFileor#cat * > ReconstitutedFile -- ensure xa* are the only files in the directory when using the wildcardFor ASCII files: Split lines -- This example splits a document into 1000 line segments.#split -l 1000 FileToBeSplitAfter this syntax change, the procedures are the same as binary.--For larger files, find a ftp server or make your filesize increments bigger.
Read more: Binary , Email

Finding a User With Niscat
1970-01-01 00:59:59
Today, I was asked to lookup a user who left over a year ago. We maintain three different name services. The local name service is files and the organizational name service is NIS+. The third one is DNS, which is used to lookup external addresses.How did I quickly find the user via command line?I used the following commands:For files: more /etc/passwd | grep -i username (if you know it or some other known string)For NIS+: niscat passwd.org_dir | grep -i usernameBy the way, the user was located in the NIS+ domain. The user was deleted.


Change User/Group Attributes to a File
1970-01-01 00:59:59
It's very simple.For User:chown username filenamechown username directorynameRecursively:chown -R username directorynameFor Group :chgrp groupname filenamechgrp groupname directorynameRecursively:chgrp -R groupname directoryname-----Change groupname and username at the same time.chown username:groupname filenameChange username and groupname at the same time recursively.chown -R username:groupname directoryname
Read more: Attributes

Installing LTO3 tape drives
1970-01-01 00:59:59
Today we attempted to install a LTO3 tape drive unit onto the baseline system. However, the tape drive would not respond to user initiated commands. Why? Apparently the operating system was not patched correctly per LTO3 documentation. How did we figure that out?showrev -p | grep patch numberIn this case, it was the following:#showrev -p | grep 108725This outputs information regarding the LTO3 tape driver.


Archived one RAID to Another
1970-01-01 00:59:59
We archived the contents of one RAID to another. It takes awhile but it works.Here's what we did in single user mode.#mount /dev/dsk/c1t3d0s0 /DATA1#mount /dev/dsk/c1t4d0s0 /DATA2#cd /DATA1; tar cvfp - . | (cd /DATA2; tar xvfp -)mount - utility used to mount the UFS block devices to /DATA1 and /DATA2 directoriesUFS - UNIX File Systemcd - change directory utilitytar - tape archive utility


Create a Database Table -- Oracle
1970-01-01 00:59:59
A co-worker and I added a table into one of our Oracle databases. Here's what we did.sql> create TABLE tablename(columnname1 number(4),columnname2 varChar2(10),columnname3 varChar2(10),columnname4 varChar2(10));Table created.sql>create - command TABLE - type of object to be created tablename - name given to table, e.g. car ( - begins parameter list columnname - attribute information, e.g. color number - datatype e.g. 4, 5 and column width e.g. (4) varChar2 - datatype e.g. Phoenix123 and column width e.g. (10) ); - ends parameter list
Read more: Database

Dump File and Load File -- Sybase
1970-01-01 00:59:59
We have a script to dump user created databases on daily basis via a cron job. However, you can dump and recover a user database on demand.Here are the steps.To dump a user database to file:Ensure that you have permissions to write to the destination directory.1>use master2>go1>dump database databasename to '/raid/sybdumps/dump.dat'2>goTo recovered from a database dump file:Ensure that you have permissions to read the dump file.1>use master2>go1>load database databasename from '/raid/sybdumps/dump.dat'2>go1>online database databasename 2>go1>quit2>goExit Sybase interactive mode


An Inline Shell Script -- For Loop
1970-01-01 00:59:59
Often I'm asked how to traverse a list of items in a file. You can easily go through a list of items using a for loop. Here's an example of copying selected contents of originalDir to destinationDir via the command line.#sh#for i in `cat /home/esofthub/mylist.dat`#do#cp -pr /originalDir/$i /destinationDir/.#echo $i done#donesh - shell cat - lists each item in the list one iteration at a time cp - the copy utility for a local workstation -pr - these options preserve the permission and copies recursively echo - lists the item copied
Read more: Inline , Shell

How to Mount and Eject a Floppy
1970-01-01 00:59:59
How to mount and dismount a floppy on a Solaris box.#volcheck -v (to mount)#cd /floppy (check contents)To eject#cd /#eject (to remove floppy or CDROM)You can also use the filemanager (GUI based) to do the same as the aforementioned.
Read more: Floppy

How to Add a Disk (hard drive)?
1970-01-01 00:59:59
For Solaris 7 and below...You can add the hardware and issue the following commands:#drvconfig -i sd#disksORYou can reboot the system after adding the hardware.#touch /reconfigure#init 6ORAt the OBPboot -rYou can use the same commands for Solaris 8 but you can also use the following command:#devfsadm (it automatically detects the hardware)
Read more: drive , hard drive

Drop Database Table Command -- Oracle
1970-01-01 00:59:59
When a table is no longer needed in the database, you may want to drop it. But if it has referential integrity, a simple "drop table tablename" won't suffice.You will need to do the following:SQL>drop table tablename cascade constraints (which removes the referential constraints)
Read more: Database , Oracle , Table

Create Tables and Add Constraints -- Oracle
1970-01-01 00:59:59
Here's an easy way to create, configure and populate Oracle tables. It can be done from the command line but that can be quite cumbersome, especially if you need to make changes.Open up a new file in NotepadPopulate it with your create, constraint, drop, insert and etc statements.Save the file as filename.sql (don't forget the .sql extention)e.g.#sqlplus**you will be prompt for login/password information**SQL>@/home/esofthub/filename.sql;--The "@" symbol executes the contents in the filename.sql file--If you have errors/modifications, simply open the filename.sql in Notepad and make the necessary changes--Then rerun the file using the "@" symbol
Read more: Tables

Display Only Unique Lines From a File
1970-01-01 00:59:59
There are many situations in which you may only want to display unique lines. Here is an easy way of doing it.#uniq filenamee.g. #uniq filename > outputfile (All of the duplicate lines are filtered out. outputfile only has unique lines in it.)
Read more: Display , Lines

How to Add a Tape Drive?
1970-01-01 00:59:59
For Solaris 7 and below...You can add the hardware and issue the following commands:#drvconfig -i st#tapesORYou can reboot the system after adding the hardware.#touch /reconfigure#init 6ORAt the OBPboot -rYou can use the same commands for Solaris 8 but you can also use the following command:#devfsadm (it automatically detects the hardware)


Combine Contents of Multiple Files Into One.
1970-01-01 00:59:59
Two days ago, I had to combine 8 large data files into one. Each file contained a list of CSV data that needed to be parsed into one file. Here's what I did.#cat file1 file2 file3 file4 file5 file6 file7 file8 > mynewfilemore examples... #cat file1 file2 > newfilename #cat file1 file2 file3 > newfilename #cat file1 file2 file3 file4...filen > newfilename (You should be getting the idea by now...) The ">" system is a redirect.By the way, cat is short for concatenate or join.
Read more: Contents , Multiple

Write to An Unwritable Partition
1970-01-01 00:59:59
You can write to an unwritable partition using this simple syntax. Many security engineers strongly encourage SysAds to lock down (read only) their/usr partitions. However, this can present problems during upgrades. Here's a quick and dirty workaround.#mount -F ufs -o rw,remount /usrFrankly speaking, I've only been able to remount /usr to write. I've always had to reboot the system for read only to take effect. Suggestions?
Read more: Partition , Write

A Quick and Dirty Tutorial on VI Editor
1970-01-01 00:59:59
INSERT MODE i (insert before cursor) a (insert after cursor)A (insert at the end of the line) o (open new line below cursor) O (open new line above cursor)ESC to COMMAND MODE x (deletes single character), 3x (deletes three characters), ...nx (deletes n characters) dd (deletes single line), 5dd (deletes 5 lines), ...ndd (deletes n lines)yy (copies single line), 5yy (copies 5 lines), ...nyy (copies n lines)p (pastes lines) dw (deletes single word) cw (changes single word) r (replaces single character) . (repeats previous command) u (undos last command) :set list (displays non-printable characters) Use keyboard arrows to move around To save and exit vi: :w filename :w (if filename was provided when vi was invoked) :q! (quit without saving) :wq! (quit and save--overrides write permissions) :ZZ (quit and save--does not override write permissions) e.g. vi filename THIS IS AN EXAMPLE (in INSERT MODE) (now press ESC) :wq!
Read more: Editor , Quick , Tutorial

How to FTP Local File(s) to a Remote Server
1970-01-01 00:59:59
You will be asked for login/password information following the first step unless anonymous.#ftp esofthub.comftp>cd /tmp/TEMP (on remote workstation)ftp>binftp>lcd /tmp/MYLOCAL (on local workstation)ftp>!ls (on local--file named filename)ftp>put filename (puts filename into remote's directory, /tmp/TEMP)ftp>quitUse mput (multiple files) instead of put if you want to FTP everything from the local directory into the remote directory
Read more: Local , Remote

How to get Files From a Remote Server
1970-01-01 00:59:59
You will be asked for login/password information following the first step unless anonymous.#ftp esofthub.comftp>cd /tmp/TEMP (on remote workstation)ftp>binftp>ls (on remote--file named filename)ftp>lcd /tmp/MYLOCAL (on local workstation)ftp>get filename (places filename into /tmp/MYLOCAL)ftp>quitUse mget (multiple files) instead of get if you want to FTP everything from the remote directory into the local directory
Read more: Remote

Append an Entry to a File
1970-01-01 00:59:59
There are many situations in which you may want to append an entry to a file. Here are two ways of doing it.#echo "138.123.34.12 myhost" >> /etc/hosts#cat >> /etc/hosts"138.123.34.12 myhost"then execute a control d
Read more: Entry

How to Change the Values of the PROM (EEPROM)
1970-01-01 00:59:59
For security purposes, you might want to password protect your open boot prom (obp). This will prevent unauthorized changes of your prom settings.#eeprom (gives you a default listing)e.g.#eeprom security=commandenter new prom password (it prompts you for a new password)
Read more: Change , Values

How to Capture xterm/cmdtool Output
1970-01-01 00:59:59
When you are performing an upgrade/installation via command line, you might want to capture the steps/procedures in real-time. There is a convenient way of doing this task.#script -a /tmp/outputfilename (whatever is typed after this command execution is captured)When you are done, enter control d to terminate the capture process.
Read more: Output

Convert a ISO Standard to DOS and vice versa
1970-01-01 00:59:59
Sometimes you have to convert UNIX formatted file to a DOS format and vice versa .#unix2dos filenameunix > filenamedosConvert a DOS formatted file to ISO Standard ?#dos2unix filenamedos > filenameunix


Modify Information in a Nisplus Table
2008-03-09 07:11:00
The nistbladm command is used to modify information in a nisplus table. In this example, the passwd.org_dir table was modified. The login directory and shell was modified for the esoft user. Here is the syntax.Prior to modification# niscat passwd.org_dir | grep esoftesoft:SNVE9mJSZ9ub6:1005:10:Test Account:/export/home/esoft:/bin/sh:13947::::::Modify the user's home directory# nistbladm -e home=/home/esoft '[name=esoft]'passwd.org_dir# niscat passwd.org_dir | grep esoftesoft:SNVE9mJSZ9ub6:1005:10:Test Account:/home/esoft:/bin/sh:13947::::::Modify the user's shell# nistbladm -e shell=/bin/zsh '[name=esoft]'passwd.org_dir# niscat passwd.org_dir | grep esoftesoft:SNVE9mJSZ9ub6:1005:10:Test Account:/home/esoft:/bin/zsh:13947::::::
Read more: Table

Display the Structure of a Nisplus Table
2008-03-09 04:45:00
Building on the last post, I am using the niscat -o flag to display the structure of a common nisplus table. In the example below, the run shows the passwd table and its specific metadata/attribute information. Here is the syntax.# niscat -o passwd.org_dirObject Name : "passwd"Directory : "org_dir.esofthub.com."Owner : "esoft.esofthub.com."Group : "admin.esofthub.com."Access Rights : ----rmcdrmcdr---Time to Live : 12:0:0Creation Time : Sun Feb 24 18:22:47 2008Mod. Time : Sun Feb 24 18:22:47 2008Object Type : TABLETable Type : passwd_tblNumber of Columns : 8Character Separator : :Search Path :Columns : [0] Name : name Attributes : (SEARCHABLE, TEXTUAL DATA, CASE SENSITIVE) Access R
Read more: Display , Structure

Page 1 of 4 « < 1 2 3 > »
eXTReMe Tracker