Linux Nota
Linux Nota
==========================
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
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
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
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