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

Similar documents
Introduction to Linux

Unix Filesystem. January 26 th, 2004 Class Meeting 2

Chapter Two. Lesson A. Objectives. Exploring the UNIX File System and File Security. Understanding Files and Directories

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

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

CS246 Spring14 Programming Paradigm Notes on Linux

CSCI 2132 Software Development. Lecture 4: Files and Directories

A Brief Introduction to Unix

Chapter-3. Introduction to Unix: Fundamental Commands

EECS2301. Lab 1 Winter 2016

Getting your department account

GNU/Linux 101. Casey McLaughlin. Research Computing Center Spring Workshop Series 2018

Introduction to the Linux Command Line

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

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

Introduction to Linux. Roman Cheplyaka

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

Introduction to Unix: Fundamental Commands

Files

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

Introduction: What is Unix?

CISC 220 fall 2011, set 1: Linux basics

Introduction of Linux

Unix System Architecture, File System, and Shell Commands

Computer Systems and Architecture

Commands are in black

Lab Working with Linux Command Line

UNIX File Hierarchy: Structure and Commands

Introduction Into Linux Lecture 1 Johannes Werner WS 2017

Introduction to the UNIX command line

THE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering

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

CENG 334 Computer Networks. Laboratory I Linux Tutorial

Outline. Structure of a UNIX command

Week 2 Lecture 3. Unix

Overview LEARN. History of Linux Linux Architecture Linux File System Linux Access Linux Commands File Permission Editors Conclusion and Questions

commandname flags arguments

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

The landscape. File hierarchy overview. A tree structure of directories The directory tree is standardized. But varies slightly among distributions

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

Files and Directories

M.C.A. (Sem.-lll) (CBCS) Examination November CCA-3003 Operating System and LinuxlUnix programming

Introduction to UNIX command-line

Introduction to Linux

LAB 8 (Aug 4/5) Unix Utilities

LAB 8 (Aug 4/5) Unix Utilities

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

Perl and R Scripting for Biologists

Please choose the best answer. More than one answer might be true, but choose the one that is best.

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

CS197U: A Hands on Introduction to Unix

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

INTRODUCTION TO LINUX

Overview of the UNIX File System

Basic UNIX commands. HORT Lab 2 Instructor: Kranthi Varala

Essential Unix and Linux! Perl for Bioinformatics, ! F. Pineda

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

You will automatically be in your user (home) directory when you login.

Filesystem Hierarchy and Permissions

Assume that username is cse. The user s home directory will be /home/cse. You may remember what the relative pathname for users home directory is: ~

The Linux Command Line & Shell Scripting

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

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

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

MA 511: Computer Programming Lecture 23 Partha Sarathi Mandal

Unix Workshop Aug 2014

Useful Unix Commands Cheat Sheet

UNIX System Programming Lecture 3: BASH Programming

Operating Systems. Engr. Abdul-Rahman Mahmood MS, PMP, MCP, QMR(ISO9001:2000) alphapeeler.sf.net/pubkeys/pkey.htm

Linux Kung-Fu. James Droste UBNetDef Fall 2016

(a) About Unix. History

CHAPTER 1 UNIX FOR NONPROGRAMMERS

CSC209. Software Tools and Systems Programming.

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

Filesystem Hierarchy and Permissions

Introduction to Linux

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

Introduction to Linux. Woo-Yeong Jeong Computer Systems Laboratory Sungkyunkwan University

Introduction to remote command line Linux. Research Computing Team University of Birmingham

Presented by Bill Genske Gary Jackson

Practical Session 0 Introduction to Linux

CS Fundamentals of Programming II Fall Very Basic UNIX

Overview of the UNIX File System. Navigating and Viewing Directories

INF322 Operating Systems

Linux Operating System Environment Computadors Grau en Ciència i Enginyeria de Dades Q2

Introduction to Linux Part I: The Filesystem Luca Heltai

Linux Shell Script. J. K. Mandal

Introduction to Linux Workshop 1

ScazLab. Linux Scripting. Core Skills That Every Roboticist Must Have. Alex Litoiu Thursday, November 14, 13

Introduction to Linux

Introduction to Linux Basics

Exercise Sheet 2. (Classifications of Operating Systems)

Linux Systems Administration Getting Started with Linux

Getting Started with Linux

Topics. Installation Basics of Using GNU/ Linux Administration Tools

Introduction to Linux

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

Linux Command Line Primer. By: Scott Marshall

The Unix Shell & Shell Scripts

Course 144 Supplementary Materials. UNIX Fundamentals

Transcription:

Linux Essentials Programming and Data Structures Lab M Tech CS First Year, First Semester Adapted from PDS Lab 2014 and 2015

Login, Logout, Password $ ssh mtc16xx@192.168.---.--- $ ssh X mtc16xx@192.168.---.--- Secure shell login to your account on the server $ logout, exit, ^d Logout from your account $ passwd or yppasswd Change password of your account

Files and Directories / root directory /bin /boot /etc /usr /var EssenGal Binaries StaGc files of Boot Loader Host-specific System Config Shareable and Read-only Data Variable Data Files /sbin /tmp /dev /lib /mnt System Binaries Temporary Files Deleted at Boot Special or Device Files Library and Kernel modules Mount for temp File systems /opt Add-on Apps and SoQware /root Home directory for Root User /home User Home Directories /user1 User Home Directories Your Home Directories are located under /user1

Files and Directories / root directory /bin /root /home /user1 EssenGal Binaries Home directory for Root User User Home Directories User Home Directories ls cp cat Your Home Directory is located at /user1/mtc16/mtc16xx This is where you reach when you login with ssh, or when you execute cd /mtc16 /mtc1601 /mtc1601 /mtc1624

Create and Remove Directories $ mkdir dfslab MAKE the directory dfslab under your home $ rmdir dfslab REMOVE the directory dfslab from your home You cannot REMOVE a non-empty directory $ touch hello.txt CREATE the file hello.txt under your home touch does not put any content $ rm hello.txt REMOVE the file avoid if possible, unless you are really sure about your decision $ rm -i, rm -f REMOVE interackvely, or by FORCE it is way safer to use the interackve mode

Files and Directories $ mkdir dfslab Create directory dfslab and then the directory structure as on the website $ pwd Present working directory dfslab/ RelaKve path to your dfslab directory from home /user1/mtc16/mtc16xx/dfslab/ Absolute path to your dfslab directory ~/dfslab/ ~ acts a shorthand for your home at /user1/mtc16/mtc16xx

Files and Directories. The current directory.. The parent directory Use of relakve path $ cd ~/dfslab/pds20160720 Check what happens if you execute $ cd pds20160720 $ cd./pds20160720 $ cd../pds20160720

Files and Directories $ ls List the contents of the current directory $ 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 access permissions owner group last modified on file or directory name

Permissions drwxr-xr-x 4 mtc1601 501 23 Jul 20 15:30 dfslab -rwxr--r-- 1 mtc1601 501 12 Jun 20 15:50 hello.txt There are 3 entities Owner, Group and Others There are 3 permissions Read, Write and Execute Thus, there are 9 bits to control the permissions drwxr-xr-x -rwxr--r-- d denotes Directory - denotes File Owner rwx 111 = 7 Owner rwx 111 = 7 Group r-x 101 = 5 Group r-- 100 = 4 Other r-x 101 = 5 Other r-- 100 = 4 $ chmod 700 dfslab Change the permission of dfslab to 700 from 755 prevents access of anyone else Common permissions 755 (directories), 744 (files), 700

Read Contents of a File $ more hello.txt $ less hello.txt Shows the contents of the file -- less is less work J $ cat hello.txt Concatenate prints the whole content onto the screen $ head hello.txt $ head n 7 hello.txt Head of the file default first 10 lines your may specify $ tail hello.txt $ tail n 7 hello.txt Tail of the file default last 10 lines you may specify

Copy or Move a File $ cp hello.txt hellocopy.txt Copy the content of the file creates a new file $ mv hello.txt hellocopy.txt Rename or move the file simply changes the pointer $ cp filename anotherfile $ mv filename anotherfile Which one should take less Kme for big files? $ cp filename directoryname Creates a copy the file in the directory provided the directory exists $ mv filename directoryname Moves the file to the directory provided the directory exists

What am I executing? $ ls Where is this ls binary can you find out? $ which ls /usr/bin/ls /usr/bin is in the PATH hence ls executes $ prog1.o $./prog1.o If the current directory, that is. (dot), is in the PATH, then the first command will work. If not, use the second one, which specifies the locakon of prog1.o. Note : To ensure that you are execukng the program in your current directory, typically the one that you have compiled, and not something else, specify./

Input and Output $ echo Hi this is me! Prints Hi this is me! on the terminal (stdout) $ echo Hi this is me! > test.txt Redirects the output (stdout) to the file. If the file exists, it is overwriaen. $./prog1.o > output.txt 2> error.txt Redirects output (stdout) to output.txt and error (stderr) to error.txt $./prog1.o < in.txt > out.txt 2> err.txt Takes input from in.txt, outputs to out.txt, and records errors in err.txt $ echo 1 2 3 4 5./prog1.o Prints 1 2 3 4 5 and uses (pipes) that as the input for the program prog1.o

Unix Commands Useful References: hwp://www.ucs.cam.ac.uk/docs/leaflets/u5 hwp://mally.stanford.edu/~sr/compugng/basic-unix.html hwp://www.math.utah.edu/lab/unix/unix-commands.html Unix/Bash Cheat-sheets: hwps://ubuntudanmark.dk/filer/fwunixref.pdf hwp://cli.learncodethehardway.org/bash_cheat_sheet.pdf $ man <command> System manual pages to describe the command in detail

Later $ grep $ find $ diff $ sort $ ps $ top $ sed $ awk