RH030 Linux Computing Essentials

Slides:



Advertisements
Similar presentations
RH030 Linux Computing Essentials
Advertisements

Linux commands exercise 1. What do you need, if you try to these at home? You need to download and install Ubuntu Linux from the Internet – DVD is need.
By: Tony Andrews.  Linux directory ordering system  Navigating and creating directories ◦ Listing directories and files ◦ Creating directories ◦ Changing.
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
Exploring the UNIX File System and File Security
Introducing the Command Line CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.
Lesson 22 – Introduction to Linux Systems Administration.
Linux+ Guide to Linux Certification, Second Edition
Linux+ Guide to Linux Certification, Second Edition
Chapter 7 Advanced Directory and File Management.
Chapter 5 Accessing Files and Directories. How Directories Get Created OS installation: usr, dev, etc, export, kernel and others places to store installation.
The UNIX File System.
Guide To UNIX Using Linux Third Edition
Guide To UNIX Using Linux Third Edition
Linux Commands LINUX COMMANDS.
CS 141 Labs are mandatory. Attendance will be taken in each lab. Make account on moodle. Projects will be submitted via moodle.
Guide To UNIX Using Linux Fourth Edition
1 THE UNIX FILE SYSTEM By Chokechai Chuensukanant ID COSC 513 Operating System.
The file structure and related utilities CS240 Computer Science II.
Unix Primer. Unix Shell The shell is a command programming language that provides an interface to the UNIX operating system. The shell is a “regular”
Lesson 7-Creating and Changing Directories. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files.
Chapter 9 Part II Linux Command Line Access to Linux Authenticated login using a Linux account is required to access a Linux system. The Linux prompt will.
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
1 Lecture 2 Working with Files and Directories COP 3344 Introduction to UNIX.
Introduction to Shell Script Programming
Week 7 Working with the BASH Shell. Objectives  Redirect the input and output of a command  Identify and manipulate common shell environment variables.
Unix Basics Chapter 4.
Linux+ Guide to Linux Certification, Second Edition
Linux+ Guide to Linux Certification Chapter Four Exploring Linux Filesystems.
Linux+ Guide to Linux Certification, Third Edition
Chapter Two Exploring the UNIX File System and File Security.
Week 3 Exploring Linux Filesystems. Objectives  Understand and navigate the Linux directory structure using relative and absolute pathnames  Describe.
Linux+ Guide to Linux Certification, Third Edition
Unix/Linux cs3353. The Shell The shell is a program that acts as the interface between the user and the kernel. –The shell is fully programmable and will.
BIF713 Basic Unix/Linux Commands Getting Help with Commands.
Chapter Two Exploring the UNIX File System and File Security.
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands: whereis, which, whoami, finger, passwd, cal, date Working with Files: cat, more, less.
1May 16, 2005 Week 2 Lab Agenda Command Line FTP Commands Review More UNIX commands to learn File name expansion - * Introduction of vi.
Linux+ Guide to Linux Certification, Third Edition
Linux+ Guide to Linux Certification, Third Edition
Manage Directories and Files in Linux Part 2. 2 Identify File Types in the Linux System The file types in Linux referred to as normal files and directories.
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands: which, passwd, date, ps / kill Working with Files: file, touch, cat, more, less, grep,
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
Linux Commands C151 Multi-User Operating Systems.
1 Lecture 2 Working with Files and Directories COP 3353 Introduction to UNIX.
Agenda The Linux File System (chapter 4 in text)
SUSE Linux Enterprise Desktop Administration Chapter 7 Manage Directories and Files.
UNIX filesystem CS 2204 Class meeting 2 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
Linux+ Guide to Linux Certification, Second Edition Chapter 4 Exploring Linux Filesystems.
1 CS3695 – Network Vulnerability Assessment & Risk Mitigation – Introduction to Unix & Linux.
File Management commands cat Cat command cat cal.txt cat command displays the contents of a file here cal.txt on screen (or standard out).
Linux Tutorial Lesson Two *Getting Help in Linux *Data movement and manipulation *Relative and Absolute path *Processes Note: see chapter 1,2,3 from Linux.
Learning Unix/Linux Based on slides from: Eric Bishop.
Agenda The Linux File System (chapter 4 in text) Directory Structures / Navigation Terminology File Naming Rules Relative vs Absolute pathnames Unix Commands:
Commands Basic syntax of shell commands UNIX or shell commands have a basic structure command -options target command comes first (such as cd or ls) any.
Linux Commands Workout 1
Linux Commands Help HANDS ON TRAINING Author: Muhammad Laique
Lecture 2 Working with Files and Directories
Some Linux Commands.
C151 Multi-User Operating Systems
The Command Prompt Commands are the way to “do things” in Unix
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands:
Exploring the UNIX File System and File Security
Web Programming Essentials:
CSE 303 Concepts and Tools for Software Development
Module 6 Working with Files and Directories
Lab 2: Terminal Basics.
A shell is a user interface.
January 26th, 2004 Class Meeting 2
Presentation transcript:

RH030 Linux Computing Essentials Workbook 2 Part 1 - Filesystem Basic’s RH030 Linux Computing Essentials

Linux+ Guide to Linux Certification, 2e Workbook 2 covers: Basic Understanding of the FSH The Linux Directory Structure Filesystem Navigation Commands Understanding the System Directories Managing Files & Directories Displaying the contents of files & directories Understanding the types of items in directories Understanding the different types of files Using Globbing, wildcards, metacharacters Editing Files will be covered next week. Linux+ Guide to Linux Certification, 2e

Linux+ Guide to Linux Certification, 2e Recall these terms: FSH or Filesystem: Manages the storage and permissions of items in a hierarchical structure called the directory tree structure and allows the user access to items within this structure by using pathnames as their addresses. Root Directory/Sub-directories: 1st directory at the top level of the hierarchical filesystem structure always referred to using the / character. Pathname: The address which is used to identify where an item is logically located within the hierarchal filesystem structure. Absolute pathname: This type of pathname is determined from the root directory at the top of the hierarchal filesystem structure to a certain file or directory. Relative pathname: This type of pathname is determined from your current location in the hierarchical filesystem structure to a specific file or directory. Linux+ Guide to Linux Certification, 2e

Linux+ Guide to Linux Certification, 2e System Directories Table 5-1: Linux directories defined by FHS Linux+ Guide to Linux Certification, 2e

/etc holds the system configuration files There are many many configuration files. Such as the file to list what shells are available. This file is used to list the available shells in the system Absolute pathname is /etc/shells Which lists the absolute pathname to the available executable files which are used to run each shell . These are all stored in /bin It is common for the name of a shell to end in *sh. So their absolute pathname’s would be: /bin/*sh Bash = /bin/bash Bourne = /bin/sh Cshell = /bin/csh Pathnames To describe a specific file or directory in the filesystem hierarchy, you must specify a "path." The path to a location can be defined as an absolute path or relative path: An absolute path of a file or directory is the complete path to it, starting at the root, which means you must include directory names. For example, the path name for the file "ch1.tex" in the directory "thesis" that is within the home directory of user zoman "/home/zoman" would be: /home/zoman/thesis/ch1.tex, (remember, the first "/" is the directory root). A relative path of a file or directory is the path to it starting from the current location. For example, if the current working directory is /home/zoman, the relative path to the file “ch1.tex” in the directory “thesis” would be thesis/ch1.tex When specifying a path, you simply trace a route through the filesystem tree, listing the sequence of directories you pass through as you go from one point to another. Each directory listed in the sequence is separated by a slash “/”. UNIX provides the shorthand notation of "." to refer to the current location, and ".." to refer to the parent directory. Because UNIX filesystem trees have no loops, the ".." notation refers unambiguously to the directory's parent.

Some really fundamental system configuration files – you should know. /etc/passwd This file is used to list the attributes of the accounts in the system /etc/group This file is used to list created groups within the system /etc/shadow This file is used to store the encrypted passwords within the system /etc/shells This file is used to tell the system what shells are available to it. Pathnames To describe a specific file or directory in the filesystem hierarchy, you must specify a "path." The path to a location can be defined as an absolute path or relative path: An absolute path of a file or directory is the complete path to it, starting at the root, which means you must include directory names. For example, the path name for the file "ch1.tex" in the directory "thesis" that is within the home directory of user zoman "/home/zoman" would be: /home/zoman/thesis/ch1.tex, (remember, the first "/" is the directory root). A relative path of a file or directory is the path to it starting from the current location. For example, if the current working directory is /home/zoman, the relative path to the file “ch1.tex” in the directory “thesis” would be thesis/ch1.tex When specifying a path, you simply trace a route through the filesystem tree, listing the sequence of directories you pass through as you go from one point to another. Each directory listed in the sequence is separated by a slash “/”. UNIX provides the shorthand notation of "." to refer to the current location, and ".." to refer to the parent directory. Because UNIX filesystem trees have no loops, the ".." notation refers unambiguously to the directory's parent.

Sometimes System Files are hidden. Configuration files are often hidden. Filenames that start with a . are hidden files. You can hide any file by renaming it with a . at the start. Or unhide it by removing the . Such as your local user bash startup initialization files …. ~/.bash_profile, ~/.bashrc Linux+ Guide to Linux Certification, 2e

Linux+ Guide to Linux Certification, 2e Filename Extensions Files on Linux do not have to use an extension But they are often used to denote their file type When used they are similar to windows & are used as identifiers. The extension is placed after the filename following a dot (.) Text configuration files often end in .conf Such as httpd.conf Data files commonly use extensions to identify their application. Executables do not commonly use an extension. But sometimes a command can put an extension onto their output. Such as winzip does with compression. Or they are sometimes used to identify how the system uses it. Linux+ Guide to Linux Certification, 2e

Linux+ Guide to Linux Certification, 2e Common Extensions Table 4-1: Common filename extensions Linux+ Guide to Linux Certification, 2e

In a Linux system there are many different types of files Text files: Stores information in a readable ASCII text format Data files: Associated with a specific application program it’s specific format. Executable files: These are the Binary files which are used to run the commands and programs. Linked files: Like shortcuts a link just associates an item with another item. Well discuss these more later. Special device files: These represent the system devices within the /dev directory. Such as …. hd=ide hardrive tty=terminal Linux+ Guide to Linux Certification, 2e

Linux+ Guide to Linux Certification, 2e File Command Sometimes you need to discover the origins of a file. Because Linux does not follow the same pattern as Windows with the use a extensions you sometimes have to be able to identify for yourself what type of file you are working with. This is done with the file command. file /etc/passwd file /etc/passwd /bin/ls ~/dir1/coffees/beans file ~/class-files/* file ./* Linux+ Guide to Linux Certification, 2e

Linux+ Guide to Linux Certification, 2e Locating Commands whatis command: used to display what this command does display 1st line from the man pages. whereis command: Used to locate the binary, source and man pages for a command. which command: Used only for executable files Searches through the System Variable $PATH Lists directories on system where executable files are located Allows executable files to be run without specifying absolute or relative path Linux+ Guide to Linux Certification, 2e

Linux+ Guide to Linux Certification, 2e Viewing Directories ls command: Most commonly used options: ls – l : detailed display or long listing of items. ll command: Is the default Alias for ls -l ls – a : displays hidden files ls – F : used to identify types of items in the directory. ls – r : list in reverse ls – R : list contents of everything – even irectories ls – ld : detailed display of actual cwd not it’s contents. Linux+ Guide to Linux Certification, 2e

ls –F = Display types items in a directory Modifies the displayed listing so each item is displayed with a symbol to tell what the type of item it is: / = directory – A forward slash (/) after the name = ASCII Text File – no symbol * = Executable – asterisk (*) after the name @ = Symbolic Link – An at sign (@) (similar to a shortcut in Windows) Linux+ Guide to Linux Certification, 2e

ls –l = Long Detailed Listing Linux+ Guide to Linux Certification, 2e

ls –R = Recursive Listing ls -R (recursive) command - displays the contents of all directories, subdirectories and their contents for a particular part of the directory tree If done at a high level in the directory structure, the output can be substantial! Linux+ Guide to Linux Certification, 2e

Globbing Wildcard Metacharacters A metacharacter is any keyboard character that has a “special” meaning to a shell when used in a command-line. Used to simplify commands specifying multiple filenames Can be used with most Linux filesystem commands Linux+ Guide to Linux Certification, 2e

Linux+ Guide to Linux Certification, 2e Using Metacharacters Asterik ‘*’ ‘*’ matches zero or more characters. Except the leading dot ‘.’ on a hidden file. Commonly referred to as a wildcard character. Using with the ls command will list all the files that match the pattern made by using ‘*’, as well as the directories and their contents that match. Question Mark ‘?’ Matches a single character. Linux+ Guide to Linux Certification, 2e

Linux+ Guide to Linux Certification, 2e Using Metacharacters Square Brackets ‘[ ]’ These are called ranges If looking for a range, then the characters must be in order. [az] looks for the 2 lower case characters ‘a’ or ‘z’ inclusive [a-z] looks for any lower case character between ‘a’ and ‘z’ Case sensitive. [a-z] and [A-Z] are not the same Semicolon ‘;’ Enables typing in multiple commands on the command line without having to press “enter” in between them. Put the ‘;’ in between each command. Called the “command separator.” Linux+ Guide to Linux Certification, 2e

Linux+ Guide to Linux Certification, 2e Example of use. Linux+ Guide to Linux Certification, 2e

Metacharacters Exercise What does this command do? $ ls *[1-5]*p Linux+ Guide to Linux Certification, 2e

Displaying the contents of Text Files There are many commands commonly used: cat head tail more less Linux+ Guide to Linux Certification, 2e

Linux+ Guide to Linux Certification, 2e Cat command Really there are multiple uses for this command. Mainly used to display contents of a text file on the screen -n switch: Displays line number and contents cat /etc/passwd Concatenation: Joining text files together cat file1 file2 file3 > new-big-file Create new quick files – similar to ‘DOS copy con’ cat > new-file tac command: Displays content of files in reverse order Linux+ Guide to Linux Certification, 2e

Displaying the Contents of Text Files head command: Views first 10 lines of a file by default You can also specify how many lines to show head - 6 <filename> tail command: Views last 10 lines of a file by default tail - 15 <filename> You can also specify what line number to start the display from. tail + 50 <filename> more command: Displays output page-by-page Use the Space key to go to the next page Use the Enter key to go to the next line less command: Same as more command. But can also use cursor to scroll backwards. Linux+ Guide to Linux Certification, 2e

Using more/less with a pipe more and less is often used with the output from other commands If output is too large to fit on terminal screen, you would use the “|” pipe metacharacter with the more or less command. ls -l | more cat dante | more more dante Linux+ Guide to Linux Certification, 2e

What does this command do? $ ls -al | head > myfiles Linux+ Guide to Linux Certification, 2e

Piping & Redirection Solution $ ls -al | head > myfiles take the top ten files listed and put this part of the listing in a file called myfiles Linux+ Guide to Linux Certification, 2e

Working with Directories There are many commands commonly used: mkdir rmdir rm cp mv Linux+ Guide to Linux Certification, 2e

Managing Files and Directories mkdir command: Creates new directories mkdir Will make a new directory mkdir –p Will make a hierarchical pathname structure using a only a single command. mkdir –p ~/newdir1/newdir2/newdir3 rm command: Removes files only rm -r command: Removes directories +files + sub-directories etc -r recursive copy entire contents of a directory -i interactive prompts user before overwriting files -f force action overrides interactive mode rmdir command: Removes directories only if they are empty Linux+ Guide to Linux Certification, 2e

Managing Files and Directories cp command: Copies files 2 arguments minimum: Source file/directory (may specify multiple sources) Target file/directory - mandatory . = cwd -r recursive copy entire contents of a directory -i interactive prompts user before overwriting files -f force action overrides interactive mode mv command: Move/Rename files or directories Used to move items Also used to rename items Same use of arguments as the cp command Linux+ Guide to Linux Certification, 2e

What does this command do? $ mv ??[abc] ../.. Linux+ Guide to Linux Certification, 2e

Linux+ Guide to Linux Certification, 2e solution $ mv ??[abc] ../.. move any file(s) with only three characters in the name, anything in the first two character positions, a or b or c in the third position, up two directory levels Linux+ Guide to Linux Certification, 2e

Workbook 2 - Command Summary /etc /home /root /boot /var /usr /bin /sbin ls cd pwd / . .. ~ touch whoami which exit > >> cp mv rm echo mkdir rmdir rm - r cp -r ls – F r a l s R *, ?, [a-z], [az] ranges file cat less head more Directory Navigation To gain access to particular files, you have to be able to move through directories to find them. Here are a few useful commands which will allow you to do this :- cd path Changes working directory to path. Allows you to change directory but only if you can see it in your directory listing. Example : current directory is : /home/zoman ; type $ cd thesis new location is : /home/zoman/thesis cd /path Changes working directory to /path. Allows you to change directory based on the given absolute path. Example : $ cd /etc new location is : /etc cd / This will put you into the UNIX root directory. Example: $ cd / new location is : / cd .. This will put you into the previous (parent) directory in the hierarchy. Example : current directory is : /home/zoman/thesis ; type $ cd .. new location is : /home/zoman cd This will put you into your personal home directory. Example: current directory is : / ; type $ cd