Un*x for dummies Basics of Command Line Interface…ipn · $ cp HOWTO HOWTO.original ... $ grep...

17
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Un*x for dummies Basics of Command Line Interface… Vincent Lafage Ivana Hrivnacova 1 Computing department, IJCLab Université Paris-Saclay January 6, 2021 1 / 17

Transcript of Un*x for dummies Basics of Command Line Interface…ipn · $ cp HOWTO HOWTO.original ... $ grep...

Page 1: Un*x for dummies Basics of Command Line Interface…ipn · $ cp HOWTO HOWTO.original ... $ grep version HOWTO ... Un*x for dummies Basics of Command Line Interface… Author: Vincent

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

Un*x for dummiesBasics of Command Line Interface…

Vincent LafageIvana Hrivnacova

1Computing department, IJCLabUniversité Paris-Saclay

January 6, 20211 / 17

Page 2: Un*x for dummies Basics of Command Line Interface…ipn · $ cp HOWTO HOWTO.original ... $ grep version HOWTO ... Un*x for dummies Basics of Command Line Interface… Author: Vincent

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

Linux Screenshot

2 / 17

Page 3: Un*x for dummies Basics of Command Line Interface…ipn · $ cp HOWTO HOWTO.original ... $ grep version HOWTO ... Un*x for dummies Basics of Command Line Interface… Author: Vincent

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

File

A computer file is a block of arbitrary informationdata:

• contents ⇒ characters (encoding)…& metadata:

• file’s nameunder Mac/Linux, filenames are CASE-SENSITIVE!!!

isotope.cxx is NOT Isotope.cxx• file’s extension• file’s size (how many characters, bytes or kilobytes or

megabytes…)• creation date & time• last modification date & time• attributes

3 / 17

Page 4: Un*x for dummies Basics of Command Line Interface…ipn · $ cp HOWTO HOWTO.original ... $ grep version HOWTO ... Un*x for dummies Basics of Command Line Interface… Author: Vincent

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

Files extension…

• text files ⇒ .txt or no extension• source code files ⇒ .cpp/.cxx/.C, .c, .h/.hpp/.hxx/.H,

.pl, .py, .f, .f90, .cob, .adb, .ads…• email files ⇒ .eml• web page files ⇒ .htm, .html, .php…• LATEX file ⇒ .tex

• binary files• image file ⇒ .png, .jpg, .gif,…• movie file ⇒ .mpg, .avi,…• document file ⇒ .pdf, .doc, .odt,…• executable files ⇒ .exe or no extension

4 / 17

Page 5: Un*x for dummies Basics of Command Line Interface…ipn · $ cp HOWTO HOWTO.original ... $ grep version HOWTO ... Un*x for dummies Basics of Command Line Interface… Author: Vincent

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

Directory

also known as folder

files are kept in directories⊕there are subdirectories in directories

⇒ folders form a hierarchy,or tree structure of one or more levels

$ mkdir new_directory ⇒ create a new directory callednew_directory in the current directory

$ rmdir old_directory ⇒ delete old_directory$ mkdir -p www/logs ⇒ create logs subdirectory of www

directory, and if needed create www as well.

5 / 17

Page 6: Un*x for dummies Basics of Command Line Interface…ipn · $ cp HOWTO HOWTO.original ... $ grep version HOWTO ... Un*x for dummies Basics of Command Line Interface… Author: Vincent

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

Moving across directories

cd directory_name$ cd directory ⇒ goes to directory called directory

(you can go directly to a subdirectory)• special directories:

• . current• .. parent• ̃ home

(the default directory when you log in, where all your files are)philosophical questions:

$ pwd ⇒ Where am I?… in which directory: Path to Working Directory

$ whoami ⇒ Who am I?

6 / 17

Page 7: Un*x for dummies Basics of Command Line Interface…ipn · $ cp HOWTO HOWTO.original ... $ grep version HOWTO ... Un*x for dummies Basics of Command Line Interface… Author: Vincent

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

Executable files

$ program ⇒ execute the executable file called program$ ./program ⇒ …and stored in the current directory$ open application ⇒ …only on Mac

7 / 17

Page 8: Un*x for dummies Basics of Command Line Interface…ipn · $ cp HOWTO HOWTO.original ... $ grep version HOWTO ... Un*x for dummies Basics of Command Line Interface… Author: Vincent

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

example

8 / 17

Page 9: Un*x for dummies Basics of Command Line Interface…ipn · $ cp HOWTO HOWTO.original ... $ grep version HOWTO ... Un*x for dummies Basics of Command Line Interface… Author: Vincent

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

example (2)

9 / 17

Page 10: Un*x for dummies Basics of Command Line Interface…ipn · $ cp HOWTO HOWTO.original ... $ grep version HOWTO ... Un*x for dummies Basics of Command Line Interface… Author: Vincent

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

example (2b)

10 / 17

Page 11: Un*x for dummies Basics of Command Line Interface…ipn · $ cp HOWTO HOWTO.original ... $ grep version HOWTO ... Un*x for dummies Basics of Command Line Interface… Author: Vincent

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

Basic file management

displaying directory contents$ ls ⇒ shows all files in the current directory• ls has a LOT of options…

displaying file contents$ cat HOWTO ⇒ dumps HOWTO file’s content to the screen$ more HOWTO ⇒ “pages” HOWTO file’s content to the screen$ less HOWTO ⇒ “pages” HOWTO file’s content to the screen

11 / 17

Page 12: Un*x for dummies Basics of Command Line Interface…ipn · $ cp HOWTO HOWTO.original ... $ grep version HOWTO ... Un*x for dummies Basics of Command Line Interface… Author: Vincent

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

example (3)

12 / 17

Page 13: Un*x for dummies Basics of Command Line Interface…ipn · $ cp HOWTO HOWTO.original ... $ grep version HOWTO ... Un*x for dummies Basics of Command Line Interface… Author: Vincent

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

Basic file management (2)

copying, renaming & moving, deleting files$ cp HOWTO HOWTO.original ⇒ CoPy file HOWTO in new file

HOWTO.original$ rm HOWTO ⇒ ReMove (delete) file HOWTO$ mv HOWTO.original HOWTO ⇒ MoVe (rename) file

HOWTO.original as HOWTO$ mv HOWTO SubDirectory ⇒ MoVe file HOWTO from current

directory to SubDirectory

13 / 17

Page 14: Un*x for dummies Basics of Command Line Interface…ipn · $ cp HOWTO HOWTO.original ... $ grep version HOWTO ... Un*x for dummies Basics of Command Line Interface… Author: Vincent

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

example (4)

14 / 17

Page 15: Un*x for dummies Basics of Command Line Interface…ipn · $ cp HOWTO HOWTO.original ... $ grep version HOWTO ... Un*x for dummies Basics of Command Line Interface… Author: Vincent

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

Basic file management (3)

finding documentation$ man ls ⇒ displays documentation of ls command$ man man ⇒ …man command

searching file contents$ grep version HOWTO ⇒ looks for occurence of character

string version in HOWTO file’s content$ grep -i version HOWTO ⇒ …in a case-insensitive way$ grep -r version . ⇒ …in all files of the current directory

and sub-directories$ find . -iname howto ⇒ looks for all files called “howto”,

in a case insensitive way, in the current directory & recursivelyin all of its subdirectories

15 / 17

Page 16: Un*x for dummies Basics of Command Line Interface…ipn · $ cp HOWTO HOWTO.original ... $ grep version HOWTO ... Un*x for dummies Basics of Command Line Interface… Author: Vincent

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

Basic file management (3b)

16 / 17

Page 17: Un*x for dummies Basics of Command Line Interface…ipn · $ cp HOWTO HOWTO.original ... $ grep version HOWTO ... Un*x for dummies Basics of Command Line Interface… Author: Vincent

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

...

.

Thank you for your attention

Questions?

17 / 17