Title: BIL 101E Introduction to Computers and Information Systems
1BIL 101EIntroduction to Computers and
Information Systems
2Unix History
- The unfinished development of OS Multics at
Bell Laboratories in 1965 left them without a
good OS. - Ken Thopson and Dennis Ritchie decided to
sketch out an OS for BL. - Ken Thompson implemented it on PDP-7. As a pun
on Multix he named the new operating system Unix.
- A new programming language C was developed for
implementation of Unix and 95 of this operating
system was written in C - therefore Unix is a
very good portable system.
3Linux History
-
- Linux was written by Linus Torvalds and has been
improoved by countless number of people around
the word. - It was initially developed for small PC.
4Linux Features
multitasking several programs running at once
multiusers several users at the same machine
at once multiplatforms it runs on many
different CPU
5Getting Started
- You can login to an UNIX operating system after
you had been assigned a username by a system
administrator. -
- login
-
- Unix/Linux is case sensitive (as the C language).
Username smith is different from Smith - After entering your username you will be faced
with the following - password
6Getting Started
- If you have typed your password correctly a
prompt will appear. For example -
-
-
- or a little detailed prompt
-
- marian
7UNIX DIRECTORY STRUCTURE
- In Unix, the files are organized into a tree
structure with a root named by the character '/'.
The first few levels of the tree look like this
8UNIX DIRECTORY STRUCTURE
- In many systems the user files are subdirectories
of a - directory named home' in root directory /. If
we had - a user tango, for example, tangos home directory
- would be /home/tango, and all his files would be
- within that subtree.
- Suppose tango's directory looks like this
9UNIX DIRECTORY STRUCTURE
10FILE TYPES
There are four types of files in the Unix file
system. Ordinary Files An ordinary file may
contain text, a program, or other data. It can
be either an ASCII file, with each of its bytes
being in the numerical range 0 to 127, i.e. in
the 7-bit range, or a binary file, whose bytes
can be of all possible values 0 to 255, in the
8-bit range.
11FILE TYPES
- Directory Files
- Suppose that in the directory x I have a, b and
c, - and that b is a directory, containing files u and
v. - Then b can be viewed not only as a directory,
- containing further files, but also as a file
itself. - The file b consists of information about the
directory b - i.e. the file b has information stating that the
- directory b has files u and v, how large they
are, - when they were last modified, etc.
12FILE TYPES
- Device Files
-
- In Unix, physical devices (printers,
terminals etc.) are represented as files. - This seems odd at first, but it really makes
sense This way, the same read() and write()
functions used to read and write real files can
also be used to read from and write to these
devices. -
13FILE TYPES
- Link Files
-
- Suppose we have a file X, and type
-
- ln X Y
-
- If we then run ls, it will appear that a new
file, Y, has been created, as a copy of X, as if
we had typed -
- cp X Y
- However, the difference is the cp does create a
new file, while ln merely gives an alternate name
to an old file. If we make Y using ln, then Y is
merely a new name for the same physical file X.
14Listing Files
- The a' (all'') and l' (long'') options of
the ls command will give us a lot of information
about files in a specified directory. -
- ls al
- drwx--x--x 63 tango users 4096 Sep
17 0133 .drwxr-xr-x 7 root root
4096 Sep 3 1653 ..drwxr-xr-x 30
tango users 4096 Sep 15 1144
downloadsdrwxr-xr-x 4 tango users
4096 Jul 25 2319 evrimdrwxr-xr-x 5
tango users 4096 Sep 17 0053 foy -
- 1st column - access permissions (see below)
- 2nd column - number of file entries (in the case
of directory files) - 3rd column - owner
- 4rd column group
- 5th column - size in bytes
- 6th column - date and time of last modification
- 7th column - name
15File Permissions
- In Unix, all files are protected under some
access control mechanism, so that the owner of a
file can deny access of his files to other users.
The first column of the long directory list shows
the access characteristics of a file, in te form
of 10 flags, e.g. - drwxr-xr-x.
- Position 1 file type d (directory)
- - (ordinary file)
- l (symbolic
link) - Position 2-4 permissions for the owner
- r (read), w (write) , x (execute)
- Position 5-7 permissions for other users in
the same group - Position 8-10 permissions for all other users
16BASIC UNIX COMMANDS
- The command line is a place where the commands of
a operating system are called and the results of
the commands are seen. - The commands are the tools that the operations
needed by the user to operate the system. - The basic commands about basic operations, disk
operations, administrative or user based
operations, network operations are given here. -
- Please note that this is not a complete set of
commands, but most commonly used ones are
documented here.
17BASIC UNIX COMMANDS
18BASIC UNIX COMMANDS
- ls Lists contents of directories. Directory
contents are sorted alphabetically. - l In addition to the name of each file,
prints the file type, permissions, number of hard
links, owner name, group name, size in bytes, and
timestamp (the modification time). - a Lists all files in directories, including all
files that start with .. - --color Controls whether color is used to
distinguish file types. - ls l
- ls a
- ls al
- ls color
19BASIC UNIX COMMANDS
- man Formats and displays the online manual
pages. To exit the manual pages q character
should be used. - man ls
- cd Change directory command allows you to
change the present working directory to another
one. - cd /home/user1/examples
- cd ..
- cd ../../
- cd ../../ex/project
20BASIC UNIX COMMANDS
- mkdir Creates a new directory with each given
name. -
- mkdir bil101
- rm Removes files or directories. By default, it
does not remove directories. - -f Ignores nonexistent files, never prompt
- -i Prompts before any removal
- -r, -R Removes the contents of directories
- recursively.
-
21BASIC UNIX COMMANDS
- rm ex1
- rm .c
- rm .
- rm f .c
- rm i example1
- rm r /home/user2/abc/
rmdir Removes empty directories. rmdir cse100
22BASIC UNIX COMMANDS
- cp Copies files and directories. If the last
argument names an existing directory, cp copies
each other given file into a file with the same
name in that directory. Otherwise, if only two
files are given, it copies the first onto the
second. It is an error if more than two files are
given. By default, it does not copy directories. - i Prompts whether to overwrite existing regular
destination files. - R Copies directories recursively.
- cp ex1.c ex2.c
- cp ex1.c exs/
- cp ex1.c exs/ex2.c
- cp i ex1.c ../exs/
- cp R exs/ ../examples/
23BASIC UNIX COMMANDS
- mv Moves (renames) files. If the last argument
names an existing directory, mv moves each other
given file into a file with the same name in that
directory. Otherwise, if only two files are
given, it moves the first onto the second. It
also renames directories. - mv ex1.c ex2.c
- mv ex1.c ../exs/ex2.c
24BASIC UNIX COMMANDS
- mdir Displays an MSDOS directory. If your floppy
disk is DOS-formatted, then you can see the
content of your floppy disk by typing - mdir a
- mcopy Copies MSDOS files to/from Unix. If your
floppy disk is DOS-formatted, then you can copy
your files from the floopy disk to the harddisk
or from the harddisk to the floppy disk without
mounting it. - mcopy ex1.c a.
- mcopy aex2.c .
- mcopy ex1.c aex2.c
- mcopy aex2.c ex3.c
25BASIC UNIX COMMANDS
- mmd Makes an MSDOS subdirectory. If your floppy
disk is DOS-formatted, then you can create
directory in your floppy disk. - mmd dir1
- mrd Removes an MSDOS subdirectory. If your
floppy disk is DOS-formatted, then you can remove
a directory in your floppy disk. - mrd dir1
- mcd Changes MSDOS directory. If your floppy
disk is DOS-formatted, then you can change
directory in the floopy disk. - mcd dir2
26BASIC UNIX COMMANDS
- mdel Deletes an MSDOS file. If your floppy disk
is DOS-formatted, then you can delete a file in
your floppy disk. - mdel ex2.c
- fdformat fdformat does a low level format on a
floppy disk. Device is usually one of the
following - fdformat /dev/fd0H1440
- mformat Adds an MSDOS filesystem to a low-level
formatted floppy disk. - mformat a
27BASIC UNIX COMMANDS
- pwd Prints name of the current working
directory. - pwd
- find Searches for files in a directory
hierarchy. find searches the directory tree
rooted at each given pathname by evaluating the
given expression from left to right, according to
the rules of precedence, until the outcome is
known, at which point find moves on to the next
pathname. - name pattern Base of the path matches shell
pattern -
- find / -name .c
- find ./ -name .c
- find /home/user2/ -name .c
28BASIC UNIX COMMANDS
- cat Concatenates files and prints on the
standard output. - cat ex3.
- cat ex2.c ex5.c
- cat ex4.c ex3.c gt ex5.
- more more is a filter for paging through text
one screenful - at a time.
- ls more
- less Less is a program similar to more, but
which allows - backward movement in the file as well as forward
movement. - ls less
29BASIC UNIX COMMANDS
- chmod Changes the permissions of each given
file according to mode, which can be either a
symbolic representation of changes to make, or
an octal number representing the bit pattern
for the new permissions. - In the symbolic mode a combination of the
letters ugoa controls which users' access to
the file will be changed the user who owns it
(u), other users in the file's group (g), other
users not in the file's group (o), or all users
(a). The operator causes the permissions
selected to be added to the existing permissions
of each file - causes them to be removed. The
letters rwx select the new permissions for the
affected users read (r), write (w), execute(or
access for directories) (x). - chmod uw ex3.c
- chmod a-x ex5.c
30BASIC UNIX COMMANDS
- A numeric mode is from one to four octal
digits(0-7), derived by adding - up the bits with values 4, 2, and 1. Any omitted
digits are assumed to - be leading zeros. The first digit selects the
set user ID (4) and set - group ID (2) and save text image (1) attributes.
The second digit - selects permissions for the user who owns the
file read (4), write (2), - and execute (1) the third selects permissions
for other users in the - file's group, with the same values and the
fourth for other users not in - the filess group, with the same values.
- -R change files and directories recursively
- chmod 755 ex2.c
31BASIC UNIX COMMANDS
32BASIC UNIX COMMANDS
- chown Changes file owner and group.
- -R operate on files and directories recursively
- chown user3 ex3.c
- chown R user4 examples/
- chown user3.user3 ex4.c
- chgrp Changes group ownership.
- -R operate on files and directories recursively
- chgrp user5 ex6.c
- chgrp R user6 examples/a
33BASIC UNIX COMMANDS
- du Estimates file space usage
- du exs/
- gzip Compresses files.
- -c Write output on standard output keep
original files unchanged. - gzip c final/ gt fin.gz
- gunzip Expands files. gunzip can decompress
files created by gzip. - -c Write output on standard output keep
original files unchanged. - gunzip c fin.gz
34BASIC UNIX COMMANDS
- tar It is an archiving program designed to store
and extract files from an archive file. - -c create a new archive
- -f use archive file
- -z filter the archive through gzip
- -v verbosely list files processed
- -x extract files from an archive
- tar cvfz str.tgz /home/user1/
- tar xvfz str.tgz
- paswd Updates a user's authentication tokens
- passwd
- passwd user5
- whoami Prints the user name associated with the
current effective user id. - whoami
35BASIC UNIX COMMANDS
- ps Reports process status. Ps gives a snapshot
of the current processes. It returns the process
id knowledge. - -A select all processes
- -a select all with a tty except session leaders
- T select all processes on this terminal
- a select all processes on a terminal, including
those of other users - x select processes without controlling ttys
- u display user-oriented format
- ps aux
- ps x
- ps u
- ps a
- kill Terminates a process kill sends the
specified signal to the specified process. The
process id can be read by the help of the ps
command. - kill 9 125
36BASIC UNIX COMMANDS
- ssh (SSH client) is a program for logging into a
remote machine and for executing commands on a
remote machine. It is intended to replace rlogin
and rsh, and provide secure encrypted
communications between two untrusted hosts over
an insecure network. - ssh burcu_at_maslak.be.itu.edu.tr
- scp secure copy (remote file copy program)
- scp file burcu_at_maslak.be.itu.edu.tr/directory1
37BASIC UNIX COMMANDS
- startx The startx script is a front end to xinit
that provides a somewhat nicer user interface
for running a single session of the X Window
System. It is typically run with no arguments. - Startx
- logout Exits from the current user.
- Logout
- reboot Stops the system.
- Reboot
- poweroff Stops the system.
- Poweroff
38Text Editing in UNIX Environments
- In many UNIX environments like GNU/Linux, the
system provides more than one text editor. We
will discuss vi, joe and pico here. - VI Vi stands for visual, because it was an early
text editor that actually showed you the text you
were creating and what the resulting changes
looked like. Vi is generally available on every
UNIX system you might come across for the rest of
your life. - w writes the file to disk (if "file" is
already defined) - q quit vi
- wq save some typing same as w and then q
39Text Editing in UNIX Environments
JOE is a powerful text editor with many
capabilities. Above is a screen shot of the help
screen of JOE.
40Text Editing in UNIX Environments
This editor has all the basic functions for
beginners and a quick solution to editing text
files for everyone.