whatis unix
TRANSCRIPT
-
7/28/2019 Whatis UNIX
1/10
What is Unix ?
The UNIX operating system is a set of programs that act as a link between the computer and the user.
The computer programs that allocate the system resources and coordinate all the details of the computer's internals is called theoperating system or kernel.
Users communicate with the kernel through a program known as the shell. The shell is a command line interpreter; it translatescommands entered by the user and converts them into a language that is understood by the kernel.
Unix was originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis
Ritchie, Douglas McIlroy, and Joe Ossanna.
There are various Unix variants available in the market. Solaris Unix, AIX, UP Unix and BSD are few examples. Linux is
also a flavour of Unix which is freely available.
Several people can use a UNIX computer at the same time; hence UNIX is called a multiuser system.
A user can also run multiple programs at the same time; hence UNIX is called multitasking.
Unix Architecture:
Here is a basic block diagram of a UNIX system:
The main concept that unites all versions of UNIX is the following four basics:
Kernel: The kernel is the heart of the operating system. It interacts with hardware and most of the tasks like memorymanagement, tash scheduling and file management.
-
7/28/2019 Whatis UNIX
2/10
Shell: The shell is the utility that processes your requests. When you type in a command at your terminal, the shell
interprets the command and calls the program that you want. The shell uses standard syntax for all commands. C Shell,
Bourne Shell and Korn Shell are most famous shells which are available with most of the Unix variants.
Commands and Utilities: There are various command and utilities which you would use in your day to day activities.
cp, mv, cat and grep etc. are few examples of commands and utilities. There are over 250 standard commands plus
numerous others provided through 3rd party software. All the commands come along with various optional options.
Files and Directories: All data in UNIX is organized into files. All files are organized into directories. These directories
are organized into a tree-like structure called the filesystem.
System Bootup:
If you have a computer which has UNIX operating system installed on it, then you simply need to turn on its power to make it live.
As soon as you turn on the power, system starts booting up and finally it prompts you to log into the system, which is an activity tolog into the system and use it for your day to day activities.
Whatis UNIX
UNIX is a so called operating system for workstations and has mainly ben developped at
Berkley University (BDS-UNIX). One of the striking difference between UNIX ans many
other operating systems is, that it has been a multiuser and multiprocess environment from
the very beginning. Multiprocess / multiuser means that different tasks can be run on the
same system by different people with different priviliges at the same time.
The system used by SGI is a derivate from the original UNIX, a so called dialect, named
IRIX.
Filesystem
The following commands are all crucial for navigating in the structure of the filetree. Unlike
other systems, in UNIX a filesystem cannot only incorporate files and directorys that are
stored locally on the hard drive. It can also merge (shared) drives on other systems (hosts) or
external devices like tape drives or printers, keyboards etc.
Navigation
ls ls [-RadLCxmlnogrtucpFbqisf1AM] [names]
Lists the content of a directory
ls -ls List in short form
ls -la All files (including .-files)
ls ./mydir List content of mydir
pwd pwd
Print working directory name
Pwd
cd cd [ directory ]
-
7/28/2019 Whatis UNIX
3/10
Change working directory
cd Change to home directory
cd ~ Change to home directory
cd .. Change to parent directory
cd /usr/lib Change to absolute path /usr/lib
cd doc/letters Change to relative path doc/letters
du du [-sarklmL] [name . . .]
Summarize disk usage
du -k Show disk usage in kblocks (1024 bytes)
du -ks * Summarize all directorys (*) and show as kblocks
df df [-b][-f][-i][-k][-l][file-system ...]
Report number of free disk blocks. Shows usage of disks. Usefull to find out if
there is enough room to save / copy a project or file.df -k Display disk usage in kblocks
mount mount
mount [ -h host ] [ -fnrv ]
mount [ -cfnrv ] [ -o options ] fsname | dir
Mount and dismount file systems. Shows mounted disks. External disks are
preceeded by their hostname.
mount Show mounted disks
Modifying
cp cp [ -irp ] file1 [file2 ...] target
Copy files or directory structures
cp file1 file2 Creates a copy of file1, named file2
cp old* archive/ Creates a copy of all files starting
with "old" into the directory archive
cp -R letters archive/. Creates a copy of all files under
"letters" and puts them into "archive"
ln ln [ -sif ] file1 [file2 ...] target
Link files. Links are like pointers that "point" to the original location of the file.
They thus, use less diskspace.
ln -s /serve/sgi/tools ~/SGItools symbolic link to /serve/sgi
in your homedirectory
mv mv [ -if ] file1 [file2 ...] target
Moves files to another location or rename them.
mv file1 file2 Renames file1, to file2
-
7/28/2019 Whatis UNIX
4/10
mv old* archive/ Moves all files starting with "old"
into the directory "archive"
rm rm [-f] [-i] file
Remove filesrm file1 file2 Removes file1 and file2
rm old* Removes all files starting with "old"
rm -r unused/* Removes all files recursively that
are under "unused"
mkdir mkdir [-m mode] [-p] dirname
Make directories
mkdir newthings Creates a directory named "newthings"
rmdir rmdir [-p] [-s] dirname
Removes an empty directory. If the directory is not empty, it will not be
removed.
rmdir oldstuff Removes a directory named "oldstuff"
Permissions
chmod chmod [-R] mode file
chmod [-R] [ugoa]{+|-|=}[rwxstl] file
Change the permissions of a file or directory. To do so, you have to be the
owner of the file or directory. The permissions are coded into a 6-digit booleanstring.
Permissions are coded into a 6-digit boolean string with the
values 1,2,4 according to their byte-positions:
rwxrwxrwx 1200 guest testfile
^^^ Owner rights: read write
execute
^^^ Group rights: read write
execute
^^^ Others: read write
execute
^^^^ Group ID of the file/dir^^^^^ Owner ID of the file/dir
^^^^^^^^^ Name of the file
To compose a full permission number, add the according bits to
a
3-digit number according to owner-group-other:
rwxrwxrwx
421421421
chmod 644 owner:rw group:r other:r (typical dir)
chmod 755 owner.rwx group:rx other:rx (typical file)
File archiving / compression
-
7/28/2019 Whatis UNIX
5/10
tar tar key [directory] [tapefile] [blocksize] [ name ... ]
Tape archiver. Writes a single archive-file from a set of files. Tar is often used
to either backup data or move complete directory-structures around. Tar
usually adresses a tape device, can thoug, be rerouted with the f option to
write to a file.
tar cvf arch.tar docs/* Creates a file named arch.tar with
anything under docs/
tar xvf move.tar Explodes transport.tar and creates
all the directories that have been
packed into the tar file.
compress compress [ -f ] [ -v ] [ -c ] [ -b bits ] [ name ... ]
Compress data. Results will be stored into a file with the suffix .Z
compress oldfile.txt Will result in oldfile.txt.Z
compress * Will compress every file in the
directory
uncompress uncompress [ -f ] [ -v ] [ -c ] [ name ... ]
Expand data with the .Z suffix
uncompress oldfile.txt.Z Will result in oldfile.txt
uncompress * Will decompress every .Z file
in the directory
gzip gzip [ -acdfhlLnNrtvV19 ] [-S suffix] [ name ... ]
gunzip [ -acfhlLnNrtvV ] [-S suffix] [ name ... ]Compress or expand files. Same as 'compress' but with a more efficient
algorithm.
gzip oldfile.txt Compress oldfile.txt to oldfile.txt.gz
gzip -d oldfile.txt.gz Decompress oldfile.txt.gz to
oldfile.txt
Helpers, alias and communication commands
The commands below will help you to identify your command shell environment. You can
lookup the current user, find out about what command will be executed when you type
something and last, lookup the versions of installed programms. Helpers
who who [-uTlHqpdbrtas] [ file ]
who am i
Who is on the system, who owns the current shell?
who Show all logged users (optional -u)
who am i Displays the user of the current shell
man man [-cdwWtpr] [-M path] [-T macropackage] [section] titleman [-M path] -k keyword
-
7/28/2019 Whatis UNIX
6/10
Print entries from the on-line reference manuals; find manual entries by
keyword
man cp Will show the manpage for the copy ('cp')
command
man -k tape Will search for all helppages, in which thekeyword 'tape' appears
man man ... if ever you have forgotten how to use 'man'
apropos apropos keyword
Locate commands by keyword lookup
apropos netscape Returns: 'The premier World Wide Web
browser'
Command interpretationalias INTERNAL SHELL COMMAND
Creates an alias for a string. Useful if you want to create your own shell
commands. 'alias' will simply list all your defined aliases.
alias ll 'ls -la' Will create a command 'll' that executes
'ls -la' when you punch 'll'
alias zipall 'gzip *' 'zipall' will gzip all files in the
current directory
which which [-a] [-f] [name...]
Locate a program file including aliases and path (csh only!) Searches thecommand aliases and your binaries-path for the command that would have been
executed if you had entered the requested string. Sometimes, you think that a
command should be executed, but it is not. Then it is often useful to check your
aliases with 'which'.
which ll Will tell you that 'll' is aliased to 'ls -la'
(if defined like above)
which acad12 tells you that /serve/sgi/acad12.sh will
execute
Processesps ps [ options ]
Report process status
ps List all active processes
ps -al List all processes in long format
ps -aledf List all processes in long format with
additional information
top top [ -i interval ] [ -D fullpathname ]
Display processes having highest CPU usage. If your workstation seems to be
very slow it is often due to a running process. You can identify it using 'top' andclose the application that causes the load. If the process is not yours, you will
-
7/28/2019 Whatis UNIX
7/10
have to ask either the owner of a superuser to shut down that process for you.
top Updates every 5 seconds
top -i1 Updates every second
kill kill [-signal] pidTerminate a process by default. To do so, you need the PID (process ID). You
can get that, using either the 'ps' or the 'top' command.
kill 42310 Kills the process with the number 42310 if
yours
kill -INT 42310 Sends the process 42310 the INT signal (ctrl-
c)
Communication
login login [ -d device ] [ name [ environ ... ]]
Sign on. Changes the owner of the current shell or logs you into a systemlogin
rlogin rlogin rhost [ -l username ] [ -ec ] [ -8 ] [ -L ]
rlogin username@rhost [ -ec ] [ -8 ] [ -L ]
Remote login. Calls a remote server and logs you in under the specified
username
rlogin spielberg Connect to spielberg as current
user
rlogin spielberg -l scully Connect to 'spielberg' as user
'scully'rlogin scully@spielberg Same as above
ftp ftp [ -v ] [ -d ] [ -i ] [ -n ] [ -g ] [ host ]
Internet file transfer program. One of the oldes ways of moving data from one
server to another. Ftp also allows you to create and remove directorys remotely.
Be careful when using mput/mget. Files with the same name will be
overwritten without asking!
ftp spielberg Opens a ftp connection to spielberg
For ftp-internal commands, type 'help' at the prompt.The most useful are:
user scully Set the remote user to 'scully'
get document1 Fetches the file document1 to the local dir
mget doc* Fetches all files named doc* to the local dir
ls lists the remote dir
cd changes the remote dir
lcd changes the local dir
bin changes the transfer protocol from ascii
to binary and back
telnet telnet [-d] [-n tracefile] [-l user | -a] [-e escape-char] [host [port]]
User interface to the TELNET protocol. Opens a telnet connection to a given
-
7/28/2019 Whatis UNIX
8/10
host
telnet spielberg Opens a telnet connection to spielberg
finger finger [-bfhilmpqsw] [name...]
User information lookup program. Check if a user is logged in on the remotehost. Also used to find out if someone has read email recently.
finger scully@spielberg See if user 'scully' is logged
in on host 'spielberg'
talk talk person [ ttyname ]
Talk to another user. Establish a talk connection between two machines. To do
so, you need to know if the requested user is currently logged in on the other
side (see 'finger')
talk scully@spielberg Try to open a connection to user
scully on spielberg
talk scully Open a connection to user scully
on current host
File processing
Since UNIX systems base heavily on plain text files for configuration, there are many
powerful tools that allow you to process such files. Since processing such files often requires
executing many commands after each other, there is something called 'piping' that allows youto direct the output of a command into the input of the next command. You can thus execute
command chains, without saving the intermediate results to a file.
Below, you will find the simple commands first, and the chaining of them into complex
command sequences in the 'redirection & piping' section that follows.
Simple commands
echo echo [ arg ]
Echo arguments. Prints arguments to the shell.
echo hi Will print "hi" into your shell
grep grep [options] limited regular expression [file . . .]
Search a file for a pattern
grep 'ando' archi.txt Return every line of archi.txt in
which 'ando' appears
grep 'ando' archi/cv*.txt Search in all cv* files under
'archi'
for the string 'ando'
cat cat [-u] [-s] [-v [-t] [-e]] file
-
7/28/2019 Whatis UNIX
9/10
Concatenate and print files. Often used to pipe input into another process.
cat letter3.txt Print file letter3.txt
cat letter*.txt Print all files that match letter*.txt
cut cut -clist [file ...]cut -flist [-dchar] [-s] [file . . .]
Cut out selected fields or characters of each line of a file. Often used by piping
output from another process.
cut -c1-5 data.txt Get first 5 characters of every line
cut -d/ -f1,4-6 data.txt Get fields 1,4,5,6 delimited by '/'
sort sort [-cmu][-ooutput][-ykmem][-zrecsz][-dfiMnr][-btx][+pos1[-pos2]][-Ttdir]
[files]
Sort and/or merge files
sort archi.txt Sort the file archi.txt alphabetically
diff diff [-lrs] [-Sname] [-cefhn] [-xpat] [-biwt] dir1 dir2
diff [-cefhn] [-biwt] file1 file2
Differential file and directory comparator
diff oldfile newfile Searches the two files and seeks for
differences line by line
more more [-cdflrsuw] [-lines] [+linenumber] [+/pattern] [ filename ... ]
Browse or page through a text file
more longfile.txt Prints your file screen by screen
Piping and redirecting
Redirection:
The first thing you can do when interlinking processes, is that you
redirect input or output from / to processes.
Redirected output:
ls -la > listing.txt List dir and output to listing.txt
sort units.txt > sorted.txt Sort units.txt and output to
'sorted.txt'
Redirected input:
cat < data.txt Read the file data.txt as input for
'cat'
mail < order.txt Read the input for 'mail' from the
file
'order.txt'. The file order.txt
should
in this case carry all the commandsyou
-
7/28/2019 Whatis UNIX
10/10
would normally type when calling
'mail'
Piping:
Another thing is piping data streams through a multitude of commands.
sort chaos.txt |grep 'apple' Sorts chaos.txt and seeks for lines
with 'apple'
ps -edalf |grep media |cut -c14-20 List all processes, find lines with
'media' and cut the second fieldDevices
A last, interesting feature about UNIX, is that in the complex filetree,
not only files and diretorys, but also input and output devices can be
found. Namely things like 'mouse', 'keybd' a.o. are all available in a
directory called /dev. There are two interesting devices that might be
useful: the 'null'-device and any ttyq-device.
The 'null' device (/dev/null) acts like a 'black hole'. Anything that is
sent to that device is trashed immediately.
convert my.gif my.tiff > /dev/null
In this case, any message that would normally appear on the screen when
convert is doing its work, is trashed to nowhere (/dev/null)
ttyq-devices are opened, whenever a shell is initialized. You can thus
send information to a shell, using the /ttyqXX devices:
ls -la > /dev/ttyq0
will list the content of a director not in your current shell, but in
the system console (if present)
In the manpages, there will often be references to 'stdout' and 'stdin'.
These are the standard-input and output devices of your system. Namely,
stdin is the keyboard, while stdout points to the monitor.
Last but not least, also processes have their presence in the filesystem.
They can be found under /proc