Sie sind auf Seite 1von 83

Pelatihan Admin System LPSE se-

Provinsi Kalimantan Selatan


An Introduction To Linux
Some key events in the history of linux
1969 the dawn of time.
Ken Thompson and Dennis Ritchie write the first
Version of Unix.
1984 Free Software Foundation start work on the GNU Project
Which result in a C compiler (GCC) and editor (emacs) and lots
Of command line tools that mimic or improve on their traditional
Unix counterparts
1987 -- Andrew Tanenbaum writes Minix, a UNIX-like
O/S than runs on PCs, mainly As teaching aid
1991 Linus Torvalds starts starts development of
Linux as a project to exploit the intel 386 architecture.
Design is heavily influenced by Minix and Unix.
1994-ish: Explosive growth of the internet fosters wide-
Spread growth of linux and the open source movement
1970 1980 1990
2000
The history of Linux (continued)
Linux began life in 1991
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

Contributions come from many other developers
Free Software Foundation wrote bash shell, gcc compiler, many other
command line tools, distributed under the GNU 'brand name'

Like UNIX before it, linux was not originally conceived as a 'product'
Why Linux

Linux is free, UNIX-like operating system

Work on any kind of hardwares

Comes with complete development environment includes
compilers, toolkit, scripting language

Linux provide rich Graphical User Interface (GUI) support

Strong security nature iptables, file permissions,
ownerships
How does linux differ from windows?
Linux File Structure
Linux File Structure

In the linux operating system, all filesystem are contained
within one directory hierarchy

The root directory is the top level, an all its sub directories
make up the directory hierarchy

This differ to other operating systems such as MS-Windows

All directories are grouped under the root entry /
Directory Architecture (1)

Directory Architecture (2)

Directory Architecture (3)






It is a virtual filesystem that does not exist in HDD
Contain linux kernel information
Unable to delete or add files/directories like general filesystems
Kernel tuning via adjusting file values

Using Linux at The Command Line
Command Line Terminology

A mechanism for interacting with a computer operating system or
software by typing complete command lines including path, file names
and argument to performed spesific tasks.
One command line is initiated by one utility
An utility is followed by Option or argument
An utility is given right after prompt
Prompt has corresponding display per different systems, general as
follow
#- initiated: root
$- initiated: common users
Command Line Terminology


Linux Manual Page man/info

Numerous ways of using utilities, applications, configuration and etc
Hard to be familiar with all usages
Comprehensive documents existing in system
The utilities man/info can be used to inquire all utilities usage
Utility man Option/related utilities/files

Syntax: man [options] target word strings
-k: identical with apropos
-K: search all corresponding contents within man page
whatis: search system utility description
The command /usr/bin/makewhatis creates the required whatis database
apropos: search the data whitin whatis database
The directory /usr/share/doc/ includes all software related documents
Linux File Naming

File names are case-sensitive
File names is composed of alphabets, numbers and other symbols (@,_
and etc)
Various special characters refer to different connotation so that file name
shall avoid the following metadata :
*?<>;&![]|\(){}
File whose name starts with -+
Files whose name starts with . stands for hidden file in unix system.
Linux Common Utilities

Fuction DOS (Case-insensitive) Linux (Case-sensitive)
Change directory CD [directory] cd [directory]
Copy file
COPY < source file ><
target file >
cp < source file >< target file >
Move file MOVE mv < source file >< target file>
List file DIR ls
Clean screen CLN clear
Delete file DELETE rm< file >
Make directory MKDIR mkdir < directory >
Rename file RENAME mv < source file >< target file >
Present working directory PWD pwd
Find file FIND find < directory >
Exit EXIT exit
Date display date < time format >
Time display date
List directories and files information ls

Syntax: ls [option] [Argument (a directory or a file)]
Options:
-a, shows file information (including hidden file)
-l, shows complete information of directory and files (incl. attribute,
number of hard link, owner, group, size, date and filename)
-d, shows directory information only
-F, append file type character right after filename:
*: executable file
/: directory
@: symbolic link
Example :
ls al
Copy files or directory

Syntax: cp [option] <source file> <target file>
Options:
-p, duplicates file attributes such as owner, group, permission and
date of each source file/directory in the corresponding target
file/directory
-r, (R) recursively copies all the contents of directories

Example :
cp /home/test.txt /home/test2.txt



Move files/directory - mv

Syntax: mv [option] <source file> <target file/directory>
Move or rename files or directories from one place to another
Options:
-f, forces overwriting the destionation whitout warning
-i, a prompt to ensure if it would overwrite an existing file
Example :
mv /home/test.txt /home/test2.txt

Remove files/directory - rm

Syntax: rm [option] file [file..]
Remove one or multiple files
Options:
-f, remove files without any confirmation
-i, asks for every deletion to be confirmed
-r, (R) remove directory and its subdirectories and files
Example :
rm /home/test.txt

Change/output current working directory cd/pwd

Syntax: cd [option] [directory]
Change the current working directory
cd - : back to the previous directory
cd ~: back to home directory
cd : back to home directory
Pwd (print working directory) show the path of the current working
directory

Directories

A virtual container where groups of files can be kept and organized, also
referred to folder in windows system
/ is the root directory specifying the first or top most directory on
hierarchy.

Absolute/relative pathname (1)

Absolute pathname: specifies a unique location in filesystem which is usually
writen in reference to a root directory
Relative pathname: specifies a unique location in filesystem which is usually
writen in reference to the current working directory
One dot . represent the current directory itself
Two dots .. point upwards in the hierarchy to indicate the parent directory

Absolute/relative pathname (2)


File/directory name completion

When entering a command, bash will perform filename completion
Press TAB key
Bash will complete as much of the name as is unambiguou, based
on the name completed so far and the names of the existing files
Less typing, less change for typing mistakes
If there are several possible matches, [TAB][TAB] will show them
all
Example ([T] denotes the TAB key)
$ ls l /h[T]/t[T]/re[T].. Completes to
$ ls l /home/tux/reports/

Make a new directory - mkdir

Syntax: mkdir [option] <relative or absolute path>
Multiple directories can be created at one time
Options :
-m, specifies the permissions when you are making directory
-p, create a directory hierarchy

Remove a directory - rmdir

Syntax: rmdir [option] directory [directory]
Remove an empty directory only
Unable to remove directory containing files
Options :
-p, remove all hierarchical directory at one time


Linux File Searching
File searching utilities

find directly search system files (all unix system available)
locate search files via built databases
Whereis find out the utility destination, source code and man page
which find out the utility absolute pathname

Real time files searching utility find

Syntax: find [<directory> [target expression]] [output]
Search files with corresponding expression in target directory then
assign an output
Assign multiple paths at one time
[target expression]
-name, search file name
-type, search file type
-user, search file owned by one user
-group, search file owned by one groups
Searching files in database locate

Syntax: locate <file name>
Search files without specifying directory

Text Editor in Unix System vi
Unix/linux text editor vi

Text editor
Similar to windows notepad
Comes with every version of unix/linux
Advanced vi vim (vi Improved)
Provide general editor function: edit, copy, cut, paste, redo, undo and etc
Three modes of vi editor

Insert mode : edit text
Command mode : move, cursor, cut, paste copy and etc
Execution mode : save, exit and other complicated functions
Enter in vim editor (1)

Type in vim command directly to enter in vim editor
Type in :q<enter> to exit
Enter in vim editor (1)

Type in vim and followed by a target file name, e.g: /etc/issue
Type in :q<enter> to exit
Quit vi editor

Command mode: capitalized ZZ (quit without saving)
Execution mode:
:q quit without saving
:q! quit without saving
:wq, :x quit with saving
vi insert mode

The usage of Key i,I,a,A,o,O can enter in insert mode
The usage of Key r,R can enter in replace mode
Command to enter in Insert Mode Cursor Behavior
i Insert text from cursor location (h)
I Move to first character of current line (T)
a Move to the character next to cursor (i)
A
Move to end of line (after five space
characters)
o Insert a new line after the current one
O Insert a new line before the current one
r Replace one character
R Replace all characters after cursor
vi command mode

Unable to use mouse to move cursor under text interface
Move cursor by keyboard
Provide general editor functions like cut, copy, paste, and etc
vi command mode (cut, copy, paste)


vi command mode (undo, redo, search)


File Access Permission
File Access Permission (1)

Flexible file access configuration from unix/linux
Default setting after first system installation for easily use
It has a lot of space to enable strict access control
The access permissions are provided by filesystem
File Access Permission (2)

File attributes descriptions :

Permission types

r (readable) : grants the ability to read a file
w (readable) : grants the ability to edit or modify a file
x (executable) : grants the ability to execute a file; the permission to
access directory

chmod Change Permission Mode

chmod CHange (permission) MODe
Only the owner can modify file permissions
Root has full right to modify permission off all files
Syntax :

chmod numeral mode


chown change the owner of a file

chown CHange OWNer
Changing the file owner
Usually executed by root
Able to change files group class at one time
chown change the owner of a file

chown CHange OWNer
Changing the file owner
Usually executed by root
Able to change files group class at one time
Filesystem Maintaining Utilities
Introduction to Filesystem

Filesystem is designed for a spesific way to store and organize data
Linux default filesystem: ext2, ext3, ext4
Other filesystems: reiserfs, xfs, ufs, jfs, and etc
All filesystems adhere to FHS
Filesystem maintaining and status displaying

Filesystem status
du disk usage; usage to estimate file space usage
df disk free; used to display the amount of available disk
space for filesystem
ext2/ext3 maintaining utilities
fsck filesystem check
e2fsck for checking ext2/ext3 filesystem only
Disk usage - du

Report the amount of disk space
Quickly check which files use the most space when disk space is
insufficient
Disk free df

Display the amount of disk space that is free on filesystem
Display the information of filesystem type and mount point
Filesystem check - fsck

It may result in problem for filesystems is for long-term or abnormal
operation
Used by root user
Used only after unmounting filesystem
common options:
-t, type : specify the filesystem type, such as ext3 and etc
-p, repair : repair the broken filesystem automatically
-y, yes : for yes automatically if (yes/no) check point
-c, check : check for bad sector

Ext2/ext3 Filesystem check e2fsck

Used by root user
Used only after unmounting filesystem
Able to check various filesystem types: ext2,ext3
common options:
-t, type : specify the filesystem type, such as ext3 and etc
-p, repair : repair the broken filesystem automatically
-y, yes : for yes automatically if (yes/no) check point
-c, check : check for bad sector

Mount configuration - /etc/fstab

mount -a and umount -a will mount/unmount all filesystems
mentioned in fstab
Used in system script startup during booting
List corespondence between device and mount point
Specify filesystem type on device
Ensuring data accuracy while editing fstab is a must, or system booting
will fail.
/etc/fstab Definitions

Mount configuration - /etc/fstab

mount -a and umount -a will mount/unmount all filesystems
mentioned in fstab
Used in system script startup during booting
List corespondence between device and mount point
Specify filesystem type on device
Ensuring data accuracy while editing fstab is a must, or system booting
will fail.
Process
Process

An instance of a computer program that is being executed
A running program would remain in memory
A running program is one process
CPU executes only one task at one time
Process utilities

Display process information :
ps, top,
Send signal :
kill, killall, pkill,
Display system load average and booting time :
uptime, who, w
Display process information ps

Syntax: ps [option]
Options:
Unix/posix options, which may be grouped and must be
preceded by a dash
BSD options, which may be grouped and must not be used with
a dash
GNU long options, which are preceded by tho dashes
Suggestion: unix/posix
Only display the current process information without assigning options
Unix/posix types ps

-e/-A : select all process
-f : full format listing
-w : wide output, use this option twice for unlimited width
-a : display all information of current running process
-u : <user account> : select by effective user ID
-o : <format>: specify user-defined format
Unix/posix types (example) ps


BSD types ps

a : list all process with terminal (tty), or to list all processes when
used together with the x option.
x : list all process
w : wide output, use this option twice for unlimited width
u : display user-oriented format
Unix/posix types (example) ps


Sample top


Signal

A limited form of inter-process communication
Command used to send signal : kill
Sending signal

Syntax: kill [option] PID [PID..]
Option :
Number usage kill -9 PID
Text usage kill HUP PID
Package Management
Package Management

Two major Linux Distribution: RedHat and Debian
RedHat, Inc. is an American company associated to a large extent with
its enterprise OS RedHat Enterprise Linux
Debian project is an independent decentralized organization; Ubuntu is
just based on the Debian Linux Distribution
RedHat Package Management rpm & yum
Debian Package Management dpkg & apt-*
RPM Introduction

RPM command rpm
Used to manage single package in text interface
Package updater with GUI interface is available
Multiple rpm command function include install, update, erase, query
and verify
The package file with rpm file extension name contain all programs of
identical software
Rpm can leave out unnecessary files for preventing to waste system
source
RPM package naming

RPM Wrapper yum

Yellowdog updater, modified
Developed by Duke University
Written by phyton programs
Based on rpm utility
Automatic packages updates and removals as well as list capablilities
on which this package depends
Configuration files : /etc/yum.conf
yum Repository

yum check the updates on yum server online
yum server records are documented in /etc/yum.repos.d/
Files include: CentOs-Base.repo, CentOS-Media.repo
Package category:
base base package
updates updates package
addons package added
extras additional package
yum




search : find some parts of description, summary, packager in rpm
documentation
install : install the latest version of a package or group or packages
update : if run without any package, update will update every currenty
installed package
check-update : to know if your machine had any updates that needed to
be applied without running it interactively
upgrade : upgrade to the latest version
remove/erase : used to remove package
Debian Package Management

Debian include the GNU OS tools and linux kernel
Complete name: Debian GNU/Linux
Over 25.000 packages provided
Files named with .deb file extension
dpkg is debian spesified utility that is similar to rpm
apt-* (refer to get, cache and etc.) is dpkg wrapper (binary file) that is
similar to yum
dpkg Introduction

The base of the debian package management system
Unable to automate installation or removal of depended packages
Root user only
Syntax: dpkg [option] (action) [package]
dpkg usage

dpkg [option] (action) [package]
apt-get usage

apt-get [option] <(action) [package]>
APT sources list is located at /etc/apt/sources.list

Das könnte Ihnen auch gefallen