CHAPTER 7 : MANAGING FILES
==========================
- can use GUI for manipulate files - file manager
- text-mode shells - simplify some tasks
Manipulating Files
------------------
Creating Files
--------------
- using command touch
$touch newfile.txt ---> creating an empty file called newfile.txt
- if use touch command with existing file - updates that file's access and
modification time stamps to current data and time.
- option with touch command
- don't create a file => -c or --no-create option
- set the time to specific value => -d string or --date=string
Copying Files
-------------
- using command cp
$cp orig.txt new.txt => copy in current directory
$cp orig.txt /otherdir => copy to otherdir with same name orig.txt
$cp orig.txt /otherdir/new.txt => copy to otherdir with name new.txt
- option with cp command
- force overwrite => -f or --force => overwrite w/o prompting
- use interactive mode => -i or --interactive => overwrite with prompt
- preserve ownership and permission => -p or --preserve
- perform recursive copy => -R or --recursive
- perform an archive copy => -a or --archive => preserve ownership
- perform an update copy => -u or --update
Moving and Renaming Files
-------------------------
- using command mv
$mv outline.pdf /otherdirc
- option same as command cp
Using Links
-----------
- create multiple links to one file
- Hard link - duplicate directory entry - both entry point to same file - can exist
only on a single filesystem
- command - $ln origname linkname
- Symbolic/Soft link - a file that refers to another file by name
- command - $ln -s origname linkname
- identify links in listing using option -l - command $ln -l
Example
$ln report.txt hardlink.txt
$ln -s report.txt softlink.txt
$ls -l
-rw-r--r-- 2 ....... hardlink.txt
-rw-r--r-- 2 ....... report.txt
lrwxrwxrws 1 ....... softlink.txt -> report.txt
Hardlink - show the at #2
- delete original file will delete all the copies of the files link to it.
- duplicate directory entries that point to the same file
- dangerous to create a link to a directory - disallow
Softlink - show the l at beginning and -> name file
- delete original files makes the file completely inaccessible - the
symbolic links remain but point to non-existent file
- separate files that refer to the original file by name
- can use to create a link to a directory
Deleting Files
--------------
- using command rm => remove one or more files
$rm file1.txt file2.txt
- option
- delete entire directory => -r or -R or --recursive
- delete and prompt => -i
- delete without prompt => -f or --force
- once delete file - gone - didn't go to trash can
Using Wildcards
---------------
- use wildcards to refer to file
- classes of wildcards
- ? => for a single character match
- * => any characters including no character
- bracketed values - [] - any character in set
Understand Case Sensitivity
- case sensitive
Manipulating Directories
------------------------
Creating Directories
--------------------
- use command mkdir
$mkdir newdir => new directory in current directory
$mkdir dirone newdir/dirtwo => create in current and newdir directory
- option
- set mode => -m => setting permission mode
- create parent directories => -p => create parent dir if not exist
Deleting Directories
--------------------
- use command rmdir
$rmdir dirone => remove dir in current directory
$rmdir newdir/dirtwo => remove dir in newdir directory
- rmdir - delete only empty directories only - if have files use command rm -r
- option
- ignore failures on non-empty directory => --ignore-fail
- delete tree => -p => delete entire directory tree
CHAPTER 8 : GETTING HELP
========================
Using man Pages
---------------
- man pages - quick reference - useful to know the options to use with command
- run man page
$man pwd => information manual start from section 1
$man 5 pwd => information manual start from section 5
- search for a man page
- command whatis => search summary information contained in man pages
- command apropos => more through search of man pages
- man pages section
- name - name of the command
- synopsis - brief description
- description - long description
- options - all the options
- files - files associated with man page subject
- see also - point to related information
- bugs - know bugs or limitations
- history - summary of program's history
- author - author to contact
- man pages use less command to display information - display a text file a screen
at a time.
- common way to moving about document using less command
- h or H => display help
- page down, spacebar, ctrl-v, ctrl-f => move down one screen
- page up, esc-v,b or ctrl-b => move up one screen
- down arrow, enter, ctrl-n, ctrl-j => move down one line
- up arrow, ctrl-y, ctrl-p, ctrl-k => move up one line
- xg => go to line x in the document
- q => quit less pager
Using info Pages
----------------
- info pages - new version documentation of man pages - supporting hyperlinking
$info pwd
- use command info to display information
- option to navigate info pages
- ? => display help
- N => next node in linked series
- P => move back in series
- U => mvoe up one level node hiearchy
- Arrow down - move around
- page down page up - scroll up and down
- enter - move to new node
Finding Additional Documentation
--------------------------------
CHAPTER 9 : USING PROGRAM AND PROCESSES
=======================================
Understanding Package Management
--------------------------------
- linux distributions
- linux packages characteristics
- each package is a single file that can be stored on a disk or transmitted
over the Internet
- not programs; packages rely on other programs to do the work of installing
the software
- packages contain dependency information - can tell the package software
what other packages or individual files must be installed in order for the package
to work correctly
- packages contain version information - package software can tell which of
two packages is more recent
- packages contain architecture information - identify CPU type
- binary packages ar typically built from source packages - possible to build
a new binary package given the source package
- package software maintain database information about installed packages -
name, version numbers, location of all the files.
Understanding Package Systems
-----------------------------
Managing RPM Systems
- RPM based distribution - Red Hat, Fedora, CentOS, SUSE Enterprise - tool to
install sotware - text-mode - rpm command local files, yum or zypper for network
repository
- yum command
$yum install yumex => install yumex tool
$yum remove zsh => remove zsh packages
$yum upgrade => upgrade package
- filename extension .rpm
Managing Debian Systems
- Debin distribution - Debian, Ubuntu
- command dpkg => lowest level interface , command apt-get for network repository
- filename extension .deb
- ap-get command
$apt-get install samba => install samba tool
$apt-get remove zsh => remove zsh packages
$apt-get upgrade => upgrade packages
Understanding the Process Hiearachy
-----------------------------------
- when boot - kernel run one program - /sbin/init
- init process - responsible for starting all other programs that must run
- each process can have child process - have child and parent process
- every process has associated with it a process ID (PID) number begin with 1.
- each process has parent PID - point to its parent
Identifying Running Process
---------------------------
- command to identify process is command ps and top utilities => search for
process, - command ps => identify process - produces a process listing - return
process priority and CPU use information - sorted by PID number - provides
information at only single moment in time
- option
- restrict output to process owned by user => -u
- display parent/child relationship => --forest
- command top - need to locate CPU or memory-hogging process - study how resource
use varies over time - interactive version - sort by CPU use - update its display
every few seconds
- command top - provide load average - measure of the demand for CPU time by
applications - detecting runaway process, hung process
- how much memory process consume - command free - overall memory use - generate
report total memory status
- command - $free
Using Log Files
---------------
- locate - /var/log directory tree
- important log file
- boot.log => summarize services start in the boot process
- cron => summarize process run at regular internal
- messages or syslog => message from many deamons
- secure => security related messages
- to look at kernel ring buffer - log file for kernel
- command $dmesg