Presentation is loading. Please wait.

Presentation is loading. Please wait.

 Adnan Niazi November 2014. UNIX Lecture Goals  Goal 1: Know basic UNIX commands and their use.  Goal 2: Understand the basic structure of a common.

Similar presentations


Presentation on theme: " Adnan Niazi November 2014. UNIX Lecture Goals  Goal 1: Know basic UNIX commands and their use.  Goal 2: Understand the basic structure of a common."— Presentation transcript:

1  Adnan Niazi November 2014

2 UNIX Lecture Goals  Goal 1: Know basic UNIX commands and their use.  Goal 2: Understand the basic structure of a common Unix system.  Goal 3: Know how to find information on more advanced UNIX commands and their use.

3 New Concepts  ShellA “shell” is an interface to a system, we’ll use BASH, the Bourne Again Shell.  RecursionSomething that repeats in a way similar to itself. (eg. a mirror reflecting a mirror …)  VariableA symbol representing a non-static value.  PointerA variable that stores a reference to another variable.

4  UNIX HISTORY

5 UNIX History  1969 – First Version of UNIX developed at Bell Labs by AT&T  1975 – UNIX 6, the first to be widely available outside Bell Labs. The first “Berkeley Software Distribution” (BSD) is released.  1989 – UNIX System V, the last traditional UNIX version.  1991 – Linus Torvalds begin developing Linux.

6 “UNIX-like”  Today – UNIX itself, what’s now called “traditional UNIX” is not used, except by enthusiasts.  There are many “UNIX-like” systems (also known as *nix or UN*X) that are similar to UNIX while not conforming to the Single UNIX Specification.  In fact, most operating systems today except windows are “UNIX like”.

7 UNIX History

8 *NIX Systems Mac OS X

9  *NIX Command Line Basics

10 The command line Host, tells you where you are! User, tells you who you are! The prompt! This is where you write stuff

11 Command line structure Format: $ command [switches] [arguments] Square brackets mean “optional”! The prompt! Tells you your scope. Switches control the behavior of the command Arguments are the “target” of the command

12 Why text? Scary, complicated and tedious at first, but supercomputing is impossible without it. Text based commands allow scripting and automation, making work re-usable and repeatable Well designed commands allow fast and powerful data manipulation that graphical interfaces can’t replicate.

13 Navigation Commands Listls Change Directorycd Print Working Directorypwd

14 listing The Basic command The command generates a compact list of files and directories

15 listing Adding switches: The ‘l’ switch gives detailed (“long”) output

16 listing … and adding arguments The argument defines which directory or pattern to list.

17 print working directory One of the easiest commands, prints your location in the directory tree.

18 change directory Self explanatory, changes your position in the directory tree. Combining all the Navigation commands allow you to explore the file system as efficient as a graphical interface!

19 TAB COMPLETION!!! Never let typing slow you down! Pressing while typing automatically completes what you are typing as long as the computer can “guess” it! Tab turns into

20 File System Interaction Commands Copycp Movemv Removerm

21 copycopy Makes a copy of a file with a new name Copy always take two arguments; first the file to be copied, and then the name of the new file.

22 copycopy To copy a directory, you need to copy recursively. The “-r” switch makes the command recursively copy everything within the directory as well.

23 movemove Move behaves exactly the same as copy, but removes the original Moving does not care about recursion.

24 movemove The move command is also used to rename things! Moving something into a new name is the same as changing the name after all!

25 remove Used to remove files or directories. There is no trash bin on the command line! If you delete something it’s GONE!

26 remove Remove a directory! You need to specify recursion with “-r”. This is since it affects every file and not just the top one!

27 File Interaction Commands lesslook inside files headprint beginning of file tailprint end of file catprint entire file nanobasic text editor

28 less Light-weight program for looking inside text files You exit less by pressing “q” and scroll one page with

29 head Prints the first rows from a file, defaults to 10 lines but can be asked to print any number of lines.

30 tail Prints the last rows from a file, defaults to 10 lines but can be asked to print any number of lines.

31 cat Prints every row from a file. Short for concatenate as it can be used to concatenate files.

32 nano Light-weight text editor. Command help is available at the bottom of the screen! ( ^ means, so you exit with +x )

33 The Great Summary Movemv Listls Copycp Removerm Change Directorycd Print Working Directorypwd lesslook inside file headprint start of file tailprint end of file catprint entire file nanoedit file

34  BASIC LINUX FILE SYSTEM

35 Basic Linux File Structure  /devThis is where all the hardware is!  /etcThis is where important stuff lives  /homeThis is where user files are  /rootThis is where the boss hangs out  /tmpThis is where the system stores temp files  /usr/localThis is where most programs are  /var/logThis is where the log files are

36 Directory Tree notes.txtscript.shphoto.jpg

37 Special files:. and.. Hidden files in UNIX start with a “.”, these can be viewed with the “-a” switch for ls. There are also the special files “.” and “..” in each directory.. is a pointer to self, i.e. it references the directory itself.. is a pointer to parent, i.e. to the directory containing the current directory.

38 File Permissions First row is d rwx rwx rwx this is the file permissions! The first “ d ” means that the file is a directory, the three triplets following is “read”, “write” and “execute” permissions for “user”, “group” and “other”. This data is followed by “owner user” (martin) “owner group” (staff), file size, date and name

39 Changing Permissions The command for changing permissions is chmod. ex. $ chmod 750 myscript.sh The number 755 is derived from the binary representation of three permission bits, “read, write, execute”. 111 = read, write and execute = 1×2 2 +1×2 1 +1×2 0 = 7 101 = read and execute = 1×2 2 +0×2 1 +1×2 0 = 5 000 = no permissions = 0×2 2 +0×2 1 +0×2 0 = 0 Note that sometimes changing permissions requires sudo

40 Questions?

41 Tutorial! There is a tutorial at http://sgbc.slu.se/unix/http://sgbc.slu.se/unix/ The tutorial deals with the things that we have looked at in this lecture as well as some extra bonuses!


Download ppt " Adnan Niazi November 2014. UNIX Lecture Goals  Goal 1: Know basic UNIX commands and their use.  Goal 2: Understand the basic structure of a common."

Similar presentations


Ads by Google