Changes between Version 6 and Version 7 of ubuntuinstall


Ignore:
Timestamp:
Nov 17, 2016, 7:41:04 AM (7 years ago)
Author:
admin
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ubuntuinstall

    v6 v7  
    359359}}}
    360360
     361=== Working with Files ===
     362
     363Files on Linux (or any Unix) are case sensitive. This means that FILE1 is different from file1, and /etc/hosts is different from /etc/Hosts (the latter one does not exist on a typical Linux computer). In Linux everything is considered as a file even a directory is a special kind of file. A small overview of some basic and important file handling commands
     364
     365 - '''file''': The file utility determines the file type. Linux does not use extensions to determine the file type. The command line does not care whether a file ends in .txt or .pdf. As a system administrator, you should use the file command to determine the file type.
     366 - '''cp''': To copy a file, use cp with a source and a target argument.
     367  * '''cp -r''': To copy complete directories, use cp -r (the -r option forces recursive copying of all files in all subdirectories).
     368  * '''cp -i''': To prevent cp from overwriting existing files, use the -i (for interactive) option.
     369 - '''mv''': Use to rename a file or to move the file to another directory.
     370 - '''rm''': Use to remove files
     371  *'''rm -i''':To prevent yourself from accidentally removing a file.
     372  *'''rm -rf''':'''rm -r''' will not remove non-empty directories. However rm accepts several options that will allow you to remove any directory. The rm -rf  will erase anything
     373'''Extremely dangerous Command'''
     374{{{
     375When you are logged on as root, be very careful with rm -rf (the f means force and the r means recursive) since being root implies
     376that permissions don't apply to you. You can literally erase your entire file system by accident.
     377}}}
     378 - '''less''':The less command is useful for displaying files that take up more than one screen
     379 - '''head/tail''':You can use head to display the first ten lines of a file. and tail to display the last ten lines of a file. you can use both commands with '''-n''' and specify the number of lines
     380 - '''cat''':The cat command is one of the most universal tools, yet all it does is copy standard input to standard output.
     381
     382=== Exercise ===
     383
     384 -  Create numbers.txt (Containing ten lines of numbers one to ten)file with cat command.
     385{{{
     386$ cat > numbers.txt
     387}}}
     388Add the lines with enter key at the end. After inserting all the lines press Ctrl + D
     389{{{
     390one
     391two
     392. .
     393ten
     394}}}
     395 - View the file you created using less and cat
     396'''cat'''
     397{{{
     398$ cat numbers.txt
     399one
     400two
     401three
     402four
     403five
     404six
     405seven
     406eight
     407nine
     408ten
     409}}}
     410'''less'''
     411{{{
     412$ less numbers.txt
     413}}}
     414Press '''q''' to exit from less
     415 - View first four lines and last four lines using head and tail commands
     416{{{
     417$ head -n 4 numbers.txt
     418one
     419two
     420three
     421four
     422$ tail -n 4 numbers.txt
     423seven
     424eight
     425nine
     426ten
     427}}}
     428
     429 - Create another file numbers2.txt(with lines contain eleven to fifteen)
     430{{{
     431$ cat numbers2.txt
     432eleven
     433twevelve
     434thirteen
     435fourteen
     436fifteen
     437}}}
     438 - Combine numbers.txt and numbers2.txt and create numbers3.txt. and view the file.
     439{{{
     440$ cat numbers.txt numbers2.txt > numbers3.txt
     441$ cat numbers3.txt
     442one
     443two
     444three
     445four
     446five
     447six
     448seven
     449eight
     450nine
     451ten
     452eleven
     453twevelve
     454thirteen
     455fourteen
     456fifteen
     457}}}
     458 - Check the file format of the newly created file
     459{{{
     460$ file numbers3.txt
     461numbers3.txt: ASCII text
     462}}}
     463
     464 - Copy all the created files to the test directory. and verify
     465{{{
     466$ cp numbers.txt numbers2.txt numbers3.txt test/
     467$ cd test
     468$ ls
     469numbers2.txt  numbers3.txt  numbers.txt  one
     470}}}
     471
     472 - Make a copy of test directory as newtest and rename it to numbers
     473{{{
     474$ cp -r test/ newtest
     475$ mv newtest/ numbers
     476}}}
     477
     478 - Delete the test directory
     479{{{
     480$ rm -rf test
     481}}}
     482
     483
    361484=== Setting UP IP Addresses ===
    362485