DirectoryComputersBlog Details for "My SysAd Blog"

My SysAd Blog

My SysAd Blog
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--ori
Articles: 1, 2, 3, 4, 5, 6, 7

Articles

Specify or Report Default Permissions with umask
2007-08-17 11:14:00
The umask command can be used to specify default permissions on files you create. It also can be used to report on a file's current defaults. Here are some examples.Explanation of what the octal digits mean0 - don't restrict any permissions1 - restrict execute permissions2 - restrict write permissions4 - restrict read permissionsReport current umask setting# umaskProvides complete access to every file you create on the system to everyone.# umask 000Provides complete access to you and your group. The others (world) are excluded.# umask 007Provides complete access to you but limits group and others to read and execution.# umask 022
More About: With U , Missi
Change the Operational Status of Processors
2007-08-16 15:58:00
The psradm command can be used to change the operational status of a processor(s) in a multiprocessor system. The statuses are online, offline and no-intr. Here are a few examples.Take processors 2 and 3 offline# psradm -f 2 3Process ors 1 and 2 are not interrupted by I/O processes# psradm -i 1 2Bring a specified processor, 3, online# psradm -n 3Bring all processors online# psradm -a -n
More About: Change , Status , Operation
Log Telnet and FTP Sessions in Log File
2007-08-15 17:03:00
For security reasons, you might opt to log telnet and FTP sessions. On my box, those sessions are logged into the /var/adm/messages file. To make this change, you will have to modify the /etc/rc2.d/S72inetsvc script. Here's an example.Go to the bottom of this file and look for this line, /usr/sbin/inetd -s &# vi /etc/rc2.d/S72inetsvc.../usr/sbin/inetd -s &Change to /usr/sbin/inetd -s -t &: wq!You will have to recycle the inetd daemon.
More About: File , Telnet , Sessions
Reverse the Contents of a File
2007-08-14 13:36:00
The tail command can be used to reverse the contents of a file. Here's an example.# cat > filenameTHIS IS AN EASY WAY TO REVERSE THE CONTENT OF A FILE.THE REVERSAL WILL DO MORE THAN 10 LINES. IT WILL REVERSE THE ENTIRE FILE.EOM.# tail -r filename.EOMTHE REVERSAL WILL DO MORE THAN 10 LINES. IT WILL REVERSE THE ENTIRE FILE.THIS IS AN EASY WAY TO REVERSE THE CONTENT OF A FILE.
More About: File , Contents , Tent , The Con
Display either Files or Directories -- UNIX
2007-08-14 13:00:00
I'm revisiting the common but important ls command. Here's an easy way to show either files or directories that are in the current directory.Listing files only# ls -l | awk '{if (substr($1,1,1) == "-") {print}}'-rw-r--r-- 1 esoft other 103936 Jul 7 21:11 070707_archive.tar-rw-r--r-- 1 esoft other 348672 Jul 7 21:44 07072007_archive.tar-rw-r--r-- 1 esoft other 330240 Jul 7 21:16 07072007Y_arch.tar-rw-r--r-- 1 esoft other 482 Jun 2 19:42 crontab_file-rw-r--r-- 1 esoft other 1029 May 30 00:21 exclude-rw-r--r-- 1 esoft other 0 May 30 00:24 include-rw-r--r-- 1 esoft other 103936 Jul 7 21:14 Jul07%s070707_archive.tar...Listing directories only# ls -ld */.drwxr-xr-x 2 esoft sys 512 Oct 22 2005 default/.drwxr-xr-x 3 esoft other 512 Jul 7 20:03 esoft/.drwx------ 2 esoft staff 512 May 30 22:16 Mail/.drwxr-xr-x 2 esoft other 512 Jul 7 20:57 RAID/.drwxr-xr-x 3 esoft other 512 Jul 7 ...
More About: Unix , Display , Directories , Files , Director
Display Non-printable Characters in a Text File
2007-08-13 12:02:00
I received a message asking me how to see non-printable characters in a text file. Almost immediately, utilities such as vi, cat, and od come to mind. The od command clearly states which non-printable characters are present. Here are examples using a text file.# vi filename.txt^I^I^I^I$$$$this is a test$^I^I^I^I$~: set list# cat -vet filename.txt^I^I^I^I$$$$this is a test$^I^I^I^I$# od -c filename.txt0000000 t h i s i s0000020 a t e s t 0000034Related post
More About: File , Display , Characters , Text , Char
Using the UNIX repeat Command
2007-08-12 12:50:00
The other day I was thinking about all those sentences I had to write while in grade school (primary). It would have been great to know something about the repeat command. In all seriousness, you can use it as a separator (maybe script output). Here are some examples of its use. # repeat 5 echo "*********"****************************** ***************# repeat 5 echo "##########"############################# ###################### repeat 5 echo " "# repeat 500 echo "I will not chew gum or backtalk."I will not chew gum or backtalk.I will not chew gum or backtalk.I will not chew gum or backtalk.I will not chew gum or backtalk.I will not chew gum or backtalk....You get the idea
More About: Unix , Command , The U
Display Specific Lines in a File using sed
2007-08-11 15:25:00
I'm often asked how to show specific lines in a file. The utility I use for this task is the powerful string editor or sed. Here's a brief example of its use.For illustration purposes, I'm using the cat -n filename to show the line numbers in this script.# cat -n filename...8 for i in $*910 do1112 typeset -i16 hex13 hex=$i14 print $i equals $hex in hexadecimal1516 typeset -i8 oct17 oct=$i18 print $i equals $oct in octal1920 typeset -i2 bin21 bin=$i22 print $i equals $bin in binary2324 print25 done...Prints out the for loop without displaying the line numbers# sed -n 8,25p filename | tee for_loop
More About: File , Display , Specific , Lines
Recreate the /dev/null Link using devlinks
2007-08-10 09:14:00
If you inadvertently delete the /dev/null link, you can recreate it by using the devlinks command. The null device is basically a bit bucket. Here's an example.# cd /dev/# ls -l nullnull: No such file or directory# devlinks# ls -l nulllrwxrwxrwx 1 root other 27 Aug 10 16:11 null -> ../devices/pseudomm@0:nullIf null device and link is missing, use mknod.# cd /devices/pseudo# mknod mm@0:null c 13 2# chown root:sys mm@0:null# chmod 666 mm@0:null# devlinks
More About: Link , Create , Null
Capitalize Strings in UNIX
2007-08-09 15:59:00
There might be times when you need to CAPITALIZE everything. The capitalize command handles this task well. Here's an example of its use.Capitalize entire script# cat testme | /usr/openwin/bin/capitalize -u#!/BIN/KSHIF [ $# = 0 ]; THENECHO ADD AN ARGUMENT LISTEXITFI...Capitalize the output of a command# date | /usr/openwin/bin/capitalize -uTHU AUG 9 22:56:16 KST 2007
More About: Unix , Strings , Tring
Display the core File Configuration
2007-08-07 16:06:00
The dumpadm command is used to show the dump configuration. However, you can change the dump configuration using the dumpadm -d option, e.g. dumpadm -d /dev/dsk/the_slice_deviceNote below that a crash dump would be saved in the /var/crash/esoft directory.# dumpadm Dump content: kernel pages Dump device: /dev/dsk/c0t0d0s1 (swap)Savecore directory: /var/crash/esoft Savecore enabled: yes
More About: File , Display , Core , Configuration , Config
Z Shell for loop -- UNIX zsh
2007-08-06 11:43:00
Here's a succinct use of the for loop using the Z shell. See ZSH is cool: Brace Expansion by Stéphane Kattoor for additional details. Here's a practical application of the zsh for loop.Using the Bourne shell for loop# sh# for i in 1 2 3 4 5 6 7 8 9 10 11 12dorcp -p /etc/hosts esoftclient$i:/etcdoneNow using brace expansion for the Z shell for loop# zsh# for i in {1..12}dorcp -p /etc/hosts esoftclient$i:/etcdone
More About: Unix , Shell , Loop
Display the Checksum and Size for a File
2007-08-03 12:09:00
The cksum command is used to display the checksum and size of a file. This command is useful in verifying file integrity over noisy transmission lines. Here's an example of its application.# cksum firefox-1.0-sparc-sun-solaris2.8.tar28210 05393 55203840 firefox-1.0-sparc-sun-solaris2.8.tar
More About: File , Display , Size
Process Control for UNIX
2007-08-01 10:37:00
Here's a listing of common process controls. This listing contains controls codes accompanied with descriptions.Control +s --> Stops screen scrollingControl+q --> Resumes suspended displayControl+d --> Signals end of fileControl+c --> Interrupts a processControl+z --> Suspends a foreground process bg --> Resumes a background process fg --> Resumes a foreground processControl+u --> Clears command line
More About: Unix , Process
View the Value of a UNIX Variable
2007-07-31 21:16:00
Sometimes you might want to display the contents of a variable. Why? It might be set to an incorrect value. Here's a couple basic ways of doing that.Set variable# csh# setenv ESOFT /export/home/esofthubor# sh# ESOFT=/export/home/esofthub; export ESOFTView variable contents# echo $ESOFT/export/home/esofthub# env | grep ESOFTESOFT=/export/home/esofthubOther miscellaneous uses# cd /# cd $ESOFT; pwd# ls $ESOFT# $ESOFT/myscript.cshTHIS IS A TEST
More About: Unix
Copy the Contents of a Magnetic Tape to Another
2007-07-30 11:58:00
If you need to copy the contents of a magnetic tape to another magnetic tape, it's a fairly easy task. However, prior to copying, ensure tapes are free of errors and rewound. Here's the syntax.#mt -f /dev/rmt/0 rewind#mt -f /dev/rmt/1 rewind#tcopy /dev/rmt/0 /dev/rmt/1
More About: Contents , Copy , Magnet , Tent , The Con
Clear the Terminal Screen
2007-07-30 11:17:00
I use the clear command to clear out the contents of a screen. It's similar to executing a new xterm without the extra window. You might also want to use it to prevent prying eyes (i.e. competitors, etc).#clear
More About: Screen , Terminal , Clear , Term , Cree
Send Message to Users with Write All
2007-07-08 06:51:00
When you want to send a message to everyone, use the wall command. It sends the message immediately to the console. Here's its syntax.# wallI hope everyone had a great 4th of July and have a nice weekend.control+d
More About: Write , Message , Send , Users , Mess
Using the Common UNIX Find Command
2007-07-07 11:17:00
One of the most useful utilities in the UNIX systems resources directory is the find command. System administrators use this powerful utility frequently. Here are a few common tasks performed by the ubiquitous find command. I'll add more as time goes on.# cd /export/home/esofthubFind a file or directory# find . -name TEMP -printor# find . -name TEMP -exec echo {} ;Find core files in this directory tree and remove them# find . -name "core" -exec rm -f {} ;Find junk directories and remove their contents recursively# find . -name "junk" -exec rm -rf {} ;Find a pattern in a file using the recursive grep (ignore case)# find . -type f | xargs grep -i MYPATTERNFind files modified in the past 7 days# find . -mtime -7 -type fFind files owned by a particular user# find . -user esofthubFind all your writable directories and list them# find . -perm -0777 -type d -lsor# find . -type d -perm 777 -printFind all your writable files and list them# find . -perm -0777 -type f -lsor#find . -type ...
More About: Unix , Common , Comm , Command
Enable Stop-A or Disable Stop-A
2007-07-06 10:57:00
When you run the bsmconv script, it disables the Stop -A feature. However, this can present a problem during troubleshooting efforts (e.g. problems bringing the system down to OBP level). Here's how to re-enable or disable it.To enable Stop-A, prepend an asterisk, "*", to the following line in the /etc/system file.#vi /etc/system...*set abort_enable = 0ORset abort_enable = 1:wq!#init 6To disable Stop-A, add "set abort_enable = 0" to the /etc/system file#vi /etc/system...set abort_enable =0:wq!#init 6
Disable C2 Security Audits on Solaris
2007-07-06 10:37:00
Keep in mind that auditing takes a lot of disk space, so you will need to plan accordingly. Also, the audits are cryptic and may not be useful unless you have someone who understands them. If you weren't aware of the aforementioned, you might want to disable the Basic Security Module (BSM). Here's an example.Go to single user state#init s#cd /etc/security# ./bsmunconvThis script is used to disable the Basic Security Module (BSM).Shall we continue the reversion to a non-BSM system now? [y/n] ybsmunconv: INFO: moving aside /etc/security/audit_startup.bsmunconv: INFO: restore /etc/rc2.d/S92volmgt.bsmunconv: INFO: removing c2audit:audit_load from /etc/system.bsmunconv: INFO: stopping the cron daemon.The Basic Security Module has been disabled.Reboot this system now to come up without BSM.#init 6
More About: Solaris
Enable C2 Security Audits on Solaris
2007-07-06 10:09:00
It's always a good idea to monitor activity on your server or workstation. Solaris provides a C2 auditing level system, which is the Basic Security Module (BSM). It's enabled by running the bsmconv command. Here's an example.# cd /etc/security# ./bsmconvThis script is used to enable the Basic Security Module (BSM).Shall we continue with the conversion now? [y/n] ybsmconv: INFO: checking startup file.bsmconv: INFO: move aside /etc/rc2.d/S92volmgt.bsmconv: INFO: turning on audit module.bsmconv: INFO: initializing device allocation files.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.#init 6By the way, the binary audit files (default directory /var/audit) are a bit cryptic. Use the praudit command to convert files to a ASCII format. Also, the /etc/rc2.d/S92volmgt file was moved to /etc/security/spool.
Drop User From a Sybase Database
2007-07-06 04:55:00
Denying user access to a database is a fairly simple process. The sp_dropuser stored procedure makes this possible. However, ensure the user doesn't own any objects in the database, has grant privileges or owns the database. Here's the syntax for the current database.1>sp_dropuser esofthub2>go1>select * from sysusers2>go
More About: Database , User , Base , Sybase , Drop
Drop a Sybase Group
2007-07-06 04:45:00
Dropping a Sybase group is another fairly easy task. To accomplish this task, you will need use the sp_dropgroup stored procedure. But here's one caveat, the group must not contain any members. Here's an example.1>sp_dropgroup esoftdb_group2>go
More About: Group , Base , Drop
Change a Sybase User's Group
2007-07-06 04:22:00
Changing a user's group is another fairly straightforward task. You will need to use the sp_changegroup stored procedure to accomplish this task. Here's an example.1>sp_changegroup mynewgroup, esofthub2>go
More About: Change , Group , Base , Sybase , Chang
Create a Sybase Group
2007-07-06 04:14:00
Creating a group in a Sybase database is an easy task. You will need to use the sp_addgroup stored procedure to accomplish the task. Here's the syntax for the current database.#isql -Usa -Ppassword1>use esoftdb2>go1>sp_addgroup esoftdb_group2>goDetermine groups in a database#isql -Usa -Ppassword1>use esoftdb2>go1>sp_helpgroup2>goDetermine users in a specific group1>sp_helpgroup esoftdb_group2>go
More About: Group , Create , Base
Dumping Sybase Transaction Log
2007-07-06 03:36:00
A common problem with a transaction log is filling up. You will have to dump it or you could face serious performance issues. Here's the syntax.#isql -Usa -Ppassword1>use esoftdb2>go1>dump tran esoftdb with no_log2>go
More About: Ping , Base , Sybase , Tran , Ansa
Display Sybase Login Information
2007-07-06 03:19:00
The sp_displaylogin reports information on a login. It gives information such as, user ID, full name, roles, and account status. Here's its syntax.For privilege roles#isql -Usa -Ppassword1>sp_displaylogin esofthub2>goFor non-privilege roles (provides information about their own login)#isql -Uesofthub -Panypassword1>sp_displaylogin2>go
More About: Information , Display , Format , Base , Sybase
Change Default Database for Sybase User
2007-07-06 03:08:00
Here's a quick way to change the default database for a user in Sybase. This task can be done with the sp_modifylogin stored procedure. In the example below, the esofthub login is being assigned the esoftdb as its default database. Here's its syntax.#isql -Usa -Ppassword1>sp_modifylogin esofthub, defdb, esoftdb2>go
More About: Change , Database , User , Fault , Base
Change Password for a Sybase User
2007-07-03 14:18:00
Changing passwords for a Sybase user is a fairly straightforward process. The first example deals with changing the ?sa? password or another user's password. The second example is when a user changes their own password. Here's the syntax.Note: If your password string begins with a number, enclose it in "quotes." #isql -Usa -Ppassword1>sp_password old_password, new_password, sa2>goAnother user's password #isql -Usa -Ppassword1>sp_password old_password, new_password, esofthub2>goAny user can change their own password#isql -Uesofthub -Pesofthub_password1> sp_password old password, new_password2>go
More About: Change , Password , User , Sword , Base
More articles from this author:
1, 2, 3, 4, 5, 6, 7
40933 blogs in the directory.
Statistics resets every week.


Contact | About
© Blog Toplist 2008 - SEO by FeWorks
eXTReMe Tracker