COMP 201 OpenSource L3 UnixFilesys
COMP 201 OpenSource L3 UnixFilesys
SYSTEM ADMINISTRATION
DANIEL OBUOBI
BASIC OF UNIX & FILE SYSTEM
Basics of UNIX
Getting Started With UNIX
Section A: Objectives
After studying this lesson, you should be able to:
– Define operating systems in general
– Describe what a UNIX shell is
– Describe the options for connecting to a
UNIX system
– Log on to and log out of UNIX
Getting Started With UNIX
Section A: Objectives (Contd)
After studying this lesson, you should be able to:
– Use the date, cal, who, finger, clear, man,
whatis, whereis, whoami, and passwd
commands
– Recall a command from the command
history
– Use Pine to check email on CSE
What is an Operating System?
Hardware
Kernel
System Calls
• PuTTY is a free implementation of Telnet and SSH for Win32 and Unix
platforms.
– Much better than using Telnet, more secure and easier to use
• Telnet is a terminal emulation program for the Internet.
• SSH (Secure Shell) is for UNIX/LINUX systems to provide
authentication security for TCP/IP applications, such as FTP and
Telnet. It can encrypt communications as they go across a network or
the Internet.
where:
$ is system prompt ($ for Bourne Shell, % for C shell)
command is the name of the valid UNIX command for that shell in lowercase
letters
[-option(s)] is one or more modifiers that change the behavior of command
[option argument(s)] is one or more modifiers that change the behavior of [-
option(s)]
[command argument(s)] is one or more objects that are affected by command,
generally, files or pathnames
A space seperates command, options, option arguments and command arguments, but no
space is necessary between multiple options or multiple option arguments. And a
space is optional between the option and option argument.
Structure of a UNIX command (Contd)
Examples:
• $ ls
– Contains only the command ls
• $ ls -la
– Contains the command ls and two options, l and a
• $ ls -la m*
– Contains the command ls; two options, l and a;
and a command argument, m*
• $ lpr -Pspr -n 3 proposal.ps
– Contains the command lpr; two options, P and n;
two option arguments, spr and 3; and a command
argument, proposal.ps
The date Command
– Press the <Space> key on the keyboard shows you more manual
pages, one screen at a time
– Press Ctrl+B to go back to previous screen
– Press <q> to quit man pages and return to the command line prompt
The whatis Command
• Sending a Message
– After your message is composed, type <Control>X, and then press y or
press <Enter>. Your message is sent and a copy is saved to the sent-
mail folder
• Replying a Message
– To reply to a message that you have selected at the Message Index
screen or that you are viewing: Press R
– You are asked whether you want to include the original message in
your reply. Also, if the original message was sent to more than one
person, you are asked if you want to reply to all recipients.
• Forward a Message
– Press F
– Enter the address of your recipient and send the message as usual.
File and File Systems
Understanding Files and Directories:
Objectives
• After studying this lesson, you should be
able to:
– File system structure
– Navigating, creating and deleting…
– Unix permissions
Understanding the UNIX File System
ls -l long listing
ls -a list all files
ls -al long listing all files
ls –F mark directories with /,
executable files with *
ls –R Recursively lists subdirectories
encountered
e.g.
ls –l /etc long list the /etc directory
Creating & Deleting Files
• Common options:
-i : interactive; prompts before overwriting an existing
file
-r : recursive; cp will copy the directory and all its files,
including any subdirectories and their files to target
Example 1: Copying a file
cp goodies goodies.old
Example 2: Copying a list of files to a destination directory
cp result1, result2, result3 /tmp
Example 3: Copying a directory to a destination directory
cp -r /etc/xml .
Move or Rename Files
Examples:
• mv file1 file2
– Rename the file named file1 in the current
working directory to file2
• mv file2 ..
– Push or move the file named file2 up to the
parent of the current working director
Create and Remove Directories
• mkdir dirnames
– Create directories specified in ‘dirnames’
• rmdir dirnames
– Remove the empty directories specified in
‘dirnames’
Remove Files
R W X
User (u)
Group (g)
Others (o)
Unix File Permissions (Contd)
• read (‘r’)
– For file: can view file contents
– For directory: can read directory contents (‘ls’)
• write (‘w’)
– For file: can write to or remove the file
– For directory: can create a new directory or file in
it or remove an existing entry from it
• execute (‘x’)
– For file: can execute (run) file
– For directory: can search, ‘cd’ into the directory
Unix File Permissions (Contd)
-rw-------
Only owner can read and write
-rwxrwxrwx
Everyone can read, write and execute (not very
common!)
-rw-r--r--
Everyone can read, but only owner can write
Directory Permissions: Examples
drwx------
Only owner can view, delete/create files, and cd
into that directory
drwxrwx---
Owner and group can view, create/delete files, cd,
etc.
drwxr-xr-x
Everyone can view and cd into, but only owner can
modify
Changing Permissions
Where
• u user, g group, o others, a all (user,
group, and others);
• + add permission, - take away permission,
= assign permission
Changing Permissions: Examples