Sei sulla pagina 1di 23

All fields marked (*) are mandatory and must be completed.

* * * *

Customer: Platform: System: Category:

* Status: Details:

IBM - CII, IBM - CRM UNIX - AIX ALL Systems System Management Active

Event ID: Event Class: Product:

Geography: EMEA Line of Business: IGA

(Please use native Notes wherever possible - refrain from adding attachments as these are NOT searchable.)

A VERY Brief History of UNIX........ UNIX was first developed in the late 1960s by programmers at Bell Labs (later part of AT&T). During the 1970s it was widely used in academic environments but seldom for industrial or commercial applications. In 1980 the University of California at Berkeley (who had been using UNIX for some years) released their own enhancements to the system. Development of the "Berkeley Enhancements' has proceeded in parallel with the development of the basic UNIX system by AT&T, and now UNIX System Laboratories (a separate company from AT&T). Most UNIX Operating Systems sold today consist of a mix of the original AT&T code and the "Berkeley Enhancements". UNIX has been available on IBM Systems since 1985 in the form of PC/IX and XENIX on Personal Computers and IX/370 on System/370 Mainframes. In 1986 IBM released AIX, initially on the 6150 Micro Computer System and later on Personal System/2 and System/370. AIX is different from most UNIX implementation in that IBM rewrote most of the UNIX system from scratch rather than just compiling the AT&T source code. This has allowed IBM to design a number of new features into AIX but maintain compatibility with other systems. Since 1988 many international organizations have been involved in the process of developing a standardized UNIX Operating System. This will benefit the customer who will find it easier to transfer applications and skills onto new UNIX systems. The Institute of Electrical and Electronics Engineers (IEEE) is in the process of defining a standard called IEEE 1003 POSIX, which standardizes many elements of an operating system and its supporting software. IBM has recently introduced AIX/ESA for mainframe systems to replace AIX/370. This is a version of the OSF operating system with IBM enhancements. What Is AIX Then? AIX in it's narrowest sense is a time-sharing operating system kernel, a program that controls the resources of a computer and allocates them among it's users. In it's broadest sense UNIX/AIX is often taken to include not only the operating system kernel, but also essential programs like command languages, editors, compilers and so on. It may even include programs developed by yourself or other users to be run on the system.

Another definition is that AIX is designed as a multi-user/multitasking operating system, which is specifically designed to make the user's computing environment simple, efficient, flexible and productive. All of the processing and tasks are carried out on a central machine, attached to this machine are clients, be they PCs or Terminals, they are essentially dumb, they merely act as Input/Output devices. Unlike of course Windows NT, you have a central machine to serve your network, but a lot of the work is also carried out on the Workstations. In a UNIX environment, you will normally find that the server does all the work! UNIX allows a user to initiate a task and then go on to other activities while the system continues to work on the original task. Background processing helps users to be more effective in using the system and to accomplish more work in a given period of time. Access to a UNIX server is controlled by the use of "User IDs" and passwords (optional). User IDs store information, such as users access rights (where they are allowed to go whilst on the server), privileges (What they are allowed to use), and information personal to the user (Name, Rank, Serial No, etc. in a user account. Logging On Before you can logon to anything you have to start up a window or "session" as it's called to logon with. There a couple of ways to do this and it depends on what you are using to login from. The most commonly used package for initiating a "telnet session" as it's called is SecureCRT, which you should have on your laptop. To start a session is simple, click the SecureCRT icon ( servers like so: ) and you'll either be provided with a list of

Highlight the one you wish to logon to and click "Connect" Alternatively you'll be presented with the "Quick Connect" dialog like so:

Simply type the server you wish to connect to in the "Hostname" box and click "Connect". When the session is started you will be presented with a prompt looking like this:

Exciting huh? This is standard UNIX greeting, the system is asking you to enter your User ID, these can be anything, from all numbers to all letters to a mixture of both. For example mine is "coopej". WARNING: UNIX IS VERY VERY CASE SENSITIVE, MOST COMMANDS ARE TYPED IN LOWER CASE, BUT BE WARNED IF A COMMAND YOU TYPE WON'T RUN THEN CHECK IT'S CASE FIRST!! After you've entered your User ID the system will ask you for your password, if this is the first time you are logging in your password will probably have been given to you on

a piece of paper, type it in exactly how it is written, remembering to keep the case right. The characters will not display as you type. If you got your User ID and password right the system will have logged you on, if you didn't it should have given you another go. If you get your login wrong several times in a row then the system will usually kick you off and close your connection, get it wrong enough times the system will lock your ID and you'll have to get someone to reset it for you. When you are logged on you will see the following prompt like the following: cdb01px:coopej > This is the CLI or Command Line Interface, UNIX is for the most part what's called Command Line Driven. This means that unlike Windows NT, where you can do most things with a mouse, most things in UNIX are accomplished from the command line. This means a lot of typing for the likes of you and me, but you can actually work faster in UNIX than say Windows NT because you aren't waiting for the GUI to catch up to what you are trying to do all the time. You can get a GUI for UNIX called "X Windows", but this is used less and less these days when administering UNIX systems. UNIX remember, is a multi-user system and as such is designed to service a lot of people at the same time, it is far less taxing on a processor to display a series of ASCII screens than it is to power resource hungry GUIs, that's why most of the things you will run from UNIX will take the form of ASCII interfaces. To terminate or logoff from the session you're running, you can do it in two ways, one is to type 'exit' and hit Enter, the other is a <Ctrl & d> (Hold down the CTRL key and press 'd'), the second option is more widely used as it's quicker. Okay so you know how to logon but what can you do while your logged on, well the rest of these notes will take you through some basic tasks that you'll need to able to do...... AIX Command Syntax AIX/UNIX Commands like in all Operating Systems have a particular syntax, the order and separation of the elements of a command is important. The format of any command should look like so: Command e.g. ls -l myfile Option(s) Argument(s)

The command or process name must come first, the options (which are 90% letters) should follow the command name, separated by a space and preceded by a '-' (minus sign). Multiple options may be grouped immediately after a single '-' or separated by spaces and each preceded by a '-'. Options are typically used to modify the operation of the process. The arguments follow the options, again separated by a space. The order of the arguments will depend on the command. Changing Your Password

Changing your password is the first thing to do, that is if the system hasn't already asked you to do it the first time you logon. This is really simple, at the prompt type: passwd Then hit enter, the system will ask you for your old password, and then ask for your new one, getting you to retype your new password so that you get it right and to make sure that its actually the one you want. If you are a super user (e.g root) you can also change another users password by entering "passwd <username>" The AIX File System Structure AIX like Windows uses a hierarchical file system consisting of directories that contain both files and other directories. However, a fundamental difference between Windows and UNIX is that DOS is a single user operating system. As you know by now when you login to a UNIX computer, you will be in what is called your HOME directory. Other than system administrators you should be the only person with rights to alter the contents of your HOME directory, this of course also means that you cannot alter files in other peoples HOME directories. A UNIX file system is different from most others in the fact that it treats everything in it as a file, it makes no special distinctions between files, directories or even devices, they are all counted as files, they are just labeled differently to show their nature. Every item in a UNIX File system can be defined as belonging to one of four possible types: Ordinary Files These can contain text, data, or program information. An ordinary file cannot contain another file, or directory. An ordinary file can be thought of as a onedimensional array of bytes. Directories These are containers that can hold files and other directories. A directory is actually implemented as a file, that has one line for each item contained within the directory. Each line in a directory file contains only the name of the item, and a numerical reference to the location of that item. The reference is called an 'inumber', it is an index to a table known as the 'i-list'. The i-list is a complete list of all the storage space available to the file system. Special Files These represent input/output (i/o) devices, like a tty (terminal), a disk drive, or a printer. Because UNIX treats such devices as files, a degree of compatibility can be achieved between device i/o, and ordinary file i/o, allowing for the more efficient use of software. Special Files can be either 'character special files', that deal with streams of characters and are not buffered, but are synchronous, or 'block special files', that operate on larger blocks of data, are buffered and can be asynchronous. Links

A link is a pointer to another file. Remember that a directory is nothing more than a list of names and i-numbers of files. A directory entry can be a 'hard link', in which the i-number points directly to another file. A hard link to a file is indistinguishable from the file itself. When a hard link is made, then the i-numbers of two different directory file entries point to the same inode. For that reason, hard links cannot span across file systems. A 'soft link' (or 'symbolic link') provides and indirect pointer to a file. A soft link is implemented as a directory file entry containing a pathname. Soft links are distinguishable from files, and can span across file systems. Not all versions of UNIX support soft links. A UNIX file system typically consists of one non-removable file system, known as the 'root file system', and other removable file systems. The removable file systems are attached or 'mounted' as it is more commonly know to the 'root file system'. Each file system that is mounted on a UNIX machine is accessed through its own block special file. A Brief Tour Of A UNIX File System The actual locations and names of certain system configuration files will differ under different implementations of UNIX. Here are some examples of important files and directories under AIX: /dev/ /bin/ /etc/ /lib/ /tmp/ /usr/bin/ Where special files are kept Executable system utilities, like, ls, grep, etc. System configuration files and databases Operating system and programming libraries System scratch files (all users can write here) Additional user commands

/usr/local/bin Traditional storage point for user written executables and scripts /usr/local/log Traditional storage point for common system log files Using The 'cd' Command If you have used any operating system at it's base level you will already know that the 'cd' command, stands for change directory. In UNIX the cd command works roughly the same as it does in MSDOS, however the slashes (\) in UNIX go the other way (/), so for example to change to my home directory in DOS I would type: cd \home\coopej and in UNIX, I would type: cd /home/coopej Okay, there are a couple of little things to know about the cd command and they are as follows:

cd /

Will take you to the root of your current file structure

cd Will take you your home directory, that is the directory you started in when you logged in cd .. pwd Will step you back up the directory tree one step. Will display your current path (location). (e.g. /home/coopej)

Displaying Which Service You Are On, Who's With You, What They Are Doing And For How Long. (Or In Short, The 'Who' Command Explained) To display which service you are on and who's on it with you there are a few commands that you can type. The first of these is 'who', typing who at the command prompt will give something like the following output: GB024503 dalyp GB024503 prodadm coopej pts/1 pts/2 pts/4 pts/5 pts/6 Oct Oct Oct Oct Oct 17 16 17 15 17 08:57 15:25 09:06 12:09 14:50 (dyn-9-174-165-46) (sig-9-65-29-1.mt) (dyn-9-174-165-46) (cdb01sx.megacent) (dyn-9-174-165-53)

This shows that there are 5 users logged on, it shows their name, what port/terminal they are connected to, what date and time they logged on and from what machine. For the instance of my name 'coopej', it shows that I am on psuedo terminal 6, that I logged on on the 17th of October at 14:50, from 'dyn-9-174-165-53'. There is a more detailed form of who, that enables you to tell a lot more about what the people on the system are doing. The command is 'w' (best thought of as the "who and what" command), if you type it at the prompt you get an output similar to the following: 02:52PM up 128 days, 4:13, 0.73, 0.66 User tty login@ GB024503 pts/1 08:57AM dalyp pts/2 03:25PM GB024503 pts/4 09:06AM prodadm pts/5 Wed12PM /source/xr4p4/adapt coopej pts/6 02:50PM 5 users, idle 0 12 2 2days 0 load average: 1.00, JCPU 0 1 0 148:10 0 PCPU 0 0 0 16 what -ksh sleep -ksh

0 -ksh

As you can see there is a lot more information with this output. This shows the User ID (User), the port they are on (tty), the date they logged on (if different from today's date) (login@), how long they have been idle (that is how long since they last did anything that used CPU) (idle), how much processor time they have used up (JCPU,PCPU) and what command or program they last ran or are running (what). As you can see from this I (coopej) logged on at 14:50, I have been idle 0 minutes because I just entered a command, I've used no processor time, because it's a small command and doesn't register and what I'm currently running is just my korn shell which shows as "-ksh". The top line in a 'w' command shows the current time, the server up time, how many users and the system load average.

To find out what your username is at any time merely type "whoami" and that will tell you. There is another command that is useful in determining where you are the command is 'hostname', if you type this at a prompt you will be told the name of the server you are on. Using The 'ls' Command The 'ls' command, otherwise known as the list command, is used to list all of the files in a directory. The usage is simple. If you type 'ls' you will get an output like so: 8forbek 8howea 9heatcj brierls time.change.test dsmsup1 gregosl grintel guest jamesbg kadrit lost+found nastip success.message temp time.change

This as you can see displays all the files in a directory, roughly 4 to a line. You can also display the files in what's known as long format, this is done by typing 'ls -l', this will display something like this: drwx-----drwxr-xr-x drwx-----drwx------rw-r--r-drwx------rwxrwxrwx -rwxrwxrwx drwx-----drwx-----drwxr-xr-x 2 3 3 2 1 2 1 1 3 2 4 patelms richad sayerst sherlod root temp root root via2786 weatham wildep staff staff staff staff system staff system system staff staff staff 512 512 512 512 563 512 806 170 512 512 512 04 06 06 06 05 06 22 05 09 10 07 Jun May May May Mar May Oct Mar May Jun May 08:03 18:18 20:52 18:18 1996 18:18 1996 1996 08:47 14:18 10:10 patelms richad sayerst sherlod success. temp time.cha time.cha via2786 weatham wildep

This displays the files permission (see later), the number of links to the file, User ID of the owner of the file, the group the file belongs to, the size in bytes, the time and date it was created or last modified and the filename. Some other options if the "ls" command are as follows: -a -t Lists all hidden files, that is files that begin with a "." Lists the files in chronological order with the latest file first.

-r Lists the files in reverse order, (i.e. -rt, would list the files in reverse chronological order) Pipes And The 'pg' and 'more' Commands You can also make either of the above commands display information a screenfull at a time by adding what is known as a piped command onto the end of the 'ls' command. This is done like so 'ls -l | pg', the '|' character is known as a pipe, in this instance it will pipe the output of the 'ls' command into the input of the 'pg' command. The result

is that the information is displayed one screenfull at a time ,and then the system waits for the user to press the space bar before displaying the next screenfull. You can place as many pipes on a single command line as you like within reason, the output from the previous command will always be passed to the input of the next one. Learning to string commands together using the pipe command is a very useful skill in UNIX, it can help greatly to find the information you need from the vast amount available on any system. You can also use the 'pg' command on it's own by typing 'pg <filename>' this will display the file a screenfull at a time. Another command in the same mold as 'pg' is the 'more' command. This is more useful than pg as the file being mored can be navigated both up and down as opposed to only down with pg. You can also search in a file that has been mored. To use more you can either put it on the end of a command and pipe into it like so: ps -ef | more -N Alternatively you can just specify the file: more -N hello.txt The "-N" argument stops more from calculating line numbers for files it is working on. In large files this can be very useful, to prevent the command from pausing when moving around. Cancelling A Running Command Most UNIX commands can be stopped from running after you start them, this is most useful especially if a command takes a long time to run. Say for example you do an "ls -l" command in a directory only to find out that the list goes on for screenfuls and screenfuls with no end in sight. The command can be stopped by holding down the Control (Ctrl) key and then typing "c". The command will then stop when the system gets around to processing your keyboard input and you will presented with the prompt again How To Use The 'grep' Function This is probably one of the most useful tools in UNIX and it's applications are virtually limitless, the definition of 'grep' in the manuals is that it 'searches a file for a pattern'. However it can be used for a lot more than this, it can be used to filter output from commands, input to commands, printers, devices of all sorts and just make the job of sifting through all the information on a UNIX system easier. Grep is normally used as a piped command to filter the output from other commands, for example if I perform a 'w' command I get an output something like this: 03:02PM up 128 days, 4:23, 0.64, 0.64 User tty login@ GB024503 pts/1 08:57AM dalyp pts/2 03:25PM 5 users, idle 0 7 load average: 0.68, JCPU 0 1 PCPU what 0 -ksh 0 sleep

GB024503 pts/4 prodadm pts/5 /source/xr4p4/adapt coopej pts/6

09:06AM Wed12PM 02:50PM

3 2days 0

0 148:37 0

0 -ksh 16 0 -ksh

However if I wanted I could pipe the command through 'grep' and specify that I only wanted to search for my user name (coopej8), I would do it like so: w | grep coopej I would then get the following output: coopej pts/6 02:50PM 0 0 0 -ksh

This is because 'grep' has filtered the output, and displayed only the lines where 'coopej' appears. It doesn't matter where the text you tell 'grep' to search for is, it can be anywhere in a file or the input/output of a command, a 'grep' statement like the one above will only display the lines where the search string appears somewhere in that line. As you can see this is most useful on systems where you have a lot of users logged on at any one time, you can find information on the one you want without having to search screenfulls of information. You can also apply options to 'grep' to get it to perform different functions, here are a few of the most commonly used: -v -c -l Displays all lines but those specified in the search string. Counts the instances of a search string. Print the names of the files which have the search string in them

-w Searches for whole words of a search string. For example if a file called 'cat.txt' had these line in it: The cat sat upon the mat The cat was on the mat If you did the following command 'grep -w on cat.txt' then the following would be returned: The cat was on the mat Although 'upon' does contain 'on', it is part of a word not a whole one so the line was not returned. If you are searching a file for a search string, the grep command must take the following format: grep option(s) "string" filename

For example to search a file for the word 'and' then display all the lines that didn't have it on, you would do the following: grep -v and myfile Grep can do a whole lot more than is written here, feel free to play with it, it is non damaging to the file system, so you can experiment to your hearts content.

Using The 'find' Command Sometimes when using UNIX (especially in large file systems), you will want to find a file but you won't know where it is?......The way to find it is using the 'find' command. The find command is used to search the current file system for files with certain names and then list the names found. For example: find . -name sum Would find all the files named 'sum' (because you have specified the '-name' option), starting from the current directory and going down the tree, because you have used the '.' option. In UNIX a '.' means the current directory/path. This might give you output something like this: ./colour/sum ./shape/sum This indicates that there are 2 files called sum, one in the sub-directory called 'colour' and one in 'shape', both of these are sub-directories of the current directory, the '.' at the start of the path tells you this. If you wanted the search above to start from the root directory of the current file system, you would replace, the '.' with a '/', this tells find to start from the root and work down. You can also execute commands on the files that you find like so: find / -name sum -exec ls -l {} \;

You would get an output similar to this: -rwx------rwxr-xr-x 2 patelms 3 richad staff staff 512 04 Jun 08:03 /shape/sum 512 06 May 18:18 /colour/sum

The find command has searched for all the files with the name 'sum' found them and then executed the 'ls -l' command on them, the '{}' tells find to replace this with the filename found, the ';' is used to escape or end the execution of a command, they can be used as command separators to string together a series of commands on one command line, like so: cd /usr/coopej8; ls -l |more; cd / Find has a few other options that can be used these are as follows: -type f d +n -n +x -x Ordinary file Directory Larger than 'n' blocks Smaller than 'n' blocks Modified more than 'x' days ago Modified less than 'x' days ago

-size

-mtime

Please feel free to experiment with find as much as you like.

Using The 'tail' Command Tail is a useful command to use when you only want to look at the last few lines of a file. For example if you change to the "/usr/local/log" directory on any machine, in there you will find any number of logs, if you wanted to look at the last ten lines of any of them you would type the following: tail <some.log> This will show you the last ten lines of the file. If you wanted to see the last 20 lines of the file you would type the following: tail -20 <some.log> Probably the most useful thing the tail command can do is show you updates to a file as they happen, this is done by issuing the following command: tail -f <some.log> This will update as each new line added to the file you are tailing but I think you get the idea. There is also a command called "head", play with it to figure out what it does. Using the 'cat' command The 'cat' command stands for 'concatenate and print' this tells unix to take all of the file(s) you have specified, collect all the contents together and display it up the screen. For example: cat trapd* Would take all the files in the current directory that began with "trapd", collect them all together into one big temporary file and print them to the screen....which would take ages. Using The Visual Editor (vi) The first application of UNIX back in 1970 was a document preparation system for Bell Labs patent department. It's not very surprising then to find that UNIX is packed with a whole host of text processing tools. The most widely used text editor (or processor as some people prefer to call it) is 'vi', now you either hate or love vi, there is no inbetween. Which ever way you feel about it, it is still the most efficient way of editing text, displaying documents and creating text files that there is under UNIX, also because it's user interface is so outwardly simple its easy to get to grips with, but takes ages to master. What follows will be a sort of survival guide to vi. You can invoke vi in two ways, one is just by typing 'vi' at the command line, the other is to type: vi <filename>

If the filename exists, vi will load the file and display it, if it doesn't vi will create a blank file for you to work with. Below is an example screen of vi, I typed 'vi .profile' from my home directory to edit my user profile, this is the screen I was presented with: PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:. export PATH if [ -s "$MAIL" ] then echo "$MAILMSG" fi # This is at Shell startup. In normal # operation, the Shell checks # periodically.

set -o vi ~ ~ ~ ~ ".profile" 11 lines, 265 characters The bottom line on the screen is the status line. Here vi is telling us that the file being edited is '.profile', that it is 11 lines long and contains 256 characters. The tildas (~), down the left hand side indicate that the file is empty at this point, i.e. that it has nothing in it after the 'set -o vi' line. The way to get the command prompt up in vi is to type a colon (:), I find that the best way to do this is to quickly hit the Escape key, to make sure you are out of any editing mode and then type a colon (:), this will change the bottom line of the screen to a colon and position the cursor there, vi is now waiting for input. The first thing to do if you are new to vi is to type 'set showmode' on the vi command line. So type ':' and then 'set showmode' and hit return. Vi is a modal editor, this means that it operates in a number of different modes. The most important modes are 'command mode' and 'input mode'. In command mode you can move the cursor around using the arrow keys. When you first enter vi you are placed in command mode. Showmode is one of several options which you turn on or off from within vi by using the set command. When you 'set showmode', you are asking vi to give you a visual reminder of which mode you are currently in. Typing ':' and then 'set nu' will turn on line number mode, placing line numbers to the left of the text. You can set up a series of modes within one file while editing, but the modes are not saved when the file is written to disk. To add some text to the file above you could use the 'i' (insert before cursor) or 'a' (append after cursor) commands. In either case, end insert mode by pressing the Escape key. Have you entered some text?.......really.......right okay then. Whilst you were typing did you notice the 'INPUT MODE' in the bottom right hand corner of the screen?. That's what the showmode option does. Also try the 'nu' option and see what happens. When you are entering continuous text, you will probably want to set the 'wrapmargin' option as well. This defines a right-hand margin for the automatic wrap-around of text. Type ':' and then 'set wrapmargin=15'. You can abbreviate wrapmargin to 'wm' if you like. While you are in input mode you can correct typing mistakes by using the erase key 'Ctrl & h' or 'Backspace' to backup over the last character typed, 'Ctrl & w' to back up to the last word and the line kill key '@' or 'Ctrl & x' to back up to the beginning of the line.

In command mode you can use the following commands: x dd D r xp cw ~ G PgUp PgDwn Deletes the character at the cursor position Deletes the current line Deletes from the cursor to the end of the line Replaces a single character at the current cursor position Transposes adjacent characters Replaces a complete word (3cw replaces three words) Changes from lower to upper case (or vice versa). Goto last line in file (1G first line in file) Move down a page (Weird) Move up a page

/[string] Searches for the specified string from the cursor position down. To repeat the search just do a "/". [no]Y p P Copys [no] of lines below the cursor Puts back copied lines after the cursor Puts back copied lines before the cursor

Finally how do you save a file, or quit vi without saving a file, the following commands show you how to do this (remember to bring up the ':' prompt): w q wq q! Save the file Quit vi Save the file and quit Quit without saving your file

NOTE: vi is a sophisticated editor with a huge and complex command set. What is presented here is only the bare minimum of the commands available. To attain segment 1 however, I would expect you to be able to load a file, create a new file, insert and delete text and then save the file and exit vi. The "set -o vi" Command In the profile above you saw that one of the lines was "set -o vi", this is a fairly useful command. You either put it in your profile (like above) or you just type it on the command line whilst working. It basically gives you some helping hands. For example if you type a long command line and get one character wrong you would be annoyed at

having to type the whole command all over again. If you do the "set -o vi" command now, or if you have done it earlier, you can press ESCAPE and then the "k" key to cycle through previous commands you have typed. These are stored in you ".sh_history" file in your home directory or the home directory of the user you are at that time. When the command you want appears you can use the "h" and "l" keys to move left and right on the command line and then standard vi editing commands such as "x", "r", etc can be used to correct the command line before you press RETURN. You can also just use this command to quickly repeat previous commands of course. Creating And Removing Files In UNIX you can - like in all operating systems - create and remove files. You've already been shown how to do this using vi, but you can also create empty files from the command line, by using the '>' character or redirected output character. For example to create a blank file, all you have to do is type the following: > <filename> That will create a file of the name you specify, this file will be totally empty, and you can then do what you like with it, alternatively you can use the command "touch" and a filename to do the same thing. To remove a file you merely use the 'rm' command like so: rm <filename> You can use wildcards or the asterisk (*) to delete groups of files with roughly the same name for example: rm jac* rm *.dat rm mydir/* mydir/.* would remove all the files that began with jac would remove all the files with a '.dat' extension would remove all the files in the directory "mydir"

NOTE: Be very careful using this command it is probably the most dangerous of all of the basic UNIX commands, you can virtually destroy a UNIX filesystem in 7 characters if you use this command incorrectly ( and no, I'm not going to tell you how!). Try to avoid using wildcards (*) with the 'rm' command and make sure that you know what you want to delete and where it is. Creating A Directory To create a directory is fairly simple, you can create a directory anywhere on the filesystem, now matter where you are. You don't have to be in the directory that you wish to create a new one in, but I'll leave that up to you to figure out. For now, change to your home directory using "cd" and create a directory called "test" like so: mkdir test The "mkdir" command stands for make directory and to use it is fairly simple as the above example shows

Removing A Directory To remove a directory is just as easy, again switch to your home directory and type: rmdir test The "rmdir" command stands for remove directory and is also fairly simple to use. Some implementations of UNIX won't let you remove a directory unless you have cleared all the files out of it first by using the "rm" command. Copying a file To copy a file in UNIX use the "cp" command like so cp [path\source file] [path\destination file] For example: cp /usr/OV/log/trapd.log /tmp/traptest.log to a file called traptest.log in the tmp directory. cp /tmp/timer.log . to the current directory keeping the name the same. would copy the trapd.log file would copy the timer.log file

If you leave off a destination filename, then the file will have the same name when copied to a different directory, however you cannot leave off a destination directory as the command will not run. Moving a file Moving a file is very similar to copying one, however it will delete the source file and then create the destination one. The command to move is "mv", the syntax is exactly the same as the copy command above. Be wary when using the move command, if the destination you are copying to does not have enough space for the file you are moving you will lose the file. Running SMIT SMIT is the System Management Interface Tool for AIX, if you type 'smit' at a command prompt you will get a graphical interface (if possible), or typing 'smitty' will give you a text interface for if you are working on and X terminal. SMIT is an interactive interface application designed to simplify system management tasks. It Displays a hierarchy of menus that lead to interactive dialogues. If you type 'smitty' you'll get a screen like this: System Management Move cursor to desired item and press Enter. Software Installation and Maintenance Software License Management Devices

System Storage Management (Physical & Logical Storage) Security & Users Communications Applications and Services Print Spooling Problem Determination Performance & Resource Scheduling System Environments Processes & Subsystems Applications Using SMIT (information only)

F1=Help F9=Shell

F2=Refresh F10=Exit

F3=Cancel Enter=Do

F8=Image

The sections on the menu really speak for themselves, be careful when using SMIT because it does let you at the bare bones of the operating system and you can do a large amount of damage with it. Bascially don't change anything until someone says you can!! How To Use FTP File Transfer Protocol (FTP), allows a person to transfer files between two computers. For this example I'll show you how to FTP files to and from an AIX servers, say that you have created a file called 'info.txt' and you want to send it to somebody using Lotus Notes. You can't do it whilst it's on an AIX server so you have to get it across to your Laptop. I'll explain how to do it from a Windows command prompt (although most people use an FTP GUI, it's useful to know how to do it manually as well), the basics of FTP are the same where ever you go, so what I'm about to describe should work okay on most systems and platforms. 1. Bring up a Windows Command Prompt 2. Type 'ftp' and then the machine name you wish to connect to. (e.g. ftp cdb01px or ftp c06p1app011) 3. When you are connected to the machine it will ask you for your User ID and password, these are exactly the same as you would use to login to either server. 4. You will end up with a prompt like this: 'ftp>' Now you have logged in you will have to find the file you want, assume you know that it is in the '/usr/local/log' directory so you have to change to that directory. This is done using the 'cd' command exactly as you normally would, like this: cd /usr/local/log Okay, so you are in the directory where the file is on the remote machine, but where is the file going to go on your machine when you bring it across?. You can decide this by using the local change directory command or 'lcd'. This changes the destination directory of any files FTP'd across to your machine, so for this example we'll place our file in the 'temp' directory of our laptop, to do this we type: lcd /temp You should get a response something like this:

Local directory now C:\temp ftp> This tells you any files you FTP across will now go into your 'C:\temp' directory. Now you have to get the file you want, this is simply done by typing 'get' and then the filename, like this: get info.txt You should see something similar to this on the screen: 200 PORT command successful. 150 Opening data connection for info.txt (512 bytes) 226 Transfer complete. ftp> The length of time taken to transfer a copy of the file to your machine is dependant on the size, bear this in mind when FTP'ing large files. You will now have the file on your local machine and you can do what you like with it. If you wanted to transfer a file from your local machine to the server you would use the 'put' command. The syntax is exactly the same as the 'get' command but it goes the other way, placing a file onto the remote machine from your local machine. If you wanted to 'get' or 'put' multiple files, you would have to use the 'mget' and 'mput' commands, these can be used with wildcards, like so: mget trapd* mput *.txt These commands would get all the files beginning with 'trapd' and would put all the files with a '.txt' extension. Both commands will prompt you to say yes or know to each file that meets the criteria, if you want to transfer files without being prompted for each one enter "prompt" on the FPT command line to turn the option on or off. To end an FTP session, type 'close', this will log you off from the server but will leave you still running FTP, to exit FTP, type 'quit'. If after typing close you wanted to connect to another server you could type 'open' and then the server name to start another connection. One final thing most FTP programs are intelligent these days, but some aren't, you can have to specify whether or not you were transferring a binary file (program, executable, datafile, etc.) or an ASCII file (text, letter, etc.), this was done as follows: bin asc Set type to binary Set type to ASCII

The guideline on this is, if you aren't sure whether or not the FTP program auto detects, or you want to lock the FTP session into one of these modes then use one of the options above. Understanding The Use Of The 'su' Command

The 'su' command stands for switch user, and is used to access another user ID without having to logout out and log back in. Using the 'su' command is the only way in which you can become the 'root' user on an AIX/UNIX system as you a not allowed to login as root from and external source, you have to first login as yourself and then switch user to root. The 'su' commands has two "modes", these are 'su' and 'su (minus)', and they both work in a different way. To switch user to root from you own ID you could type: su root This would prompt you for the root password, and if you typed it in correctly would log you in as root. This would mean that you would have all of root's groups and permissions on the system, but you would keep all of your directory mappings and aliases, basically the straight "su" command logs you in as root without running root's login script. If you were to use the "su -" command like so: su - coopej This would again prompt you for my password, and if you typed it in correctly would, log you in as me, but this time it would run my login script and give all my aliases and directory path settings to you. Try it and see what I mean. The 'chmod' Command And File Permissions/Attributes The chmod command is used to change the attributes/permissions of a file, to make it readable, writeable, executable or a combination of those three. If you do an 'ls -l' command, you will see this (or something similar):
-rwxrwxrwx -rwxrwxrwx drwx-----1 root 1 root 3 via2786 system system staff 806 22 Oct 1996 time.change 170 05 Mar 1996 time.change.test 512 09 May 08:47 via2786

The first 10 characters on the line are the file attribute/permission flags. You can tell the nature of a file by just a glance at these: Special Char d

| | |

User rwx 421

| | |

Group rwx 421

| | |

Other rwx 421

The first character is a special character, this can be a few things, mostly this will be a 'd' or a blank, a 'd' in this space denotes that this is a directory, a 'b' denotes that it is a block device and an 'l' means that it is a link. UNIX treats all directories as files, into which it stores, other files and directories. The letters then split into groups of three, these denote your privileges (the current user), your groups privileges and everybody else's privileges. This are abbreviated as 'u', 'g' and 'o'. The three letters underneath each of the last three titles represent readable (r), writeable (w) and executable (x) respectively. They also correspond to the numbers 4,2 and 1. You can change the permissions on a file by using the numbers or the letters, for example if you wanted to make the file executable to you only, you could do the following: chmod u+x myfile

This would make the file executable to you, the user, but not your group or other users. On the other hand to make the file executable to all groups you would do it this way: chmod ugo+x myfile

This would make the file executable to everybody. The numbers work by adding them together, for example if you wanted to perform the above two commands using numbers instead of letters to set the privileges, you would do it as follows: chmod 766 myfile chmod 111 myfile Makes the file permissions -rwxrw-rwMakes the file permissions -rwx--x--x

Remember that you also have to take into account any permissions which already exist on the file. To make the file, readable, writeable and executable by everybody, then you add the numbers together to make 7, the command line would be: chmod 777 myfile If this isn't very clear don't worry, it isn't the first time you hear it, just create a blank file using 'vi' (or from the command line) then play with it's attributes using chmod. Never change the attributes of files when you aren't sure what the file is for.... The "rwx" permissions on a directory have a different meaning to those on a file, they are: r w x Can see what files are in the directory Can create/move files in the dir Has permission to be in the directory

Changing File Ownership With The 'chown' Command The 'chmod' command allows you to set the permissions on a file or directory, however the 'chown' command allows you to change the ownership properties for user and group on files. To change just the owner property of a file you just type: chown <userid> <file> e.g. chown coopej .profile To change both the owner and the group property of a file you type the following: chown <userid>:<group> <file> e.g. chown coopej:staff .profile You cannot just change the group property of a file using the 'chown' command you have to specify both owner and group to be able to change the group with this command. To change just the group use the 'chgrp' command. Compressing And Uncompressing Files

AIX has built in commands to allow you compress and uncompress large files to decrease usage in filesystems and make file transmission easier and storage of old files more efficient. To compress a file you merely do the following: compress <filename> e.g. compress hello.txt In the example above the file "hello.txt" would be removed and new compressed version of it would be created with a ".Z" extension, so it would become "hello.txt.Z". The ".Z" extension is the easiest way to tell if a file is compressed as UNIX adds this to all compressed files. Compression is a hit and miss affair sometimes, files are compressed using an algorithm that looks for repeating patterns in a file and substitutes these with smaller values whilst keeping a record of the originals. These algorithms work very well on text files where patterns are liable to be repeated over and over again. However compression is usually poor at reducing the size of binary files such as executables due to their nature of already being compressed in some way. So do not be alarmed if compressing a file does not necessarily reduce it's size. Whilst a file is compressed you cannot view it using standard AIX commands such as 'more' and 'cat', to be able to view it you have to use a special command called 'zcat' which can view compressed files as if they were uncompressed. To uncompress a file, unsurprisingly enough you do the following: uncompress <filename> e.g. uncompress hello.txt.Z In the example above the file "hello.txt.Z" would be removed and new uncompressed version of it would be created without a ".Z" extension, so it would become "hello.txt" again. Be aware that when uncompressing the file the resulting one will be larger than the compressed version, so be way when uncompressing a file and make sure that you have enough to space to do so. I'm speaking in general terms in this case as you don't know how big a compressed file will be until you uncompress it. Creating And Extracting File Archives Using 'tar' To create or extract file archives in UNIX you use the 'tar' command which is similar in theory and operation to the 'zip' command used in Windows. For example to create an archive of all the files in the /tmp directory on a system including subdirs and files type the following: cd /tmp tar -cvf tmp.tar * It is important to specify the files to wish to archive correctly. This can be done as above by changing to the directory where you wish to start and specifying a wildcard (*) for all the files you wish to archive, or explicitly on the tar command line stating the destination archive and the input files.

Again the same care must be taken when extracting a tar file, the most normal way extract from a tar file is as follows: tar -xvf tmp.tar That would extract the tmp.tar file and assuming it is in the same directory as you were when you ran the command, will create the files and directories from the archive from your current location downwards, overwriting any files it finds with the same name, if you have permission to do so. You can also list all the names of the files in a tar archive without extracting by using the following command: tar -vtf tmp.tar This would give an output like so: drwxr-xr-x 0 0 drwxr-xr-x 0 0 drwxrwxrwx 1002 234 -rw-r--r-0 0 -rw-r--r-0 0 drwxr-xr-x 0 0 drwxr-xr-x 0 0 -rw-r--r-0 0 -rw-r--r-0 0 -rw-r--r-0 0 -rw-r--r-0 0 assignments.106304 -rw-r--r-0 0 0 Nov 18 09:46:53 2002 DSmsia/ 0 Sep 02 02:00:44 2003 ESS_cfg/ 0 Oct 23 14:05:45 2002 SQLDIR.LK0/ 2364 Oct 17 06:00:04 2003 all_users 59 Oct 17 07:31:26 2003 bklog 0 Oct 23 14:34:34 2002 bos/ 0 Oct 23 14:34:34 2002 bos/oldvgs/ 351 Oct 15 14:25:20 2003 bos/oldvgs/.oldvgs 355 Oct 14 22:26:06 2003 chkpasswd.tmp 26 Sep 15 14:06:42 2003 datapath.log 173 Oct 12 04:00:01 2003 dpo-hdisk6 Oct 10 11:36:24 2003 efixcheck.PID

Meaning that you can see the permissions, size and timestamp on the file at the time it was archived. You can then extract individual files from the archive once you know exactly what the file is called by specifying the filenames at the end of the extract command like so: tar -xvf tmp.tar efixcheck.PID There are many more options to tar, but these cover the basics and should get you started using this command.

Created by Simon Lloyd Williams on 24/10/2003 at 15:41

Potrebbero piacerti anche