19
Linux Commands Call Call Us : 20-3734-1498 Us : 20-3734-1498 Email: [email protected] Presented By QuontraSolutions Attend Free Demo

Linux Online Training | Free Demo | QuontraSolutions

Embed Size (px)

DESCRIPTION

QuontraSolutions is a Global Interactive Online IT Training Portal started by Experts with an aspire to provide a Job Oriented IT Online Training on major modules. We provide Hands on online Linux Training with real time scenarios . QuontraSolutions online training could be described in one word by its students, Linux online training we provide with a real time support by our Industry IT experts. We are passionate about how to improve the IT skills by helping you to develop the skills you need in order to accomplish your objective. One free demo will be given before sign up for Online Training Web:www.quontrasolutions.co.uk Email : [email protected] Call us: 20-3734-1498 - PowerPoint PPT Presentation

Citation preview

Page 1: Linux Online Training | Free Demo | QuontraSolutions

Linux Commands

Call Us : 20-3734-1498Call Us : 20-3734-1498Email: [email protected]

Website:www.quontrasolutions.co.uk

Presented By

QuontraSolutionsAttend Free Demo

Page 2: Linux Online Training | Free Demo | QuontraSolutions

Topics

headtaillinktargzip and gunziptouchdiff

Page 3: Linux Online Training | Free Demo | QuontraSolutions

‘head’ command

Displays the first ten lines of a file, unless otherwise stated.

Syntax:

head [-number | -n number] filename

Example:

head -15 myfile.txt

It displays the first 15 lines of ‘myfile.txt’ .

-number Number of lines to display

-n number Number of lines to display

filename Desired filename

Page 4: Linux Online Training | Free Demo | QuontraSolutions

‘head’ command

Displays the first ten lines of a file, unless otherwise stated.

Syntax:

head [-number | -n number] filename

Example:

head -15 myfile.txt

It displays the first 15 lines of ‘myfile.txt’ .

-number Number of lines to display

-n number Number of lines to display

filename Desired filename

Page 5: Linux Online Training | Free Demo | QuontraSolutions

‘tail’ commandDisplays the last ten lines of a file, unless otherwise stated.

Syntax: tail [-n number] [-l] [-b] [-c] [-r] [-f] [file]

-n number Number of lines to display

-l Units of lines.

-b Units of blocks.

-c Units of bytes.

-r Copies lines from the specified starting point in the file in reverse order.

-f Displays the last 10 lines and then update the file as new lines are being added.

filename Desired filename

Page 6: Linux Online Training | Free Demo | QuontraSolutions

‘link’ command

Creates a link to the file or directory.

Syntax:

ln [-f] [-n] [-s] [-i] source destination

-f Forced to create a link.

-n Does not overwrite existing files.

-s Creates a Symbolic link.

source Desired filename

destination Destination filename

Page 7: Linux Online Training | Free Demo | QuontraSolutions

Example:ln –s f1 home/myfiles/f2

Creates a symbolic link between file ‘f1’ to file ‘f3’ of ‘myfiles’ directory.

Represented as ‘’

View the Link using :

ls –l Remove the link using ‘rm’ command.

rm –r f1.

Page 8: Linux Online Training | Free Demo | QuontraSolutions

‘tar’ command

Used to group set of files in to ma single file. It is called Archive file.

Syntax:

tar [-c] [-t or -v] [-x] [-f] filename archivefilename

It has ‘.tar’ extension.

-c Creates an archive file.

-t or -v Lists archive file content.

-x Extract or de archive an archive file.

filename File to be archived

archivefilename New name for archive file.

Page 9: Linux Online Training | Free Demo | QuontraSolutions

Examples:1. Create an archive file

tar –vcf dir1 myarc.tar

It creates archive file ‘myarc.tar’ which has all files of directory ‘dir1’.

2. Dearchive an archive file

tar –xvf myarc.tar

All files in ‘dir1’ are no more grouped, they are separated.

Page 10: Linux Online Training | Free Demo | QuontraSolutions

‘gzip’ and ‘gunzip’

Used to compress and decompress the file respectively.

Syntax:

gzip [-f][-d] filename.

gunzip [-f] compressedfilename.

• It is with ‘.gz’ extension.

-f Compress forcibly.

-d Decompress the compressed file.

filename File to be compressed.

Page 11: Linux Online Training | Free Demo | QuontraSolutions

Examples:1. Compress the file.

gzip –f f1.

Compresses the file ‘f1’ and is represented as ‘f1.gz’.

2. Decompress the compressed file.

gzip –d f1.gz or gunzip –f f1.gz

File ‘f1.gz’ is decompressed to file ‘f1’.

Page 12: Linux Online Training | Free Demo | QuontraSolutions

‘touch’ command

Used to change the timestamp of a file. It is also used to create multiple files at one shot.

Syntax:

touch –t [-a][-m] [-r reference-file] filename

a To change access time

m To change modified time

-r Refer the timestamp of another file

filename Required filename

Page 13: Linux Online Training | Free Demo | QuontraSolutions

Use ‘Stat’ command to know the Timestamp.

$ stat f1.c

(sample output)

Access: 2010-11-01 20:35:58.000000000 +0530

Modify: 2010-11-01 20:35:58.000000000 +0530

Change: 2010-11-01 20:35:58.000000000 +0530

Format for touch -t is : [YY]MMDDhhmm[.ss]

Page 14: Linux Online Training | Free Demo | QuontraSolutions

Examples:

1. Create multiple files at once.

$ touch file1.txt file2.txt file3.txt

2. Change the access time of a file.

$ touch –t -a 08210820 file1.txt

Access: 2010-06-15 13:30:00.000000000 +0530

Modify: 2010-08-21 08:20:00.000000000 +0530

Change: 2010-11-01 20:45:05.000000000 +0530

Page 15: Linux Online Training | Free Demo | QuontraSolutions

Same way we can change the modified time of a file using ‘-m’ along with ‘-t’

4. Refer the timestamp of another file than the current time.

$touch -r file4 file5

file 5 uses the timestamp of file4.

Page 16: Linux Online Training | Free Demo | QuontraSolutions

‘diff’ commandIt is used to find differences between two files.

Syntax:

diff [options] file1 file2

Options:

a Treats all files as text and compare them line-by-line.

y Use the side by side output format.

w Ignore white space/blank space when comparing lines.

i Ignores Case.

Page 17: Linux Online Training | Free Demo | QuontraSolutions

Let us have two files, file1.txt and file2.txt as follows:

file1.txt file2.txt

LINUX TESTgoodmorningwith great thoughtsLead india

LINUX TESTGOODMORNINGwith   great   thoughts

Page 18: Linux Online Training | Free Demo | QuontraSolutions

Examples:

1. Compare the files side by side, ignoring white space.diff -by file1.txt file2.txt

LINUX TEST LINUX TEST

hscripts.com | HSCRIPTS.com

with great thoughts with great thoughts

Lead India <

2. Compare the files side by side, ignoring Case.diff -iy file1.txt file2.txt

LINUX TEST LINUX TEST

hscripts.com HSCRIPTS.com

with great thoughts | with great thoughts

Lead India <

Page 19: Linux Online Training | Free Demo | QuontraSolutions

Thankyou