Working with Basic Linux. Daniel Balagué

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

Unix Filesystem. January 26 th, 2004 Class Meeting 2

Unix background. COMP9021, Session 2, Using the Terminal application, open an x-term window. You type your commands in an x-term window.

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

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

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

Basic Survival UNIX.

Linux Command Line Primer. By: Scott Marshall

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

Lab Working with Linux Command Line

Introduction to the Linux Command Line

Mills HPC Tutorial Series. Linux Basics I

Unix Introduction to UNIX

Hitchhiker s Guide to VLSI Design with Cadence & Synopsys

A Brief Introduction to the Linux Shell for Data Science

CISC 220 fall 2011, set 1: Linux basics

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

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

CHAPTER 1 UNIX FOR NONPROGRAMMERS

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

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

Perl and R Scripting for Biologists

Introduction to the UNIX command line

Basic UNIX commands. HORT Lab 2 Instructor: Kranthi Varala

Computer Systems and Architecture

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

UTA Tech Orientation Spring 2019

CS/CIS 249 SP18 - Intro to Information Security

CS Fundamentals of Programming II Fall Very Basic UNIX

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

INTRODUCTION TO LINUX

Linux File System and Basic Commands

Introduction: What is Unix?

Introduction to Linux Basics

Introduction to Linux

First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion.

Exploring UNIX: Session 3

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

Linux Tutorial #6. -rw-r csce_user csce_user 20 Jan 4 09:15 list1.txt -rw-r csce_user csce_user 26 Jan 4 09:16 list2.

Intro to Linux. this will open up a new terminal window for you is super convenient on the computers in the lab

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

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

Table Of Contents. 1. Zoo Information a. Logging in b. Transferring files 2. Unix Basics 3. Homework Commands

Commands are in black

CS197U: A Hands on Introduction to Unix

12/7/10 ATSC 212 UNIX ATSC 212 ATSC 212 UNIX

Essential Linux Shell Commands

Week 2 Lecture 3. Unix

5/8/2012. Creating and Changing Directories Chapter 7

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

Introduction to Linux Workshop 1

Exercise Sheet 2. (Classifications of Operating Systems)

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

Introduction to Linux

EECS Software Tools. Lab 2 Tutorial: Introduction to UNIX/Linux. Tilemachos Pechlivanoglou

SECTION -C. Getting Started with UNIX

Chapter-3. Introduction to Unix: Fundamental Commands

UNIX File Hierarchy: Structure and Commands

Introduction to Unix: Fundamental Commands

Introduction to Linux Spring 2014, Section 02, Lecture 3 Jason Tang

Outline. Structure of a UNIX command

Computer Systems and Architecture

CSCI 2132 Software Development. Lecture 5: File Permissions

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

Chap2: Operating-System Structures

Introduction of Linux

Some Linux (Unix) Commands that might help you in ENSC351

Introduction to Unix and Linux. Workshop 1: Directories and Files

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

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

An Introduction to Cluster Computing Using Newton

Files and Directories

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

UNLV Computer Science Department CS 135 Lab Manual

Find out where you currently are in the path Change directories to be at the root of your home directory (/home/username) cd ~

First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion.

National University of Computer and Emerging Sciences Operating System Lab - 02 Lab Manual

Basic Linux Command Line Interface Guide

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

Scripting Languages Course 1. Diana Trandabăț

Introduction to UNIX command-line

Common UNIX Commands. Unix. User Interfaces. Unix Commands Winter COMP 1270 Computer Usage II 9-1. Using UNIX. Unix has a command line interface

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

The Unix Shell & Shell Scripts

COMS 6100 Class Notes 3

Introduction to UNIX. SURF Research Boot Camp April Jeroen Engelberts Consultant Supercomputing

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

Getting started with Hugs on Linux

Physics REU Unix Tutorial

First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion.

Command Line Interface The basics

Files

Linux & Shell Programming 2014

CSE 391 Lecture 1. introduction to Linux/Unix environment

CS246 Spring14 Programming Paradigm Notes on Linux

CSE 390a Lecture 1. introduction to Linux/Unix environment

CST8207: GNU/Linux Operating Systems I Lab Seven Linux User and Group Management. Linux User and Group Management

You should see something like this, called the prompt :

Transcription:

Working with Basic Linux Daniel Balagué

How Linux Works? Everything in Linux is either a file or a process. A process is an executing program identified with a PID number. It runs in short or long duration or even indefinitely. A file is a collection of data, generated by text editor, compiler, running application, etc. A file can be in plain text or in binary, and there are many file formats associated to the application-types. The Linux kernel is responsible for organizing the processes and interacting with files. It allocates time and memory to the processes and handles the file system and communication with files after the system calls.

What is the Shell? HUMAN English: I want to delete this.file Human types on a keyboard: rm this.file MACHINE Shell: translates human to machine & communicates instructions to the Kernel (which performs the actual work)

What is the Shell? The shell is the how you invoke the commands by typing into the terminal. It is interactive but not graphic-based. The shell is really powerful: it allows you to do a lot in just one line. The kernel's job is to talk to the hardware and software, and to manage the system's resources as best as possible.

Warning! Often there is no "undo" option or warnings in the shell. Source: http://www.quickmeme.com/meme/3prykv

What the Linux Shell Does 4 Tasks! 1. Display prompt 2. Read command 3. Process command 4. Execute command / display output And back to 1!

The BASH Shell We have a few shells available, but we are going to work with the BASH shell.

Getting Started! In the next few slides, we will learn: Navigating the file system Managing files and directories Permissions and Groups

Before We Start: There is Always Help If you want to know how a tool works, we can look for more information in the man pages. Just run the command man followed by the tool name. For example, run man man

Files and File Names A file is a basic unit of storage. The name can be long and contain any characters, but typically just choose characters and numbers and - or _ Avoid special characters like., / : ;! * & " and spaces! Linux is case sensitive! There are many types of files: We will explore the file command later.

Some File Commands Command Description ls cp mv clear less grep rm mkdir pwd List out the directory Copy files Move files or rename files Clean the screen Visualize a file (do not open large files with text editors!) searching plain-text data sets for lines matching a regular expression. Remove files (be careful with this command: rm -rf * -- it is one of the most dangerous!) Create directory Know where you are

Hint When you start writing the name of a file, you can press the Tab key to autocomplete it. If there are more than one file that start with the same chain of characters they will be listed.

Example We used pwd to know where we are and then ls to know what we could find in the presentation directory.

More Options for ls Check the output of the following command: ls -lh What does it do? HINT: use man ls

Your Home Directory When you log into the HPC cluster or when you start a terminal session, you are usually starting at your home directory. Since the home directory is so important, there are many ways to go back into it. Here are some commands that will bring you back to home: cd cd ~ cd $HOME cd /home/username wherever you go, you can always come home ;)

Create Directories To create a directory, we use the mkdir command: mkdir directory_name Exercise: create a directory called presentation in your home folder. Solution: cd mkdir presentation

Change the Working Directory to a Different Directory Assume we are in $HOME. We can move into a different directory in two ways. Relative: to change from the home directory into presentation we do cd presentation We are assuming that presentation is inside the home directory Absolute: to change from the current directory into presentation we specify the full path: cd /home/username/presentation

Moving and Renaming Files and Directories Let s create a directory called Section1 into our home folder: cd mkdir Section1 To move the directory Section1 into presentation, we use the command mv mv Section1 presentation To rename a file or directory we use the mv command as well. mv presentation Presentation

Copying Files cd Presentation cp Section1../ Copies the Section1 subdirectory into the parent directory. You could add the flag -r to copy directories recursively.

Permissions (I) As a regular user, try to get into the root s home directory with cd /root We do not have permission to access the root directory. Image source: https://www.memecenter.com/fun/99372/you-shal L-NOT-PASS

Permissions (II) Check the following example: In this example we can observe: Three access types: Read, Write, and execute. The Owner and Group for the the files listed: dxb507 (owner), hpcadmin (group).

Permissions (III) The first column of the output of ln -lh has a meaning. Let s look into more detail at the helloworld.c file: - (rw-) (r--) (r--) Type of file User Group Others The user has granted permission to read and write to the file. The group has permission to read the file as well as the other users in the system. The - (dash) means permission has not been assigned. Types of files: d - a directory. l - a symbolic link to another program or file elsewhere on the system. - (dash) - a regular file (other than directory or link).

Changing Permissions: chmod Sometimes you may not want the other members of your group to read the files. To convert a file into a file just readable and writable by you, use: chmod 600 my_file If you want the whole directory and its contents: chmod -R 600 my_file The -R option stands for recursive. The numbers explained (with an example): User Group Others rwx rw- r-- 111 110 100 These are binary numbers: 111 in binary is 7 in decimal, 110 in binary is 6 in decimal, 100 in binary is 4 in decimal. 764 For 110, you make the conversion like this: 1x2 2 + 1x2 1 + 0x2 0 = 4 + 2 + 0 = 6

Quick Command Using chmod 740 my_file you can rapidly give yourself permission to execute your file.

Groups All users are part of (at least) one group. If you are in multiple groups, you might want to change groups. Sometimes you need to specify your group when submitting a job. Check your current group: Check in which groups you belong: Changing groups: id -ng groups newgrp <different_group_name>

Changing User and Group Ownership: chown Similarly, we can change the user and keep the group for a particular file: chown new_user:same_group my_old_file To change the user and the group: chown new_user:new_group my_old_file (find more options in the man pages).

Thank you! Questions?