Lecture 01: Linux and C Programming Language

Total Page:16

File Type:pdf, Size:1020Kb

Lecture 01: Linux and C Programming Language Lecture 01: Linux and C Programming Language CSE 564 Computer Architecture Fall 2016 Department of Computer Science and Engineering Yonghong Yan [email protected] www.secs.oakland.edu/~yan 1 Contents • Remote Login using SSH • Linux • C Programming • Compiling and Linking • Assignment 1 2 Computaon Server In the cold and dark server room! Run Linux/Unix Operang System 3 Client/Server and SSH (Secure Shell) 4 Machines • hp://cto.secs.oakland.edu/docs/pdf/linuxServers.pdf • To connect to any available server – login.secs.oakland.edu • Or you can connect directly with – ringo.secs.oakland.edu – harrison.secs.oakland.edu – paul.secs.oakland.edu – gpu.secs.oakland.edu • SSH or puIy – ssh <one of above machine name> -l<ned> • Copy files or using H drive – scp or winscp – hIp://www.secs.oakland.edu/docs/pdf/accessNetworkDrive.pdf • Need VPN from home – hp://secs.oakland.edu/docs/pdf/vpn.pdf 5 Puy SSH connecon login.secs.oakland.edu 6 Linux Basic Commands It is all about dealing with files and folders Linux folder: /home/yan/… • rm (remove a filer/folder) – $ rm foo • ls (list files in the current folder) – $ rm -rf foo – $ ls -l – $ ls -a – $ rm -i foo – $ ls -la – $ rm -- -foo – $ ls -l --sort=me • cat (print the file contents to – $ ls -l --sort=size –r terminal) • cd (change directory to) – $ cat /etc/motd – $ cd /usr/bin – $ cat /proc/cpuinfo • pwd (show current folder name) – $ pwd • cp (create a copy of a file/folder) • ~ (home folder) – $ cp foo bar – $ cd ~ – $ cp -a foo bar • ~user (home folder of a user) • mv (move a file/folder to another – $ cd ~weesan locaon. Used also for renaming) – $ mv foo bar • What will “cd ~/weesan” do? • mkdir (create a folder) – $ mkdir foo Basic Commands (cont) • df (Disk usage) Search a command or a file – $ df -h / • which – $ du -sxh ~/ – $ which ls • man (manual) • whereis – $ man ls – $ whereis ls – $ man 2 mkdir • locate – $ man man – $ locate stdio.h – $ man -k mkdir – $ locate iostream • Manpage secons • find – 1 User-level cmds and apps – $ find / | grep stdio.h • /bin/mkdir – $ find /usr/include | grep stdio.h – 2 System calls • int mkdir(const char *, …); Smarty – 3 Library calls 1. [Tab] key: auto-complete the command • int prin(const char *, …); sequence 2. é key: to find previous command 3. [Ctl]+r key: to search previous command EdiAng a File: Vi • 2 modes • Delete – Input mode – dd (delete a line) – d10d (delete 10 lines) • ESC to back to cmd mode – d$ (delete Rll end of line) – Command mode – dG (delete Rll end of file) • Cursor movement – x (current char.) – h (lej), j (down), k (up), l (right) • Paste – ^f (page down) – p (paste aer) – ^b (page up) – ^ (first char.) – P (paste before) – $ (last char.) • Undo – G (boIom page) – u – :1 (goto first line) • Search • Swtch to input mode – / – a (append) • Save/Quit – i (insert) – :w (write) – o (insert line aer – O (insert line before) – :q (quit) – :wq (write and quit) – :q! (give up changes) C Hello World • vi hello.c • Switch to ediRng mode: i or a • Switching to control mode: ESC • Save a file: in control mode, :w • To quit, in control mode, :q • To quit without saving, :q! • Copy/paste a line: yy and then p, both from the current cursor – 5 line: 5yy and then p • To delete a whole line, in control mode, : dd #include <stdio.h> • vi hello.c /* The simplest C Program */ • ls hello.c • gcc hello.c –o hello int main(int argc, char **argv) { • ls printf(“Hello World\n”); • ./hello return 0; } 10 C Syntax and Hello World #include inserts another file. “.h” files are called “header” files. They contain declarations/definitions needed to interface to libraries and code in other “.c” files. What do the < > mean? A comment, ignored by the compiler #include <stdio.h> The main() function is always /* The simplest C Program */ where your program starts int main(int argc, char **argv) running. { Blocks of code (“lexical printf(“Hello World\n”); scopes”) are marked by { … } return 0; } Return ‘0’ from this function 11 Compilaon Process in C • Compilaon process: gcc hello.c –o hello – ConstrucRng an executable image for an applicaon – FOUR stages – Command: gcc <opRons> <source_file.c> • Compiler Tool – gcc (GNU Compiler) • man gcc (on Linux m/c) – icc (Intel C compiler) 4 Stages of Compilaon Process Preprocessing gcc –E hello.c –o hello.i hello.c à hello.i Compilaon (aaer preprocessing) gcc –S hello.i –o hello.s Assembling (aaer compilaAon) gcc –c hello.s –o hello.o Linking object files gcc hello.o –o hello Output à Executable (a.out) Run à ./hello (Loader) 4 Stages of Compilaon Process 1. Preprocessing (Those with # …) – Expansion of Header files (#include … ) – SubsRtute macros and inline funcRons (#define …) 2. Compilaon – Generates assembly language – Verificaon of funcRons usage using prototypes – Header files: Prototypes declaraon 3. Assembling – Generates re-locatable object file (contains m/c instrucRons) – nm app.o 0000000000000000 T main U puts – nm or objdump tool used to view object files 4 Stages of Compilaon Process (contd..) 4. Linking – Generates executable file (nm tool used to view exe file) – Binds appropriate libraries • Stac Linking • Dynamic Linking (default) • Loading and ExecuRon (of an executable file) – Evaluate size of code and data segment – Allocates address space in the user mode and transfers them into memory – Load dependent libraries needed by program and links them – Invokes Process Manager à Program registraon Compiling a C Program • gcc <op3ons> program_name.c • Opons: Four stages into one ----------- -Wall: Shows all warnings -o output_file_name: By default a.out executable file is created when we compile our program with gcc. Instead, we can specify the output file name using "-o" opon. -g: Include debugging informaon in the binary. • man gcc Linking MulAple files to make executable file • Two programs, prog1.c and prog2.c for one single task – To make single executable file using following instrucRons First, compile these two files with opRon "-c" gcc -c prog1.c gcc -c prog2.c -c: Tells gcc to compile and assemble the code, but not link. We get two files as output, prog1.o and prog2.o Then, we can link these object files into single executable file using below instrucRon. gcc -o prog prog1.o prog2.o Now, the output is prog executable file. We can run our program using ./prog Linking with other libraries • Normally, compiler will read/link libraries from /usr/lib directory to our program during compilaon process. – Library are precompiled object files • To link our programs with libraries like pthreads and realRme libraries (rt library). – gcc <opRons> program_name.c -lpthread -lrt -lpthread: Link with pthread library à libpthread.so file -lrt: Link with rt library à librt.so file Opon here is "-l<library>" Another opRon "-L<dir>" used to tell gcc compiler search for library file in given <dir> directory. CompilaAon, Linking, ExecuAon of C/C++ Programs source object file 1 file 1 source object linking file 2 file 2 load compilation (relocation + file library linking) object file 1 source object file N file N library object file M usually performed by a compiler, usually in one uninterrupted sequence hp://www.tenouk.com/ModuleW.html sum.c • cp ~yan/sum.c ~ (copy sum.c file from my home folder to your home folder) • gcc -save-temps sum.c –o sum • ./sum 102400 • vi sum.c • vi sum.s • View them from H drive • Other system commands: – cat /proc/cpuinfo to show the CPU and #cores – top command to show system usage and memory 20 More on C Programming 21 Lexical Scoping void p(char x) Every Variable is Defined within some scope. { A Variable cannot be referenced by name /* p,x */ char y; (a.k.a. Symbol) from outside of that scope. /* p,x,y */ char z; /* p,x,y,z */ } Lexical scopes are defined with curly braces { }. /* p */ char z; /* p,z */ The scope of Function Arguments is the void q(char a) complete body of that function. { char b; /* p,z,q,a,b */ The scope of Variables defined inside a { char b? function starts at the definition and ends at char c; /* p,z,q,a,b,c */ the closing brace of the containing block } legal? char d; The scope of Variables defined outside a /* p,z,q,a,b,d (not c) */ } function starts at the definition and ends at the end of the file. Called “Global” Vars. /* p,z,q */ 22 Comparison and MathemaAcal Operators == equal to < less than <= less than or equal Beware division: > greater than • 17/5=3, 17%5=2 >= greater than or equal != not equal • 5 / 10 = 0 whereas 5 / 10.0 = 0.5 && logical and • Division by 0 will cause a FPE(Float- || logical or ! logical not point exception) + plus & bitwise and - minus | bitwise or Don’t confuse & and &&.. * mult ^ bitwise xor 1 & 2 = 0 whereas 1 && 2 = <true> / divide ~ bitwise not % modulo << shift left >> shift right The rules of precedence are clearly defined but often difficult to remember or non-intuitive. When in doubt, add parentheses to make it explicit. 23 Assignment Operators x = y assign y to x x += y assign (x+y) to x x++ post-increment x x -= y assign (x-y) to x ++x pre-increment x x *= y assign (x*y) to x x-- post-decrement x x /= y assign (x/y) to x --x pre-decrement x x %= y assign (x%y) to x Note the difference between ++x and x++ (high vs low priority (precedence)): int x=5; int x=5; int y; int y; y = ++x; y = x++; /* x == 6, y == 6 */ /* x == 6, y == 5 */ Don’t confuse “=“ and “==“! int x=5; int x=5; if (x==6) /* false */ if (x=6) /* always true */ { { /* ..
Recommended publications
  • Create Union Variables Difference Between Unions and Structures
    Union is a user-defined data type similar to a structure in C programming. How to define a union? We use union keyword to define unions. Here's an example: union car { char name[50]; int price; }; The above code defines a user define data type union car. Create union variables When a union is defined, it creates a user-define type. However, no memory is allocated. To allocate memory for a given union type and work with it, we need to create variables. Here's how we create union variables: union car { char name[50]; int price; } car1, car2, *car3; In both cases, union variables car1, car2, and a union pointer car3 of union car type are created. How to access members of a union? We use . to access normal variables of a union. To access pointer variables, we use ->operator. In the above example, price for car1 can be accessed using car1.price price for car3 can be accessed using car3->price Difference between unions and structures Let's take an example to demonstrate the difference between unions and structures: #include <stdio.h> union unionJob { //defining a union char name[32]; float salary; int workerNo; } uJob; struct structJob { char name[32]; float salary; int workerNo; } sJob; main() { printf("size of union = %d bytes", sizeof(uJob)); printf("\nsize of structure = %d bytes", sizeof(sJob)); } Output size of union = 32 size of structure = 40 Why this difference in size of union and structure variables? The size of structure variable is 40 bytes. It's because: size of name[32] is 32 bytes size of salary is 4 bytes size of workerNo is 4 bytes However, the size of union variable is 32 bytes.
    [Show full text]
  • System Calls and I/O
    System Calls and I/O CS 241 January 27, 2012 Copyright ©: University of Illinois CS 241 Staff 1 This lecture Goals Get you familiar with necessary basic system & I/O calls to do programming Things covered in this lecture Basic file system calls I/O calls Signals Note: we will come back later to discuss the above things at the concept level Copyright ©: University of Illinois CS 241 Staff 2 System Calls versus Function Calls? Copyright ©: University of Illinois CS 241 Staff 3 System Calls versus Function Calls Function Call Process fnCall() Caller and callee are in the same Process - Same user - Same “domain of trust” Copyright ©: University of Illinois CS 241 Staff 4 System Calls versus Function Calls Function Call System Call Process Process fnCall() sysCall() OS Caller and callee are in the same Process - Same user - OS is trusted; user is not. - Same “domain of trust” - OS has super-privileges; user does not - Must take measures to prevent abuse Copyright ©: University of Illinois CS 241 Staff 5 System Calls System Calls A request to the operating system to perform some activity System calls are expensive The system needs to perform many things before executing a system call The computer (hardware) saves its state The OS code takes control of the CPU, privileges are updated. The OS examines the call parameters The OS performs the requested function The OS saves its state (and call results) The OS returns control of the CPU to the caller Copyright ©: University of Illinois CS 241 Staff 6 Steps for Making a System Call
    [Show full text]
  • An Array-Oriented Language with Static Rank Polymorphism
    An array-oriented language with static rank polymorphism Justin Slepak, Olin Shivers, and Panagiotis Manolios Northeastern University fjrslepak,shivers,[email protected] Abstract. The array-computational model pioneered by Iverson's lan- guages APL and J offers a simple and expressive solution to the \von Neumann bottleneck." It includes a form of rank, or dimensional, poly- morphism, which renders much of a program's control structure im- plicit by lifting base operators to higher-dimensional array structures. We present the first formal semantics for this model, along with the first static type system that captures the full power of the core language. The formal dynamic semantics of our core language, Remora, illuminates several of the murkier corners of the model. This allows us to resolve some of the model's ad hoc elements in more general, regular ways. Among these, we can generalise the model from SIMD to MIMD computations, by extending the semantics to permit functions to be lifted to higher- dimensional arrays in the same way as their arguments. Our static semantics, a dependent type system of carefully restricted power, is capable of describing array computations whose dimensions cannot be determined statically. The type-checking problem is decidable and the type system is accompanied by the usual soundness theorems. Our type system's principal contribution is that it serves to extract the implicit control structure that provides so much of the language's expres- sive power, making this structure explicitly apparent at compile time. 1 The Promise of Rank Polymorphism Behind every interesting programming language is an interesting model of com- putation.
    [Show full text]
  • Data Structures, Buffers, and Interprocess Communication
    Data Structures, Buffers, and Interprocess Communication We’ve looked at several examples of interprocess communication involving the transfer of data from one process to another process. We know of three mechanisms that can be used for this transfer: - Files - Shared Memory - Message Passing The act of transferring data involves one process writing or sending a buffer, and another reading or receiving a buffer. Most of you seem to be getting the basic idea of sending and receiving data for IPC… it’s a lot like reading and writing to a file or stdin and stdout. What seems to be a little confusing though is HOW that data gets copied to a buffer for transmission, and HOW data gets copied out of a buffer after transmission. First… let’s look at a piece of data. typedef struct { char ticker[TICKER_SIZE]; double price; } item; . item next; . The data we want to focus on is “next”. “next” is an object of type “item”. “next” occupies memory in the process. What we’d like to do is send “next” from processA to processB via some kind of IPC. IPC Using File Streams If we were going to use good old C++ filestreams as the IPC mechanism, our code would look something like this to write the file: // processA is the sender… ofstream out; out.open(“myipcfile”); item next; strcpy(next.ticker,”ABC”); next.price = 55; out << next.ticker << “ “ << next.price << endl; out.close(); Notice that we didn’t do this: out << next << endl; Why? Because the “<<” operator doesn’t know what to do with an object of type “item”.
    [Show full text]
  • Compendium of Technical White Papers
    COMPENDIUM OF TECHNICAL WHITE PAPERS Compendium of Technical White Papers from Kx Technical Whitepaper Contents Machine Learning 1. Machine Learning in kdb+: kNN classification and pattern recognition with q ................................ 2 2. An Introduction to Neural Networks with kdb+ .......................................................................... 16 Development Insight 3. Compression in kdb+ ................................................................................................................. 36 4. Kdb+ and Websockets ............................................................................................................... 52 5. C API for kdb+ ............................................................................................................................ 76 6. Efficient Use of Adverbs ........................................................................................................... 112 Optimization Techniques 7. Multi-threading in kdb+: Performance Optimizations and Use Cases ......................................... 134 8. Kdb+ tick Profiling for Throughput Optimization ....................................................................... 152 9. Columnar Database and Query Optimization ............................................................................ 166 Solutions 10. Multi-Partitioned kdb+ Databases: An Equity Options Case Study ............................................. 192 11. Surveillance Technologies to Effectively Monitor Algo and High Frequency Trading ..................
    [Show full text]
  • Bits, Bytes and Integers ‘
    Bits, Bytes and Integers ‘- Karthik Dantu Ethan Blanton Computer Science and Engineering University at Buffalo [email protected] 1 Karthik Dantu Administrivia • PA1 due this Friday – test early and often! We cannot help everyone on Friday! Don’t expect answers on Piazza into the night and early morning • Avoid using actual numbers (80, 24 etc.) – use macros! • Lab this week is on testing ‘- • Programming best practices • Lab Exam – four students have already failed class! Lab exams are EXAMS – no using the Internet, submitting solutions from dorm, home Please don’t give code/exam to friends – we will know! 2 Karthik Dantu Everything is Bits • Each bit is 0 or 1 • By encoding/interpreting sets of bits in various ways Computers determine what to do (instructions) … and represent and manipulate numbers, sets, strings, etc… • Why bits? Electronic Implementation‘- Easy to store with bistable elements Reliably transmitted on noisy and inaccurate wires 0 1 0 1.1V 0.9V 0.2V 0.0V 3 Karthik Dantu Memory as Bytes • To the computer, memory is just bytes • Computer doesn’t know data types • Modern processor can only manipulate: Integers (Maybe only single bits) Maybe floating point numbers ‘- … repeat ! • Everything else is in software 4 Karthik Dantu Reminder: Computer Architecture ‘- 5 Karthik Dantu Buses • Each bus has a width, which is literally the number of wires it has • Each wire transmits one bit per transfer • Each bus transfer is of that width, though some bits might be ignored • Therefore, memory has a word size from‘-the viewpoint of
    [Show full text]
  • Application and Interpretation
    Programming Languages: Application and Interpretation Shriram Krishnamurthi Brown University Copyright c 2003, Shriram Krishnamurthi This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License. If you create a derivative work, please include the version information below in your attribution. This book is available free-of-cost from the author’s Web site. This version was generated on 2007-04-26. ii Preface The book is the textbook for the programming languages course at Brown University, which is taken pri- marily by third and fourth year undergraduates and beginning graduate (both MS and PhD) students. It seems very accessible to smart second year students too, and indeed those are some of my most successful students. The book has been used at over a dozen other universities as a primary or secondary text. The book’s material is worth one undergraduate course worth of credit. This book is the fruit of a vision for teaching programming languages by integrating the “two cultures” that have evolved in its pedagogy. One culture is based on interpreters, while the other emphasizes a survey of languages. Each approach has significant advantages but also huge drawbacks. The interpreter method writes programs to learn concepts, and has its heart the fundamental belief that by teaching the computer to execute a concept we more thoroughly learn it ourselves. While this reasoning is internally consistent, it fails to recognize that understanding definitions does not imply we understand consequences of those definitions. For instance, the difference between strict and lazy evaluation, or between static and dynamic scope, is only a few lines of interpreter code, but the consequences of these choices is enormous.
    [Show full text]
  • Handout 16: J Dictionary
    J Dictionary Roger K.W. Hui Kenneth E. Iverson Copyright © 1991-2002 Jsoftware Inc. All Rights Reserved. Last updated: 2002-09-10 www.jsoftware.com . Table of Contents 1 Introduction 2 Mnemonics 3 Ambivalence 4 Verbs and Adverbs 5 Punctuation 6 Forks 7 Programs 8 Bond Conjunction 9 Atop Conjunction 10 Vocabulary 11 Housekeeping 12 Power and Inverse 13 Reading and Writing 14 Format 15 Partitions 16 Defined Adverbs 17 Word Formation 18 Names and Displays 19 Explicit Definition 20 Tacit Equivalents 21 Rank 22 Gerund and Agenda 23 Recursion 24 Iteration 25 Trains 26 Permutations 27 Linear Functions 28 Obverse and Under 29 Identity Functions and Neutrals 30 Secondaries 31 Sample Topics 32 Spelling 33 Alphabet and Numbers 34 Grammar 35 Function Tables 36 Bordering a Table 37 Tables (Letter Frequency) 38 Tables 39 Classification 40 Disjoint Classification (Graphs) 41 Classification I 42 Classification II 43 Sorting 44 Compositions I 45 Compositions II 46 Junctions 47 Partitions I 48 Partitions II 49 Geometry 50 Symbolic Functions 51 Directed Graphs 52 Closure 53 Distance 54 Polynomials 55 Polynomials (Continued) 56 Polynomials in Terms of Roots 57 Polynomial Roots I 58 Polynomial Roots II 59 Polynomials: Stopes 60 Dictionary 61 I. Alphabet and Words 62 II. Grammar 63 A. Nouns 64 B. Verbs 65 C. Adverbs and Conjunctions 66 D. Comparatives 67 E. Parsing and Execution 68 F. Trains 69 G. Extended and Rational Arithmeti 70 H. Frets and Scripts 71 I. Locatives 72 J. Errors and Suspensions 73 III. Definitions 74 Vocabulary 75 = Self-Classify - Equal 76 =. Is (Local) 77 < Box - Less Than 78 <.
    [Show full text]
  • Fixed-Size Integer Types Bit Manipulation Integer Types
    SISTEMI EMBEDDED AA 2012/2013 Fixed-size integer types Bit Manipulation Integer types • 2 basic integer types: char, int • and some type-specifiers: – sign: signed, unsigned – size: short, long • The actual size of an integer type depends on the compiler implementation – sizeof(type) returns the size (in number of bytes) used to represent the type argument – sizeof(char) ≤ sizeof(short) ≤ sizeof(int) ≤ sizeof(long)... ≤ sizeof(long long) Fixed-size integers (1) • In embedded system programming integer size is important – Controlling minimum and maximum values that can be stored in a variable – Increasing efficiency in memory utilization – Managing peripheral registers • To increase software portability, fixed-size integer types can be defined in a header file using the typedef keyword Fixed-size integers (2) • C99 update of the ISO C standard defines a set of standard names for signed and unsigned fixed-size integer types – 8-bit: int8_t, uint8_t – 16-bit: int16_t, uint16_t – 32-bit: int32_t, uint32_t – 64-bit: int64_t, uint64_t • These types are defined in the library header file stdint.h Fixed-size integers (3) • Altera HAL provides the header file alt_types.h with definition of fixed-size integer types: typedef signed char alt_8; typedef unsigned char alt_u8; typedef signed short alt_16; typedef unsigned short alt_u16; typedef signed long alt_32; typedef unsigned long alt_u32; typedef long long alt_64; typedef unsigned long long alt_u64; Logical operators • Integer data can be interpreted as logical values in conditions (if, while,
    [Show full text]
  • Advanced Programming Techniques (Amazing C++) Bartosz Mindur Applied Physics and Computer Science Summer School '20
    Advanced Programming Techniques (Amazing C++) Bartosz Mindur Applied Physics and Computer Science Summer School '20 Kraków, 2020-07-16 [1 / 37] www.menti.com/28f8u5o5xr Which programming language do you use the most? cpp h s a b python a c v a y j csharp l b m e s s a 18 [2 / 37] Agenda References C++ history C++11/14 - must be used C++17 - should be used C++20 - may (eventually) be used ... [3 / 37] www.menti.com/uaw75janh7 What is your current knowledge of C++? Core C++ 3.1 C++ STL ! e k e 2.2 i l n o d o N C++ 11/14 G 2.4 C++17 1.4 17 [4 / 37] References and tools [5 / 37] C++ links and cool stu C++ links Online tools ISO C++ Compiler Explorer cpp references cpp insights c & cpp programming cpp.sh #include <C++> repl.it LernCpp.com Quick Bench cplusplus.com Online GDB CppCon piaza.io CppCast codiva.io Bartek Filipek ... Oine tools CMake Valgrind GDB Docker Clang Static Analyzer [6 / 37] Things you (probably) already know well [7 / 37] C++ basics variables conversion and casts references implicit pointers explicit functions static statements dynamic loops exceptions declaration function templates initialization class templates operator overloading smart pointers classes basics of the STL constructors & destructor containers fields iterators methods algorithms inheritance building programs types compilation virtual functions linking polymorphism libraries multiple inheritance tools [8 / 37] www.menti.com/32rn4èy3j What is the most important C++ feature? polymorphism templates encapsulation s r e t n i e inheritance o c p n a s w hardware accessibility i e r e s g s n multithreading i a l generic programming c 8 [9 / 37] C++ history [10 / 37] The Design of C++ The Design of C++, a lecture by Bjarne Stroustrup This video has been recorded in March, 1994 [link] The Design of C++ , lecture by Bjarne Stroustr… Do obejrze… Udostępnij [11 / 37] C++ Timeline [link] [12 / 37] C++11/C++14 [13 / 37] Move semantics Value categories (simplied) Special members lvalue T::T(const T&& other) or T::T(T&& other) T& operator=(T&& other) e.g.
    [Show full text]
  • Operating System Lab Manual
    OPERATING SYSTEM LAB MANUAL BASICS OF UNIX COMMANDS Ex.No:1.a INTRODUCTION TO UNIX AIM: To study about the basics of UNIX UNIX: It is a multi-user operating system. Developed at AT & T Bell Industries, USA in 1969. Ken Thomson along with Dennis Ritchie developed it from MULTICS (Multiplexed Information and Computing Service) OS. By1980, UNIX had been completely rewritten using C langua ge. LINUX: It is similar to UNIX, which is created by Linus Torualds. All UNIX commands works in Linux. Linux is a open source software. The main feature of Linux is coexisting with other OS such as windows and UNIX. STRUCTURE OF A LINUXSYSTEM: It consists of three parts. a)UNIX kernel b) Shells c) Tools and Applications UNIX KERNEL: Kernel is the core of the UNIX OS. It controls all tasks, schedule all Processes and carries out all the functions of OS. Decides when one programs tops and another starts. SHELL: Shell is the command interpreter in the UNIX OS. It accepts command from the user and analyses and interprets them 1 | P a g e BASICS OF UNIX COMMANDS Ex.No:1.b BASIC UNIX COMMANDS AIM: To study of Basic UNIX Commands and various UNIX editors such as vi, ed, ex and EMACS. CONTENT: Note: Syn->Syntax a) date –used to check the date and time Syn:$date Format Purpose Example Result +%m To display only month $date+%m 06 +%h To display month name $date+%h June +%d To display day of month $date+%d O1 +%y To display last two digits of years $date+%y 09 +%H To display hours $date+%H 10 +%M To display minutes $date+%M 45 +%S To display seconds $date+%S 55 b) cal –used to display the calendar Syn:$cal 2 2009 c)echo –used to print the message on the screen.
    [Show full text]
  • CENG328 Operating Systems Laboratory Chapter 7
    CENG328 Operating Systems Laboratory Chapter 7 1 File System Unix and Linux based operating systems use specific filesystems (ext2 / ext3 / ext4, xfs, btrfs, etc) for storing files, directories and other filesystem objects such as links, pipes and sockets. These filesystems usually store information such as filename, size, inode number, owning user / group info, access modes, timestamps, etc. When listing files with ls command, these different file types can be recognized by the first character next to the permissions: • Regular File: Stores data (text, image, audio...) that can be read/written by programs. Denoted by \-" sign. • Directory: A data structure that stores other files, directories, etc. Denoted by \d" sign. • Link: A softlink (symlink) is a file that acts as a pointer to another file. Denoted by \l" sign. • Socket: A filesystem-level IPC method to establish communication between processes. Denoted by \s" sign. • Pipe: A filesystem-level IPC method to establish communication between processes. Denoted by \p" sign. • Character device: A device which the driver communicates with single characters. Denoted by \c" sign. • Block device: A device which the driver communicates with blocks of data. Denoted by \b" sign. $ ls drwxrwxr-x 2 user user 4096 May 3 18:29 backups lrwxrwxrwx 1 user user 6 May 3 18:29 list -> list.1 -rw-rw-r-- 1 user user 132 May 3 18:29 list.0 -rw-rw-r-- 1 user user 218 May 3 18:29 list.1 -rw-rw-r-- 1 user user 63 May 3 18:29 list.2 brw-rw---- 1 root disk 7, 6 Apr 24 10:11 sda1 prw-rw-r-- 1 user user 0 May 3 18:29 somepipe
    [Show full text]