Introduction to Linux

Similar documents
Linux Essentials. Programming and Data Structures Lab M Tech CS First Year, First Semester

Introduction to the Linux Command Line

CS246 Spring14 Programming Paradigm Notes on Linux

Unix Filesystem. January 26 th, 2004 Class Meeting 2

Unix/Linux Basics. Cpt S 223, Fall 2007 Copyright: Washington State University

Unix File System. Class Meeting 2. * Notes adapted by Joy Mukherjee from previous work by other members of the CS faculty at Virginia Tech

CSCI 2132 Software Development. Lecture 4: Files and Directories

Week 2 Lecture 3. Unix

Using UNIX. -rwxr--r-- 1 root sys Sep 5 14:15 good_program

Basic UNIX commands. HORT Lab 2 Instructor: Kranthi Varala

A Brief Introduction to Unix

CENG 334 Computer Networks. Laboratory I Linux Tutorial

Files

Introduc)on to Linux Session 2 Files/Filesystems/Data. Pete Ruprecht Research Compu)ng Group University of Colorado Boulder

Introduction: What is Unix?

The Linux Command Line & Shell Scripting

Chapter-3. Introduction to Unix: Fundamental Commands

CHAPTER 1 UNIX FOR NONPROGRAMMERS

Introduction to Linux

An Introduction to Using the Command Line Interface (CLI) to Work with Files and Directories

Lab Working with Linux Command Line

commandname flags arguments

Getting your department account

Unix L555. Dept. of Linguistics, Indiana University Fall Unix. Unix. Directories. Files. Useful Commands. Permissions. tar.

Commands are in black

Files and Directories

Unix Basics. Benjamin S. Skrainka University College London. July 17, 2010

Introduction to the UNIX command line

LAB 8 (Aug 4/5) Unix Utilities

Introduction to Unix: Fundamental Commands

Working with Basic Linux. Daniel Balagué

LAB 8 (Aug 4/5) Unix Utilities

Introduction to UNIX command-line

When talking about how to launch commands and other things that is to be typed into the terminal, the following syntax is used:

acmteam/unix.pdf How to manage your account (user ID, password, shell); How to compile C, C++, and Java programs;

Useful Unix Commands Cheat Sheet

Computer Systems and Architecture

UNIX File Hierarchy: Structure and Commands

Outline. Structure of a UNIX command

Introduction to Linux. Roman Cheplyaka

Crash Course in Unix. For more info check out the Unix man pages -orhttp:// -or- Unix in a Nutshell (an O Reilly book).

Linux Training. for New Users of Cluster. Georgia Advanced Computing Resource Center University of Georgia Suchitra Pakala

Introduction Into Linux Lecture 1 Johannes Werner WS 2017

CS Unix Tools. Lecture 2 Fall Hussam Abu-Libdeh based on slides by David Slater. September 10, 2010

LOG ON TO LINUX AND LOG OFF

CISC 220 fall 2011, set 1: Linux basics

Introduction to Linux Workshop 1

CS 3410 Intro to Unix, shell commands, etc... (slides from Hussam Abu-Libdeh and David Slater)

CSC209. Software Tools and Systems Programming.

CSE Linux VM. For Microsoft Windows. Based on opensuse Leap 42.2

Exercise Sheet 2. (Classifications of Operating Systems)

Linux Refresher (1) 310/ Fourth Workshop on Distributed Laboratory Instrumentation Systems (30 October - 24 November 2006)

Computer Systems and Architecture

Practical Session 0 Introduction to Linux

CS Fundamentals of Programming II Fall Very Basic UNIX

Lecture 3. Unix. Question? b. The world s best restaurant. c. Being in the top three happiest countries in the world.

Table of contents. Our goal. Notes. Notes. Notes. Summer June 29, Our goal is to see how we can use Unix as a tool for developing programs

Essential Linux Shell Commands

Introduction to Linux

Introduction to UNIX command-line II

Linux File System and Basic Commands

Mills HPC Tutorial Series. Linux Basics I

Connecting to ICS Server, Shell, Vim CS238P Operating Systems fall 18

Operating Systems. Copyleft 2005, Binnur Kurt

Operating Systems 3. Operating Systems. Content. What is an Operating System? What is an Operating System? Resource Abstraction and Sharing

CSE 303 Lecture 2. Introduction to bash shell. read Linux Pocket Guide pp , 58-59, 60, 65-70, 71-72, 77-80

Introduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines

Course 144 Supplementary Materials. UNIX Fundamentals

CS CS Tutorial 2 2 Winter 2018

Linux Shell Script. J. K. Mandal

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Mauro Ceccanti e Alberto Paoluzzi

Perl and R Scripting for Biologists

Shell. SSE2034: System Software Experiment 3, Fall 2018, Jinkyu Jeong

EECS2301. Lab 1 Winter 2016

Unix basics exercise MBV-INFX410

Basic Unix. Set-up. Finding Terminal on the imac. Method 1. Biochemistry laboratories Jean-Yves Sgro

A Brief Introduction to the Linux Shell for Data Science

Linux Command Line Primer. By: Scott Marshall

AN INTRODUCTION TO UNIX

Processes. Shell Commands. a Command Line Interface accepts typed (textual) inputs and provides textual outputs. Synonyms:

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Esercitazione Introduzione al linguaggio di shell

Welcome to getting started with Ubuntu Server. This System Administrator Manual. guide to be simple to follow, with step by step instructions

Student Remote Login Procedure (see picture below): 1. Start SSH Secure Shell 2. Click the computer icon (4 th on the toolbar) 3.

Unix as a Platform Exercises + Solutions. Course Code: OS 01 UNXPLAT

Hands-on Keyboard: Cyber Experiments for Strategists and Policy Makers

Introduction of Linux

Unix Workshop Aug 2014

Introduction to Linux Basics

Introduction in Unix. Linus Torvalds Ken Thompson & Dennis Ritchie

CS197U: A Hands on Introduction to Unix

genome[phd14]:/home/people/phd14/alignment >

Oxford University Computing Services. Getting Started with Unix

INSE Lab 1 Introduction to UNIX Fall 2017

UNIX COMMANDS AND SHELLS. UNIX Programming 2015 Fall by Euiseong Seo

Introduction p. 1 Who Should Read This Book? p. 1 What You Need to Know Before Reading This Book p. 2 How This Book Is Organized p.

1. What statistic did the wc -l command show? (do man wc to get the answer) A. The number of bytes B. The number of lines C. The number of words

CSCI 2132 Software Development. Lecture 5: File Permissions

Introduction to Linux Basics Part I. Georgia Advanced Computing Resource Center University of Georgia Suchitra Pakala

Multiple Choice - 58 Questions - 10 of 15%

3/8/2017. Unix/Linux Introduction. In this part, we introduce. What does an OS do? Examples

Transcription:

Introduction to Linux M Tech CS I 2015-16 Arijit Bishnu Debapriyo Majumdar Sourav Sengupta Mandar Mitra

Login, Logout, Change password $ ssh, ssh X secure shell $ ssh www.isical.ac.in $ ssh 192.168 $ logout, exit, ^d $ passwd change password 2

Files and directories (folders) / root directory /bin /usr.. /home ls cp.. /home/arijit arijit.. mandar research teaching File 1 File n /home/arijit/research 3

Files and directories (folders) / root directory.. /bin /usr.. /home ls cp.. For each user, also used as ~ mtc.. mtc. pdslab int2prog File 1 File n ~/pdslab 4

Files and directories $ pwd Present working directory ~, pdslab/day3/ Rela6ve path /home/username, /matlab/ / Absolute path 5

Files and directories. The current directory.. The parent directory Use of rela6ve path $ cd ~/pdslab/day2 What will happen if we type - - $ cd day3 $ cd./day3 $ cd../day3 6

Files and directories $ ls List the contents Owner Group Last modified $ ls -l Total 11 drwxr-xr-x 8 deb staff 272 Jul 11 11:34 Applications drwxr-xr-x 5 deb staff 170 Jun 26 23:23 Backup drwx------ 4 deb staff 136 Jul 15 11:04 Desktop drwx------ 6 deb staff 204 Jun 30 13:25 Documents drwx------ 46 deb staff 1564 Jul 31 12:42 Downloads drwx------ 17 deb staff 578 Jul 31 13:23 Dropbox drwx------ 8 deb staff 272 Jul 30 12:07 Google Drive drwx------ 54 deb staff 1836 Jul 21 12:48 Library drwxrwxrwx 23 deb staff 782 Jul 26 17:23 Softwares drwx------ 3 deb staff 102 Jun 26 13:04 Movies drwx------ 3 deb staff 102 Jun 26 13:04 Music What are these? 7

Permissions Three types of permissions Read (r): Can read the contents of a file or see the contents (list of files) in a directory Write (w): Can edit a file, can put a file in the directory or delete a file in that directory Execute (x): Can execute an executable file. Can go inside (cd) a directory. Groups: I, we and they Indicates file or directory. d for directory, - for file. Permissions for the owner of the file (I). In this case, the owner can do everything drwxr-xr-x Permission for the group (us). In this case everyone in group staff can read or execute, but cannot write. Permission for everyone else (they). In this case everyone else can read or execute, but cannot write. 8

Change permission (chmod) $ ls -l Total 4 drwxr-xr-x 8 deb staff 272 Jul 11 11:34 Applications drwxr-xr-x 5 deb staff 170 Jun 26 23:23 Backup drwx------ 4 deb staff 136 Jul 15 11:04 Desktop -rwx------ 6 deb staff 204 Jun 30 13:25 Notes.txt $ chmod g+w filename Give the group w (write) permission $ chmod o-rwx filename Remove read, write and execute permission from others 9

Permissions: make things easier Three types of permissions: assign bit values to each Read (r): 3 rd bit = 4 Write (w): 2 nd bit = 2 Execute (x): 1 st bit = 1 Example: rwx = 7, rw- = 6, Indicates file or directory. d for directory, - for file. Permissions for the owner of the file (I). In this case, the owner can do everything d421401401 drwxr-xr-x Permission for the group (us). In this case everyone in group staff can read or execute, but cannot write. Permission for everyone else (they). In this case everyone else can read or execute, but cannot write. 10

Change permission (chmod) $ ls -l Total 4 drwxr-xr-x 8 deb staff 272 Jul 11 11:34 Applications drwxr-xr-x 5 deb staff 170 Jun 26 23:23 Backup drwx------ 4 deb staff 136 Jul 15 11:04 Desktop -rwx------ 6 deb staff 204 Jun 30 13:25 Notes.txt $ chmod g+w filename Give the group w (write) permission $ chmod o-rwx filename Remove read, write and execute permission from others $ chmod 700 filename All permissions to the user, nothing to the group and others 11

Create and remove (delete) $ mkdir directoryname MAKE the directory $ rmdir directoryname REMOVE the directory You cannot REMOVE a non- empty directory $ rm filename REMOVE the file $ rm -i, rm -f REMOVE interac6vely, or by FORCE!! 12

Contents of a @ile $ more filename $ less filename less is less work. J $ cat filename From the word concatenate prints the whole content onto the screen. $ head filename Head of the file. Also try head - 10, head - 20, $ tail filename Tail of the file. Also try tail - 10, tail - 30, 13

Copy, move $ cp file copy_of_file Copy the content of the file $ mv file different_name Rename / move the file. Which one should take less 6me for big files? $ cp file1 file2 $ rm file1 mv does not copy and delete the older file, simply changes the pointer 14

What am I executing? $ ls Where is this ls? $ which ls /usr/bin/ls /usr/bin is in the path $ prog1.o $./prog1.o If. (dot, the current directory) is in the path, then the first command will work. To ensure that you are execu6ng the program in your current directory, and not something else, specify the loca6on 15

Input, output $ echo Hi this is me! Prints Hi this is me! $ echo Hi this is me! > test.txt Redirects the output to the file. If the file exists, it is overwri]en. $./prog1.o > output.txt 2> error.txt Redirect STDOUT and STDERR $./prog1.o < in.txt > out.txt 2> err.txt Take input from in.txt $ echo 1 2 3 4 5./prog1.o Print 1 2 3 4 5 and use that as the input for the program 16

Exercise Suppose there is a file <file> containing 100 lines. Using head and tail, show the lines 91-95 only. You have a directory named pdslab and under that you have a file named sharednotes.txt. You want to allow your friends (same group) to read the notes, but do not want them to see what other files are present in the pdslab directory. What permissions should you set for your home directory, pdslab directory and the file sharednotes.txt? 17

Summary of commands Command pwd cd <dir> mkdir <dir> man <command> ls ls - la, ls - l, ls - l <dir> cat <file> Use Prints the present working directory Change directory (go to) to <dir> Create a directory <dir> under the present working directory Manual page for the command <command>. Press q to quit. List contents of the present working directory List contents, with details. By default hidden files (starhng with a.) are not shown. The - a ophon shows all files including hidden files. List contents of the <dir>. Default is present working directory. Show contents of the file within the terminal 18

Summary of commands Command passwd cat <file> more <file>, less <file> cp <source_file> <deshnahon_file> rm <file> mv <file> <deshnahon_file> Use Change password Print contents of the file within the terminal, all at one go. Print contents of the file on the terminal, allows you to go back and forward. Learn the difference between more and less yourself. Press q to quit. Creates a copy of <source_file> to <deshnahon_file> Remove (delete) <file>. Use - i ophon for interachve delete. Move file to another name. mv <file> <deshnahon_directory> Move <file> from the current posihon to the <deshnahon_directory> 19

Summary of commands Command chmod <arg> <filename> which <command> head <file> tail <file> wc <file> sort <file> Use Change permissions for the file (or directory) Show the full path of the command Show the top (default 10) lines of <file>. Use head - 20 <file> for showing 20 lines, for example Show the last (default 10) lines of <file>. Similar to head, use tail - N for any number N. Show the number of lines, words of a file. Use ophons - l, - w etc for specific outputs. Sort the lines of the file by lexicographic order (default). Sort is a very powerful tool with many ophons, learn later. 20

For another day $ grep $ find $ diff $ sort $ ps $ top $ sed $ awk 21