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.

Slides:



Advertisements
Similar presentations
RH030 Linux Computing Essentials
Advertisements

NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
Lab6 CPCS361 I.Mona Alshehri. Working with Files and Directories Creating files Create a file with the cat command type the command cat > name_of_file.
5 Basic utilities When a user logs in to the Linux operating system the directory that they will start in is their home directory. Most users will have.
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 5 Accessing Files and Directories. How Directories Get Created OS installation: usr, dev, etc, export, kernel and others places to store installation.
Linux Linux File System.
Very Quick & Basic Unix Steven Newhouse Unix is user-friendly. It's just very selective about who its friends are.
Basic UNIX © McGraw Hill All rights reserved.
Using Linux Commands 2 Lab#5
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction What is Unix? An operation system (OS), similar to Windows, MacOS X Why learn Unix? Greatest Software.
7/17/2009 rwjBROOKDALE COMMUNITY COLLEGE1 Unix Comp-145 C HAPTER 2.
A Mini UNIX Tutorial. What’s UNIX?  An operating system run on many servers/workstations  Invented by AT&T Bell Labs in late 60’s  Currently there.
Linux Commands LINUX COMMANDS.
Using Linux Commands 2 Lab#5. Sort command Sort the lines of text files. $ sort fileName by default it will sort in normal order(alphabetical 0-9 A-Z.
CS 141 Labs are mandatory. Attendance will be taken in each lab. Make account on moodle. Projects will be submitted via moodle.
Using Macs and Unix Nancy Griffeth January 6, 2014 Funding for this workshop was provided by the program “Computational Modeling and Analysis of Complex.
COMP1070/2002/lec4/H.Melikian COMP1070 Lecture #5  Files and directories in UNIX  Various types of files  File attributes  Notion of pathname  Commands.
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”
Manage Directories and Files in Linux
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.
Unix Basics Chapter 4.
Linux+ Guide to Linux Certification, Second Edition
Linux+ Guide to Linux Certification, Third Edition
Chapter Two Exploring the UNIX File System and File Security.
INTRODUCTION TO LINUX Jacob Chan. GNU/Linux Consists of Linux kernel, GNU utilities, and open source and commercial applications Works like Unix –Multi-user.
Week 3 Exploring Linux Filesystems. Objectives  Understand and navigate the Linux directory structure using relative and absolute pathnames  Describe.
UNIX Commands. Why UNIX Commands Are Noninteractive Command may take input from the output of another command (filters). May be scheduled to run at specific.
Lesson 2-Touring Essential Programs. Overview Development of UNIX and Linux. Commands to execute utilities. Communicating instructions to the shell. Navigating.
Linux file system "On a UNIX system, everything is a file; if something is not a file, it is a process." Sorts of files (on a Linux system) Directories:
BIF713 Basic Unix/Linux Commands Getting Help with Commands.
Manage Directories and Files in Linux. 2 Objectives Understand the Filesystem Hierarchy Standard (FHS) Identify File Types in the Linux System Change.
Linux+ Guide to Linux Certification, Third Edition
Linux+ Guide to Linux Certification, Third Edition
Λειτουργικά Συστήματα - Lab1 Γιάννης Πετράκης. The Operating System  Unix is a layered operating system  The innermost layer is the hardware that provides.
1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem.
Introduction to Programming Using C An Introduction to Operating Systems.
Λειτουργικά Συστήματα – Lab2 Γιάννης Πετράκης. Directory Navigation and Control  The Unix file system is set up like a tree branching out from the root.
Linux Commands C151 Multi-User Operating Systems.
SUSE Linux Enterprise Desktop Administration Chapter 7 Manage Directories and Files.
Linux+ Guide to Linux Certification, Second Edition Chapter 4 Exploring Linux Filesystems.
Lecture 02 File and File system. Topics Describe the layout of a Linux file system Display and set paths Describe the most important files, including.
Linux Stuff Last Update Copyright 2014 Kenneth M. Chipps Ph.D. 1.
The Kernel At a high level, the kernel in an operating system serves as the bridge between applications and the actual data processing of the hardware.
CSCI 330 UNIX and Network Programming Unit II Basic UNIX Usage: File System.
Learning basic Unix command It 325 operating system.
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.
1 Linux Commands. 2 Path You specify a file or directory by its path name:  the full, or absolute, path name or the one relative to a location. The full.
BILKENT UNIVERSITY DEPARTMENT OF COMPUTER TECHNOLOGY AND INFORMATION SYSTEMS CTIS156 INFORMATION TECHNOLOGIES II FILES AND FILE SYSTEM STRUCTURE.
Linux Filesystem Management
Chapter 11 Command-Line Master Class
Linux Commands Help HANDS ON TRAINING Author: Muhammad Laique
Linux file system "On a UNIX system, everything is a file;
Some Linux Commands.
Exploring the UNIX File System and File Security
Module 6 Working with Files and Directories
Lab 2: Terminal Basics.
Linux Commands LINUX COMMANDS.
A shell is a user interface.
Presentation transcript:

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 are also familiar to other operating systems –Normal Files –Directories Additional types of files are UNIX-specific –Device Files –Links –Sockets –FIFOs

3 Normal Files Normal files: a set of contiguous data addressed with one name –This includes all the files normally expected under this term (such as ASCII texts, executable programs, or graphics files) You can use any names you want for these files— there is no division into filename and file type –A number of filenames still retain this structure, but these are requirements of the corresponding applications, such as a word processing program or a compiler

4 Directories Directories contain two entries with which the structure of the hierarchical file system is implemented –One of these entries (“.”) points to the directory itself –The other entry (“..”) points to the entry one level higher in the hierarchy

5 Device Files Each piece of hardware (with the exception of network cards) in a Linux system is represented by a device file –These files represent links between the hardware components or the device drivers in the kernel and the applications Every program that wants to access hardware must access it through the corresponding device file –The programs write to or read from a device file –The kernel then ensures that the data finds its way to the hardware or can be read from the file

6 Links Links are references to files located at other points in the file system Data maintenance is simplified through the use of such links –Changes only need to be made to the original file –The changes are then automatically valid for all links

7 Sockets A socket refers to a special file with which data exchange between two locally running processes can be implemented through the file system FIFOs FIFO (first in first out) or named pipe is a term used for files used to exchange data between processes The file can exchange data in one direction only

8 Change Directories and List Directory Contents The prompt of a shell terminal contains the current directory (such as The tilde (~) indicates that you are in the user’s home directory Commands: –ls –cd –pwd

9 ls

10 cd cd: change directory

11 pwd pwd: print working directory pwd -P prints the physical directory without any symbolic links

12 Create and View Files To create and view files, you need to know how to do the following: –Create a New File with touch –View a File with cat –View a File with less –View a File with head and tail

13 Create a New File with touch touch: changes the time stamp of a file or creates a new file with a size of 0 bytes

14 Create a New File with touch (continued)

15 View a File with cat You can use cat to view the contents of a file Comparable to the command “type” in DOS The command must include the filename of the file you want to see

16 View a File with less less displays the contents of a file page by page Even compressed files (such as.gz and.bz2) can be displayed

17 View a File with head and tail Used to view the first or last lines of a file By default, they show ten lines head -20 displays the first twenty lines tail -f displays a continuously updated view of the last lines of a file

18 Manage Files and Directories In this objective, you learn how to: –Copy and Move Files and Directories –Create Directories –Delete Files and Directories –Link Files

19 Copy and Move Files and Directories (continued) To copy the contents of proposals/ and all its files, including hidden files and subdirectories, to the existing directory proposals_old/: To avoid copying the hidden files, do the following:

20 Copy and Move Files and Directories (continued)

21 Create Directories You can use the command mkdir (make directory) to create new directories –mkdir proposal Use the option -p to create a complete path –mkdir -p proposal/january

22 Delete Files and Directories Use rmdir to delete empty directories –rmdir proposal Use rm to delete files and directories –rm part* –To delete directories (even if not empty) rm –r testdir –You can use the two options in Table 5-17 with rm User must have permission to delete file(s)

23 Link Files Each file is described by an inode –To see the inode number you can enter ls –I –Each inode has a size of 128 bytes –An inode contains all the information about the file besides the filename Link: a reference to a file –Create a hard link using ln, which points to the inode of an already existing file Hard links can only be used when both the file and the link are in the same file system –Create a symbolic link using ln –s; a symbolic link is assigned its own inode

24 Link Files (continued)

25 Link Files (continued) A symbolic link can point to a non-existing object if the object and its corresponding name no longer exist For example, if you erase the file old in the preceding example, in OpenSuse new will be shown in a different color in the output of ls, indicating that it points to a non-existent file An advantage of symbolic links is that you can create links to directories

26 Find Files In this objective you learn how to find files and programs using the following commands: –KFind –find –locate –whereis –which –type command

27 KFind

28 KFind (continued) Table 5-18 shows the results of three different search strings

29 KFind (continued) Use to narrow search

30 find Usage: find path criteria action

31 find (continued) Examples: find / -name game Looks for a file named "game" starting at the root directory (searching all directories including mounted filesystems). The `- name' option makes the search case sensitive. You can use the `- iname' option to find something regardless of case. find /home -user joe Find every file under the directory /home owned by the user joe. find /usr -name *stat Find every file under the directory /usr ending in "stat". find /var/spool -mtime +60 Find every file under the directory /var/spool that was modified more than 60 days ago.

32 locate locate is an alternative to find –name –The package findutils-locate must be installed –find can be quite slow –locate searches through a database previously created (/var/lib/locatedb), making it much faster The database is automatically created and updated daily by OpenSuse Use updatedb to update it manually Examples: –locate letter_Miller –locate umount

33 locate

34 whereis whereis returns the binaries (option -b), manual pages (option -m), and the source code (option -s) of the specified command –If no option is used, all this information is returned, if the information is available whereis is faster than find, but it is less thorough Example:

35 which which searches all paths listed in the variable PATH for the specified command and returns the full path of the command –It is especially useful if several versions of a command exist in different directories and you want to know which version is executed when entered without specifying a path

36 type command type command can be used to find out what kind of command is executed when command is entered—a shell built-in command or an external command The option -a delivers all instances of a command bearing this name in the file system