Академический Документы
Профессиональный Документы
Культура Документы
Create Links
ln ls l ls li fil1 fil2 fil4 # creates a new link called fil2 to fil1 # gives info about the symbolic link fil4 ln s /usr/bin fil4# creates a symbolic link to the directory /usr/bin and gives the namne fil4 fil1# gives inodnumber to the file fil1 and you can see how many links are created to this file
quot -af# displays diskspace being used by users on all mounted filesystems quot f /dev/dsk/c0t0d0s5# displays the number of files and space owned by each user in a specific disk slice
Harddrive information
c#t#d#s# c= controller number t= target number(scassi number) d= disk number s= slice number
c0t6d0s0 = cdrom
Delete files
rm i fil.txt rmdir potatis \rm fR Site-data# deletes the whole directory including the under directories # delete the file fil.txt rm r manual test.txt # delete files and directories
Find
find . name prog.c print find . name \*.c print find \ name prog.c print # dot means search in actual directory and below the actual directory # search all c files in actual directory and below the actual directory # search in all directories
File
file main.c a.out # gives info about the includings of the file
Grep
grep n unix c1.mm grep i unix c1.mm grep ni unix c1.mm grep c error c1.mm grep error *.mm # search the lines including unix in the text file # do the same as abowe but include bouth small and capital letters # print all the lines with line number including unix,Unix eller UNIX # print number of lines including the character error # search and print out all lines including the character error
Pkginfo
pkginfo | more pkgrm SUNWaudio pkgchk v SUNWaudio pkgchk p /etc/passwd admintool # displays info about installed program pakages # removes the program pakage # lists files including in the actuall program pakage # Displays the changes made on the actuall file
pkgadd d /cdrom/cdrom0/s0/Solaris# installs a program pakage # It is possible to check the installed pakages and install new pakages with admintool
Processer
ps fe ps e ps ax kill process number kill 9 process number # kill the process # kill the process brutally # list all the processes
The command at is used to do sum commands in a specified time. at 0300 at> lpr lista1 at> lpr lista2 <ctrl d> leave 1700 # jobb list can be ended with ctrl-d # this command sets a timer to 17:00 kl # in this example the print command will be executed 03:00 kl in the nite
X server applications
xhost + xprop xset xlock xwd # Control access to an X display # shows windows font properties # sets users preferences ( display, keyboard, and mouse ) # lockes the workspace # stores a screen image (window dump) in a file
Xterm
xterm sb & xkill xrefresh # xterm window with window list # shuts down the xterm window # if you get strange characters in the xterm window
xterm bg black fg yellow T Potatis& xterm geometry 132*50 10 10 & xterm sb title potatis display kudos:0.0&
Mail
dtmail & # starts the mail application in unix
If it does not showe vt100 write the lines below: TERM = vt100 export TERM setenv TERM vt100
Text Editorn Vi
There are two modes: The one is write more The second one is commando-mode (esc) where you can move around the cursor Start vi: vi file name End vi: (esc) Shift ZZ, :wq! q! Till skriv-mode: i ( insert where the cursor is placed ) a ( insert after the cursor ) Moving in the text: (esc) Arrows or page up/down Delete: (esc) x In write mode (esc) dd (esc) :1,$/olle/kalle/g u # delete one line # Replace olle with kalle everywhere in the text # Undo # exit without saving # Creates a file with name file name
insert to left of current cursor position (end with ESC) append to right of current cursor position (end with ESC) delete current word (end with ESC) change current word (end with ESC) change current character change case (upper-, lower-) of current character delete current line delete portion of current line to right of the cursor delete current character mark currrent position delete everything from the marked position to here go back to the marked position dump out at current place your last deletion (``paste'') undo the last command repeat the last command combine (``join'') next line with this one write file to disk, stay in vi quit VI, do not write file to disk, write file to disk, quit vi read in a copy of the specified file to the current buffer
search forward for string (end with Enter) search backward for string (end with Enter) repeat the last search (``next search'') replace (``substitute'') (the first) s1 in this line by s2 (lr is of form `a,b', where a and b are either explicit line numbers, or . (current line) or $ (last line)
:map k s :abb s1 s2 %
map the key k to a string of vi commands s (see below) expand the string s1 in append/insert mode to a string s2 (see below) go to the "mate," if one exists, of this parenthesis or brace or bracket (very useful for programmers!)
more /etc/vfstab
ExampleCopying All Files in a Directory to a Tape (cpio) $ cd /export/home/kryten $ ls | cpio -oc > /dev/rmt/0 ExampleListing the Files on a Tape (cpio) $ cpio -civt < /dev/rmt/0
Before Backup
/usr/sbin/shutdown y g300 System is being shutdown for backup Unmount all file system exept / and /usr # umount /export/home Check the integrity of the file system data # fsck /export/home Perform a full level backup of the /export/home file system # ufsdump 0uf /dev/rmt/0 /export/home If the bacup tape is installed on another location # ufsdump 0uf host2:/dev/rmt/0 /export/home
Creating a User
admintool & # it is possible to create and delete users and groups
Security
touch /var/adm/loginlog will be stored in to this file. who last last etxolle last reboot rusers l whoami #shows the users logged in to actuall system # shows a history list with all logins # shows information about actuall users logins # shows when the maskin has been rebooted # gives a list with all the users logged in to the remote host # shows the actuall user #Create this file to logg failed loggins to the maskin. After 5 failed atemts the login information
who am I# shows the original user /var/adm/sulog # includes information about all failed su atempts
Changing owner
chown user2 file1 chown R user2 dir1 chgrp ekonomi file1 # changes the owner to user2 for the file file1 # changes owner to user2 for the directory dir1 and including files # changes the group to ekonomi for the file1
Trusted user
Create the files below and add the name of the trusted users. They will be enabled to login with out any passwd. /etc/hosts.equiv /.rhosts
Mounting CDROM
ps ef|grep vold /etc/init.d/volmgt start cd /cdrom ls al #cehck that link has been created if not then we must mount the cdrom manually lrwxrwxrwx 1 root nobody 15 Dec 18:50 cdrom0 ->./disksuite_4_0/ /etc/init.d/volmgt stop # to stop the Volume Management deamon # check if Volume Management deamon is running # to start Volume management
eral advantages. It preserves the directory structure, the ownership, permissions, and directory hierarchy of the files it saves. IUCF has two tar programs. The HP supplied tar, and the GNU version of tar. The GNU version has one nice advantage in that it is tightly integrated with gzip and gunzip, the GNU compression programs. tar cvf /dev/rmt/ct1_cn ~ make a backup of your home directory to the compressed tape device tar cvf /tmp/myfiles.tar ~ make a backup of your home directory to the file myfiles.tar in the tmp directory tar xvf /dev/rmt/ct1_cn restore your directory from tape tar cvf /tmp/my.tar ~ create a backup of your directory to /tmp/my.tar gtar cvzf /tmp/my.tar.gz ~ create a compressed backup of your directory gtar xvzf /tmp/my.tar.gz unpack your compressed backup from the root directory When you tar files the entire path you specify on the tar command line is written before each file name in the archive. Thus when you untar the archive, the files will be placed as the path is specified on the original command line. For example, if you tar up a directory like this: dwwillia@clio: $ pwd /users2/dwwillia/Projects *** CREATE TAR FILE *** dwwillia@clio: $ tar cf scripts.tar Scripts/ dwwillia@clio: $ ls -l scripts.tar -rw-r--r-- 1 dwwillia users 10240 Jun 15 15:10 scripts.tar *** LIST CONTENTS OF TAR, PATHS ARE STORED WITH FILES *** dwwillia@clio: $ tar tf scripts.tar Scripts/ Scripts/fix.my.account *** GO TO /TMP. UNTAR FILE. IT CREATES /tmp/Scripts *** dwwillia@clio: $ cd /tmp dwwillia@clio: $ tar xvf ~/Projects/scripts.tar Scripts/ Scripts/fix.my.account 13.2 Copytape Copytape is useful when you need to duplicate a tape. You should have access to a machine with two tape units. Copy the tapes with a command like copytape /dev/rmt/ct1_h /dev/rmt/ct2_h How to add the tape drive You add a tape drive by running "mkdev tape". This asks questions about the type of tape and its configuration. If you have more than one tape drive, you may want to make one of them the "default"- all that means is that / dev/rct0 and /dev/xct0 will be linked (using "ln") to point at that tape. If you have a SCSI tape drive, but aren't sure about its configuration, you can use "sconf" on modern releases (don't use this prior to OSR5.0.5 - it existed, but could crash your system). Here's the output of "sconf -v" on one of my machines: Sdskalad0000 Sdskalad0010 Stpalad0030 Sdskalad0040 Sromalad0060 Pushing the eject button doesn't work.
First, check that no process is using the tape: fuser /dev/rStp0 If that's not the case, the tape may have been misconfigured. Run mkdev tape and be sure that it knows that this is a DAT and not a Generic. It's easy to make that mistake when running 'mkdev tape': follow the prompts carefully and press "ENTER" for the defaults until you get to the menu that askes what kind of tape it is. I did once have a DAT tape that would not eject without rebooting, but I couldn't find any reason for it, so we replaced it. I took the unit to another machine (same OS and version), and there it would eject fine, but then you couldn't put a new tape in without rebooting, so it didn't help much! tape: can't open '/dev/xct0':No such device Using "tape status" (or any "tape" command) doesn't work and complains with this message. This could simply mean that this is not your default tape drive. If you can tar cvf /dev/rStp0 . (or rStp1 if this was the second drive), but cannot do "tape" commands, then run mkdev tape again and select the default tape drive. Or for a quicker test: rm /dev/xct0 mknod /dev/xct0 c 46 128 (assuming rStp0) and then try "tape status" etc. What's happening here is the tape commands use ioctl calls to query the tape device. Ioctl commands are just special commands that a device driver can use to get information from a device. Most drivers are written to recognize a special minor number as the ioctl device; this simplifies the driver and allows any data to be written to the ordinary device. For tapes, the minor number for ioctl is 128. The ioctl devices are /dev/xct0, /dev/xStp0, etc. If you have created a SCSI tape, but didn't set it as default, then the /dev/xct0 is crw-r--r-- 1 root sys 10,128 Sep 13 10:35 /dev/xct0 which has the right minor number, but the major (10) is for a cartridge tape, not SCSI. You could fix this as suggested above, or by editing /etc/default/tape and changing the device = /dev/xct0 to device = /dev/xStp0
Various tape commands work with different types of tapes. Some tapes require formatting, some have the ability to be retensioned, some don't. You can get a list of tape commands by typing tape 2>&1 | more or man tape
A DAT tape is a DAT tape, right? If you used cpio to create a tape on System A, you should be able to read it with a different DAT on system B. Yes, but.. The first problem you can run into is hardware compression. Different manufacturers can use different schemes. Therefore, if you are planning to transfer to another system, you want compression turned off. To do that on OSR5, you'd say tape -a 0 setcomp Another area of problem is hardware block size. The defaults can vary, so you need to explicitly set it to match. To find out what the block size is, do: tape getblk (note- you may need a tape in the drive to do this!) Once you know, you can set it to match on the other machine: tape -a 0 setblk tape -a 512 setblk