Introduction To Linux: Foundation Course
Introduction To Linux: Foundation Course
Introduction To Linux: Foundation Course
Foundation Course
Outline
An Operating System
History of Linux
Free and Open Source Software
Linux Distributions
Linux File System
The Shell
Getting Help
An Operating System
Linux Timeline
History of Linux
Linus Torvalds wrote the original Linux
operating system as a hobbyist
exercise in exploiting the new Intel 386 memory
architecture
Influenced by Minix, an operating system
written by Torvald's professor
Andy Tanenbaum as a teaching aid, which was
in turn based on UNIX
Not derived from UNIX source code but
deliberately UNIX-compatible
Benefits of Linux
Free thus no vendor lock-in
Very secure, no serious virus threats
Distributions remain current and supported by
communities of other developers.
It can run on a wide range of hardware and will
install alongside pre-existing systems
It supports centralized software installation from
pre-existing repositories.
Its resource requirements are low.
Free and Open Source Software
Linux is distributed under Open Source licences
Popular Open Source Licences:
GPL (GNU Public Licence) & LGPL
MIT
Apache
Free as in “free speech” not “free lunch”
Free to run,
Freed to study & adapt,
Free to redistribute,
Free to improve.
Linux Distributions
Strictly speaking, 'linux' refers only to the
operating system kernel
Pieces of Linux OS can be downloaded from
the internet free of charge and assembled into a
working system BUT its hard work
Most users purchase a pre-built distribution
Vendors add value through installation and
configuration tools and support agreements for
enterprises.
Red Hat Based Distros
Debian-based Distros
Non-aligned Distros
The shell
/ (root)
home etc
at.deny
tux dilbert dumpdates
exports
● Pathnames not beginning with '/' are relative to the current directory
● Examples (assuming /home/tux is the current directory):
reports
code/main.c
●
Every directory has a special entry named '..' which references the
parent directory
– The directory immediately above it in the tree
●
Use relative pathnames beginning with '..' to move outside the
current directory
● Examples (assuming /home/tux/code is the current directory):
../reports/July_Conf
../../dilbert/travel/paris
File name completion
● Every user has an account name (e.g. tux) along with an associated
numeric user ID (e.g. 500)
● Every user is associated with one named group which is their primary
group
– Groups allow additional flexibility in assigning access permissions
●
Users can also be associated with one or more secondary groups
●
The command id shows your user identity and group memberships
Secondary groups
Standard file permissions
Group
Owner
Permissions for others
Permissions for members of group
Permissions for owner
Standard file permissions (continued)
u + r
chmod g - w file1 file2 …
o = x
1. Type the
command 4. Select any 5. List the files whose
name! combination permissions you want
of r, w, x to change
● Only the owner of a file (or the superuser) can change the file’s
permissions
$ chmod u+x hello.txt
$ chmod go-w display.object
$ chmod a-wx opensource openwindows
$ chmod u=rw open*
● To set different access permissions for different users, either use two
chmod commands or separate changes with a comma:
$ chmod u=rwx index
$ chmod go=r index
Or:
$ chmod u=rwx,go=r index
Question: What do you think 'chmod u=rwx go=r index' does?
Representing file permissions in octal
7 6 4
● The chown command can change the ownership and group of a file
chown owner.group file1 file2 ...
●
Example:
$ chown root.wheel foo bar
● You can change just the owner:
$ chown root foo
● or you can change just the group:
$ chown .wheel bar
$ chgrp wheel bar
● Only root can change a file's owner
– Ordinary users can change a file's group only if they are members of both
the original and the new group
Exercise: File permissions and ownerships
$ mkdir proposals/january
mkdir: cannot create directory `proposals/january':
No such file or directory
$ mkdir -p proposals/january
$ rmdir proposals
rmdir: `proposals': Directory not empty
$ rmdir proposals/january
$ rmdir proposals
$
Listing directory contents with the ls command
Option Meaning
None Display filenames only, in a multi-column listing
-l Display a 'long' listing, including file type, permissions, modification time, and
size, in addition to the name
-a Display 'hidden' files (ones whose names begin with a '.')
-F After each name, append a character to indicate the file type: '/' indicates a
directory, '*' indicates an executable file, '@' indicates a symbolic link
-i Display inode numbers (discussed later)
-t Sort by time of last alteration (by default, sort is alphabetic on file name)
-u Sort by time of last access
-R Recursive: descend into any subdirectories
-d When listing a directory, list just the directory entry, not the contents
Hidden files
Option Meaning
Interactive mode: ask for confirmation before replacing an
-i
existing file
-u If the destination file already exists, perform the operation
only if the source file is newer than the destination file
Deleting files with the rm command
Option Meaning
-i Interactive mode: ask for confirmation before deleting
Normally rm will prompt for confirmation before deleting
a file on which you do not have write permission. The -f
-f
flag suppresses this prompt and forces rm to delete the
file
-r Recursive mode: delete all subdirectories and contents
Updating files with the touch command
Option Meaning
-a Update only the access timestamp
-m Update only the modification timestamp
-r file Update the timestamps to match those of file, not the
current time
-t time Update the timestamps to the specified time, in the
format [[CC]YY]MMDDhhmm[.ss]
File and directory permissions revisited
● The ways in which file access permissions control what you can do
derive from a few simple rules
– To access the data in a file, you need read permission on the file
– To modify the data in a file, you need write permission on the file
– To list the names (only) of the files in a directory, you need read
permission on the directory
– To list the attributes of the files in a directory (e.g. to perform an ls -l), or
to use the directory in a pathname, or to make it your current directory,
you need execute permission on the directory
–
(You need both read and execute permission to have useful access to a
directory)
–
File permission examples
1. Log in as tux
2. Copy the files passwd, group, hosts and fstab from /etc to your
home directory
3. In your home directory, rename the file fstab to table
4. Create a directory called private in your home directory
5. Change the permissions on private so that only you can access it
– Hint: the permissions should be rwx------
The command as
typed The shell looks
in the current
directory for
matching file alias.pl
$ ls -l *.c
names edges.c
edges.o
main.c
… and substitutes main.o
them back into the wireframe
The command as command line
executed
$ ls -l edges.c main.c
Filename expansion using wildcards (continued)
Given these files in the current directory What do these commands do?
NAME
mount - mount a file system
SYNOPSIS
mount [-lhV]
DESCRIPTION
All files accessible in a Unix system are arranged in one big
tree, the file hierarchy, rooted at /. These files can be
spread out over several devices. The mount command serves to
attach the file system found on some device to the big file
tree. Conversely, the umount(8) command will detach it again.
How a manual page is organised
Section Contents
NAME Name and short description of the command
SYNOPSIS Description of the syntax
DESCRIPTION Detailed description of the command
OPTIONS Description of all available options
COMMANDS Instructions that can be given to the program while it is running
FILES Files referenced by the command
SEE ALSO List of related commands
DIAGNOSTICS Possible error messages and what they mean
EXAMPLE Examples of usage
AUTHOR Who wrote it
BUGS or WARNINGS Known errors and problems
Manual page section numbering
● By default the man command finds the requested page in the lowest-
numbered section
– If the same name appears in more than one section, you may have to
specify the section number explicitly to get the right man page
$ man crontab
... man page for crontab command in section 1 ...
$ man 5 crontab
... man page for crontab file format in section 5 ...
$ man uname
... man page for uname command in section 1 ...
$ man 2 uname
... man page for uname system call in section 2 ...
Searching the manual pages by keyword