Linux Pathnames and Directories

Similar documents
Permissions and Links

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

Essential Linux Shell Commands

UNIX Tutorial One

Operating Systems and Using Linux. Topics What is an Operating System? Linux Overview Frequently Used Linux Commands

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

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

Physics REU Unix Tutorial

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

Overview of the UNIX File System. Navigating and Viewing Directories

Overview of the UNIX File System

Unix Tutorial Haverford Astronomy 2014/2015

You should see something like this, called the prompt :

Introduction to Unix: Fundamental Commands

1 Getting Started with Linux.

Operating System Interaction via bash

Chapter-3. Introduction to Unix: Fundamental Commands

CS Fundamentals of Programming II Fall Very Basic UNIX

A Brief Introduction to the Linux Shell for Data Science

The Directory Structure

CMSC 104 Lecture 2 by S Lupoli adapted by C Grasso

Getting Started with Command Prompts

Examples: Directory pathname: File pathname: /home/username/ics124/assignments/ /home/username/ops224/assignments/assn1.txt

Unix tutorial. Thanks to Michael Wood-Vasey (UPitt) and Beth Willman (Haverford) for providing Unix tutorials on which this is based.

INSE Lab 1 Introduction to UNIX Fall 2017

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

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.

[301] The Terminal. Tyler Caraza-Harter

Lec 1 add-on: Linux Intro

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

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.

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

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

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

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 2: SEP. 8TH INSTRUCTOR: JIAYIN WANG

Principles of Bioinformatics. BIO540/STA569/CSI660 Fall 2010

Module 10: Unix Primer

UNIX File Hierarchy: Structure and Commands

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.

UNIT 9 Introduction to Linux and Ubuntu

CST8207: GNU/Linux Operating Systems I Lab Ten Boot Process and GRUB. Boot Process and GRUB

This is Lab Worksheet 3 - not an Assignment

Commands are in black

Using LINUX a BCMB/CHEM 8190 Tutorial Updated (1/17/12)

Unix File System. Learning command-line navigation of the file system is essential for efficient system usage

PDS Lab Section 16 Autumn Tutorial 1. Unix Commands pwd The pwd command displays the full pathname of the current directory.

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

Files

Introduction of Linux

Filesystem and common commands

Scripting Languages Course 1. Diana Trandabăț

CS 246 Winter Tutorial 1

BIOINFORMATICS POST-DIPLOMA PROGRAM SUBJECT OUTLINE Subject Title: OPERATING SYSTEMS AND PROJECT MANAGEMENT Subject Code: BIF713 Subject Description:

CSCI 2132 Software Development. Lecture 4: Files and Directories

$Id: asg4-shell-tree.mm,v :36: $

Git & Github Fundamental by Rajesh Kumar.

1. Open VirtualBox and start your linux VM. Boot the machine and log in with the user account you created in Lab #1. Open the Terminal application.

Unix Filesystem. January 26 th, 2004 Class Meeting 2

Introduction to Linux Workshop 1

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

Python for Astronomers. Week 1- Basic Python

Introduction to Linux

Introduction to Linux

Appendix B WORKSHOP. SYS-ED/ Computer Education Techniques, Inc.

Practical 4. Linux Commands: Working with Directories

The Unix Shell. Files and Directories

INTRODUCTION TO BIOINFORMATICS

Gradle and Command Line Workshop Activity

Week Overview. Unix file system File types and file naming Basic file system commands: pwd,cd,ls,mkdir,rmdir,mv,cp,rm man pages

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

CMSC 201 Spring 2018 Lab 01 Hello World

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

Oxford University Computing Services. Getting Started with Unix

Files and Directories

Linux & Shell Programming 2014

Operating Systems, Unix Files and Commands SEEM

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

Environment Variables

PROGRAMMAZIONE I A.A. 2015/2016

Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring Topic Notes: C and Unix Overview

Introduction to Linux and Supercomputers

CST Algonquin College 2

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

Linux Command Line Primer. By: Scott Marshall

ENCM 339 Fall 2017: Editing and Running Programs in the Lab

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

Unix/Linux Primer. Taras V. Pogorelov and Mike Hallock School of Chemical Sciences, University of Illinois

CENG 334 Computer Networks. Laboratory I Linux Tutorial

A Big Step. Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers

Introduction: What is Unix?

CS197U: A Hands on Introduction to Unix

Session 1: Accessing MUGrid and Command Line Basics

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

CSE115 Lab exercises for week 1 of recitations Spring 2011

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG

Project #4: Implementing NFS

The Command Shell. Fundamentals of Computer Science

Operating Systems. Copyleft 2005, Binnur Kurt

Scripting. Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers

CSC 112 Lab 1: Introduction to Unix and C++ Fall 2009

Transcription:

Linux Pathnames and Directories Hidden Filenames o Startup Files o The. and.. Directory Entries Pathnames o Absolute o Tilde ~ in Pathnames o Relative In current directory In a subdirectory or an ancestor directory In neither a subdirectory nor an ancestor directory Other Topics o Standard Directories o /home vs. your home directory o Special Uses of / o Special Uses of.

Hidden Filenames A file whose filename begins with a period. is a hidden or "invisible" file ls does not display these files unless you use the -a option You have already seen one such file.forward Two special hidden files. and.. appear in every directory $ ls -a... hw3 work We'll discuss them shortly

Startup Files The following two files are startup files:.login and.bash_profile Startup file contain Unix commands that are run just before you get the first shell prompt o These customize your Unix environment o They only work when placed inside your home directory o They can set variables which can help you with your work We'll talk more about this in a future class

The. and.. Directory Entries Every directory has at least two entries:. and.. When a new directory is created, these entries will always be there o. stands for the current directory o.. stands for the parent directory the directory immediately above your current directory $ pwd /home/ckelly $ cd.. $ pwd /home

The. and.. Directory Entries. is most often used in two circumstances oto run a program located in your current directory oto move or copy a file to your current directory $ ls it244 notes.txt work work2 $ cd work $ ls bletch.txt foo.txt $ cp../notes.txt. $ ls bletch.txt foo.txt notes.txt

Pathnames Every file has a pathname, which is used to access the file A pathname has two components o The name of the file o A path to reach the file A pathname is like an address on a letter: o a name and... o directions to get there The name of the file is always at the end of a pathname What comes before the filename is the path to the directory that holds the file

Pathnames A path is the list of directories you must go through to get to the file When you see a slash, /, to the right of a name it means the name refers to a directory When a path consists of several directories a slash, /, separates the directory names There are two types of pathnames o Absolute o Relative

Absolute Pathnames The top of the filesystem is called the root directory o The root directory is represented by a single slash, / o It can stand alone or appear as the first character before a directory name An absolute path is a list of directories starting with the root directory and ending with the directory that holds the file When you add the filename to the end of an absolute path you have an absolute pathname

Absolute Pathnames The absolute pathname of my startup file,.bash_profile in my home directory is /home/ckelly/.bash_profile This means that my home directory, ckelly, is under the directory named home which is under the root directory / The advantage of an absolute pathname is that it can be used from any part of the filesystem o It does not depend on your current directory The disadvantage is that absolute pathnames tend to be long o It is easy to make a mistake typing an absolute pathname An absolute pathname always begins with either a slash / or a tilde, ~

Absolute Pathnames: Example (User ghoffmn)

Tilde, ~, in Pathnames There is one form of absolute path that is very short This is the tilde character ~ o Tilde stands for the absolute address of your home directory o This means you can use tilde ~ anywhere you would normally use a path to your home directory $ pwd /home/ckelly/it244 $ cd ~ $ pwd /home/ckelly

Tilde ~ in Pathnames When you put a tilde in front of a Unix username it stands for the home directory of that account $ cd ~ckelly $ pwd /home/ckelly

Relative Pathnames Absolute pathnames are useful because you can use them anywhere But they are long and easy to mistype It is easier to use relative pathnames In a relative pathname the path starts from your current directory In an absolute pathname the path starts from the root directory, / The only difference between an absolute and a relative path is where they start

Relative Pathnames An address on a letter is like an absolute pathname If you address a letter to me at... Chris Kelly 99 Boylston Street Boston, MA 02116 USA...then you can mail it to me anywhere in the world and it will get to me

Relative Pathnames If someone asked me the directions to the men's room from the Web Lab I would say Go out the door Turn left Take you first door on the right These directions only work from the Web Lab This is similar to a relative path

Relative Pathnames All absolute pathnames start with a slash / or a tilde, ~ However, relative pathnames never do The absence of a slash / or a tilde ~ at the start of a pathname means it is a relative pathname As far as Unix is concerned it makes no difference whether you use and absolute or relative pathname Relative pathnames... oare more convenient, and as such... oare most often used

Relative Pathnames There are four types of relative pathnames 1. When the file is in your current directory 2. When the file is in a subdirectory of your current directory 3. When the file is in a directory that is an ancestor of your current directory 4. When the file is in a directory that is neither an ancestor or descendant of your current directory

Relative Pathnames in Your Current Directory Using a relative pathname with a file or directory inside your current directory is easy The relative pathname is simply the name of the file or directory The "path" part of the relative pathname is empty because the file or directory you want is already inside your current directory $ ls notes.txt it244 work work2 $ cat notes.txt foo foo foo to you

Relative Pathnames in Your Current Directory Notice that all I need to get the file is the file name It's the same for directories

Relative Pathnames in a Subdirectory Things get a little more complicated when you are dealing with a file in a subdirectory In this case you must list every directory between your current directory and the file you want $ ls work bletch.txt foo.txt notes.txt $ cat work/notes.txt foo foo foo to you You must use a slash / to separate the name of each directory from the name of the file or directory that comes after it

Relative Pathnames in a Subdirectory Notice that there is nothing no slash / or tilde ~ before the name of the first directory in the path

Relative Pathnames above the Current Directory When the file or directory is above the current directory you can't list the directory names Instead, you have to use the special.. entry in each directory Use one.. for each directory up the chain of directories in the path with a slash / between each.. $ pwd /home/it244gh/work $ ls../.. it244gh jharris mphamman

Relative Pathnames above the Current Directory

Relative Pathnames Neither above Nor below the Current Directory What if the file is neither above nor below? Here you have to... o go up to a common ancestor directory... o...and then go down to the directory that holds the file The path starts with one or more.. and keeps going up until you get to a directory that is an ancestor of... o both your current directory... o...and the file you are trying to reach

Relative Pathnames Neither above Nor below the Current Directory Once you get to the common ancestor you go down to the directory that holds the file $ ls../../../courses/it244/f16/ckelly/ alexgri fatalaty kiwan neko92 rangeley sfarah sukhi515 cdelaney GROUP MAIL neoalx rolon sindel wenwu10 cs110ck hsingh meteos nle sanf5456 skhalifa ychen123

Relative Pathnames Neither above Nor below the Current Directory

Standard Directories In the early days of Linux each distribution stored its important files in different directories o This made it hard to document programs o It also made things hard for developers working with different flavors of Linux Fortunately, reason has since prevailed We now have something called the FHS o It stands for Linux Filesystem Hierarchy Standard o It has been adopted by most major Linux distributions

Standard Directories This standard does not tell where to put different kinds of files Instead, for each directory name, it says what you can find in it You can see a listing for the FHS on page 96 of the current version of Sobell or page 91 of the previous edition Most Linux distributions do not use all these directories But when they do, they use them for the type of files specified by the standard

Your Home Directory versus /home Most Unix accounts have a home directory though not all One of the Ubuntu commands that creates an account has an option to not create a home directory for that account On most Unix and Linux systems all home directories are contained in the directory /home which is directly under the root directory written as / On the Mac, home directories are contained in /Users also directly under the root directory Do not confuse /home with your home directory

The Two Uses of / / is used in two different ways when writing pathnames When / appears at the beginning of a pathname it refers to the root directory -- the directory at the top of the filesystem The root directory is the only directory that is not contained in another directory Here is an example of this use of / /home This is the absolute address of home which holds the home directories of all users

The Two Uses of / When the / is not at the beginning of a pathname it is used a separator a character to mark the boundary between a directory and the name of a file or another directory Here is an example of this use of / it244/hw This is the relative pathname of the hw directory inside the it244 directory

The Two Uses of / A pathname can use the / in both ways /home/ckelly Here, the first / means the root while the second is used to separate the home directory from my home directory, ckelly

The Two Special Uses of. Another character that has more then one use when writing pathnames is the. character When. appears alone, it means the current directory So the following command... cp /home/ckelly/test.txt....copies a file to the current directory When. appears as the first character in a filename or directory name, the ls command will not list these directory entries unless you use the -a option

The Two Special Uses of. These "invisible" files are used to configure Linux and some programs Examples are.forward and.plan Unlike /,. can be used as an ordinary character in a file or directory name $ touch a.b.c.d... $ ls a.b.c.d...