CENG 334 Computer Networks. Laboratory I Linux Tutorial

Similar documents
CENG393 Computer Networks Labwork 1

Contents. Note: pay attention to where you are. Note: Plaintext version. Note: pay attention to where you are... 1 Note: Plaintext version...

Introduction: What is Unix?

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

LOG ON TO LINUX AND LOG OFF

Getting Started With UNIX Lab Exercises

Introduction to the UNIX command line

Linux Shell Script. J. K. Mandal

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

CS CS Tutorial 2 2 Winter 2018

Essential Linux Shell Commands

Practical Session 0 Introduction to Linux

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

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

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

Computer Systems and Architecture

Introduction to the Linux Command Line

Helsinki 19 Jan Practical course in genome bioinformatics DAY 0

Exercise Sheet 2. (Classifications of Operating Systems)

Introduction of Linux

The Unix Shell & Shell Scripts

User Guide Version 2.0

UNIX Essentials Featuring Solaris 10 Op System

CSCE 212H, Spring 2008, Matthews Lab Assignment 1: Representation of Integers Assigned: January 17 Due: January 22

Introduction to Linux for BlueBEAR. January

commandname flags arguments

Introduction to Linux

Mills HPC Tutorial Series. Linux Basics I

CS Fundamentals of Programming II Fall Very Basic UNIX

Introduction to Linux

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

This lab exercise is to be submitted at the end of the lab session! passwd [That is the command to change your current password to a new one]

Introduction to Linux Part 1. Anita Orendt and Wim Cardoen Center for High Performance Computing 24 May 2017

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

CSE 303 Lecture 4. users/groups; permissions; intro to shell scripting. read Linux Pocket Guide pp , 25-27, 61-65, , 176

Introduction to Linux

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

CST8207: GNU/Linux Operating Systems I Lab Six Linux File System Permissions. Linux File System Permissions (modes) - Part 1

Tutorial 1: Unix Basics

Introduction to Unix The Windows User perspective. Wes Frisby Kyle Horne Todd Johansen

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

Chapter-3. Introduction to Unix: Fundamental Commands

History. Terminology. Opening a Terminal. Introduction to the Unix command line GNOME

Introduction to Linux Workshop 1

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

Computer Systems and Architecture

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

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

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

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

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

Unix Filesystem. January 26 th, 2004 Class Meeting 2

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

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.

Exploring UNIX: Session 3

A Brief Introduction to the Linux Shell for Data Science

Part I. Introduction to Linux

Unix Introduction to UNIX

Linux Exercise. pwd answer: We call this directory (into which you get when you log in) your home directory.

Exercise 1: Basic Tools

Perl and R Scripting for Biologists

Introduction to Unix: Fundamental Commands

Files

Session 1: Accessing MUGrid and Command Line Basics

Unix basics exercise MBV-INFX410

Part 1: Basic Commands/U3li3es

The Shell. EOAS Software Carpentry Workshop. September 20th, 2016

COSC UNIX. Textbook. Grading Scheme

Commands are in black

Practical 02. Bash & shell scripting

Week 2 Lecture 3. Unix

AMS 200: Working on Linux/Unix Machines

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

5/20/2007. Touring Essential Programs

Unix Tutorial Haverford Astronomy 2014/2015

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

INSE Lab 1 Introduction to UNIX Fall 2017

DAVE LIDDAMENT INTRODUCTION TO BASH

A Hands-On Tutorial: RNA Sequencing Using High-Performance Computing

Chap2: Operating-System Structures

Lab Working with Linux Command Line

INd_rasN SOME SHELL SCRIPTING PROGRAMS. 1. Write a shell script to check whether the name passed as first argument is the name of a file or directory.

A Brief Introduction to Unix

Linux & Shell Programming 2014

More Raspian. An editor Configuration files Shell scripts Shell variables System admin

Brief Linux Presentation. July 10th, 2006 Elan Borenstein

EE516: Embedded Software Project 1. Setting Up Environment for Projects

Getting Started with UNIX

Laboratory 1 Semester 1 11/12

: the User (owner) for this file (your cruzid, when you do it) Position: directory flag. read Group.

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

Physics REU Unix Tutorial

Read the relevant material in Sobell! If you want to follow along with the examples that follow, and you do, open a Linux terminal.

CS246 Spring14 Programming Paradigm Notes on Linux

COMS 6100 Class Notes 3

MTU Computer Structure

DEPARTMENT OF MATHEMATICS. RAMLab User Guide. An Introduction to the Ryerson Applied Mathematics Laboratory

UNIT 9 Introduction to Linux and Ubuntu

Unix/Linux Operating System. Introduction to Computational Statistics STAT 598G, Fall 2011

Transcription:

CENG 334 Computer Networks Laboratory I Linux Tutorial

Contents 1. Logging In and Starting Session 2. Using Commands 1. Basic Commands 2. Working With Files and Directories 3. Permission Bits 3. Introduction to Shell Scripting

1. Logging In and Starting Session Logging in to a Linux based operating system requires a username and a password. Both the username and the password are case sensitive so pay attention whether Caps Lock is on or not. If you have entered your information correctly, your desktop will be shown.

1. Logging In and Starting Session Each Linux based operating system (Debian, Ubuntu, Kubuntu, Pardus, Fedora,... ) may present different user interfaces and applications but common operations can be performed in a similar manner on each system.

2. Using Commands This laboratory manual will help you learn the basic Unix commands. You are expected to exercise each command on the following slides. For your own benefit, do not copy and paste the commands. You must first open a Konsole application to try the commands. In order to do so, click on the menu button on the bottom left corner of the screen and start typing "konsole". When you see the application, click on its icon. As with your username and password, commands are case sensitive too, so type them exactly as you see.

2.1. Basic Commands date displays the current date and time. whoami displays the login name of the current user. echo tells the computer to retype the string after echo. Try the following: echo This is a test echo $USER What is the output now? What is $USER? You can combine variables with strings: echo Hello $USER echo 2 + 2 = $((2+2)) What is the output of $((2+2))?

2.2. Working With Files and Directories ls -l lists the files and directories in the working directory. cd <directory name> - used for changing the working directory. pwd (print working directory) tells in which directory the user currently is. Try cd Desktop. Then try pwd. What is different now? cat > services.txt ftp 21 tcp ssh 22 tcp http 80 tcp http 80 udp https 443 tcp https 443 udp <ctrl d> By <ctrl d> we mean: hold the Ctrl key down and while it is down press d. We have just used cat to create a short list of common TCP/UDP ports.

2.2. Working With Files and Directories cat services.txt shows us what is in the file dict.txt. wc services.txt counts words, lines and characters (letters) in a given file. grep tcp services.txt looks for the word tcp in the file services.txt and displays the lines in which this word appears. It gives us a way to search through files. sort services.txt command does just what it says. sort services.txt > services2.txt Note the use of the "into" symbol ">". In our example it had the effect of directing the output of the sort command from screen to the file services2.txt. Use ls to check if both files are available cat services2.txt be sure that the content is correct.

2.2. Working With Files and Directories mkdir services (make directory), create a new directory named letters. mv services.txt services2.txt services move both files into the services directory. cd letters work inside the letters directory. pwd ls rm services.txt services2.txt remove both files. cd.. to go to the upper directory. pwd rmdir services remove services directory. You can delete only empty directories or rmdir will fail.

2.2. Working With Files and Directories man manual/help, to read detailed information about commands. Try: man <commandname> man ls Displays detailed information about ls command. Find which parameter is used for sorting by modification time. To quit man simply type the letter q.

2.3. Permission Bits ls -l <filename> - will list the long directory list entry (which includes owner and permission bits) and the group of a file. The output looks something like: permission owner group size date time filename -rw-rw-r-- 1 student students 65536 2012-02-12 17:39 commands.html The Permission Bits; The first position (which is not set) specifies what type of file this is. If it were set, it would probably be a d (for directory) or l (for link). The next nine positions are divided into three sets of binary numbers and determine permissions for three different sets of people.

2.3. Permission Bits u g o 421 421 421 rw- r-- --- 6 4 0 The file has "mode" 640. The first bits, set to "r + w" (4+2=6) in our example, specify the permissions for the user who owns the files (u). The user who owns the file can read or modify (including deleting) the file. The next trio of bits, set to "r" (4) in our example, specify access to the file for other users in the same group (g) as the group of the file. In this case the group is students all members of the students group can read the file (print it, copy it, or display it). Finally, all other users (o) are given no access (0) to the file.

2.3. Permission Bits u g o 421 421 421 rw- r-- --- 6 4 0 One form of access which no one is given, even the owner, is "x" (for execute). This is because the file is not a program to be executed. It is probably a text file which would have no meaning to the computer. The x would appear in the third position if it was an executable file. If you wanted to make the file readible to all other users, you could type: chmod 644 <filename> or chmod o+r <filename>.

3. Introduction to Shell Scripting Instead of typing commands into shell one by one, you can also create text files which contain these commands. Type the following: cat > hello.sh #!/bin/bash # this is a simple shell script which greets the user # and displays date echo "Hello! The date and time is:" date <ctrl-d> Check the file you just have created with ls -l. You should note that your file does not have execution permissions, so you should fix it with chmod +x hello.sh. Now you can execute this simple script with./hello.sh. The first line is a must for all shell scripts, It defines which shell interpreter will execute this script. In this case it is /bin/bash. The next two lines are comments, they will never be executed and their only purpose is to inform the user.

3. Introduction to Shell Scripting Below is an another script which demonstrates usage of parameters: #!/bin/bash COURSE="CENG 334" echo "Hello $1, welcome to $COURSE." echo "Your username is $USER and $2 is your student ID." Save this script to hello2.sh. Then run it as:./hello2.sh "your name" number In this example, we have used three different variables: COURSE: a local variable which exists as long as the script runs. USER: An environmental variable which is defined by the system. $1, $2...: Command line arguments.