Perl Scripting and The File system

Slides:



Advertisements
Similar presentations
Basic Unix system administration
Advertisements

Linux can be generally divided into four major components: 1. KERNEL – OS, ultimate boss The kernel is the core program that runs programs and manages.
A Guide to Unix Using Linux Fourth Edition
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.
1 Unix Systems Administration Y. K. Chang Generic Unix Directory Structure /bin /dev /etc /sbin /home /lost+found / Root Dir /dsk /rdsk /term /pts /rmt.
Introduction to Unix (CA263) File System
Exploring the UNIX File System and File Security
GNU/Linux Filesystem 1 st AUT GNU/Linux Festival Computer Engineering & IT Department Bahador Bakhshi.
Linux+ Guide to Linux Certification, Second Edition
Linux Linux File System.
Guide To UNIX Using Linux Third Edition
File System and Directory Structure in Linux. What is File System In a computer, a file system is the way in which files are named and where they are.
COMP1070/2002/lec4/H.Melikian COMP1070 Lecture #5  Files and directories in UNIX  Various types of files  File attributes  Notion of pathname  Commands.
Guide To UNIX Using Linux Fourth Edition
Filesystem Hierarchy Standard (FHS) –Standard of outlining the location of set files and directories on a Linux system –Gives Linux software developers.
The file structure and related utilities CS240 Computer Science II.
Manage Directories and Files in Linux
Linux Filesystem Last Update Copyright Kenneth M. Chipps Ph.D. 1.
Unix Basics Chapter 4.
– Introduction to the Shell 10/1/2015 Introduction to the Shell – Session Introduction to the Shell – Session 2 · Permissions · Users.
Linux+ Guide to Linux Certification, Second Edition
Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2011 by the Trustees of Indiana University except as noted.
The UNIX File System. The UNIX File A file is a container for storing information and data. Filename limited to 255 characters. Can’t contain / or NULL.
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.
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:
Manage Directories and Files in Linux. 2 Objectives Understand the Filesystem Hierarchy Standard (FHS) Identify File Types in the Linux System Change.
Chapter Two Exploring the UNIX File System and File Security.
Chapter 4 The File Structure. Contents u The Hierarchical File Structure u Directory and Ordinary Files u Directories u Access Permissions u Links.
E X C E E D I N G E X P E C T A T I O N S Basic LINUX Linux System Administration Dr. Hoganson Kennesaw State University Operating Systems Directory structure:
Linux+ Guide to Linux Certification, Third Edition
Linux+ Guide to Linux Certification, Third Edition
1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem.
Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2007 by the Trustees of Indiana University except as noted.
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.
Linux Commands C151 Multi-User Operating Systems.
Linux Filesystem WeeSan Lee. Roadmap Disk Partitions The Filesystem Filesystem Mouting & Umounting File Tree File Type File Permission.
Chapter 10: File-System Interface Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Jan 1, 2005 File-System Interface.
The Unix File system (UFS) Presented by: Gurpreet Singh Assistant Professor Department of School of Computing and Engineering Galgotias University.
CS 245 – Part 1 Using Operating Systems and Networks for Programmers Jiang Guo Dept. of Computer Science California State University Los Angeles.
UNIX File System By Vishal Desai. Introduction Basic purpose of file system: Represent and organize the system resources. But UNIX File System also maps.
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
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.
Operating System & Administration UNIT-III Introduction to File System.
A Brief Overview of Unix Brandon Bohrer. Topics What is Unix? – Quick introduction Documentation – Where to get it, how to use it Text Editors – Know.
The Unix File System R Bigelow. The UNIX File System The file system refers to the way in which UNIX implements files and directories. The UNIX file system.
LINUX Zhengli Zhu, School of Life Sciences. Outline 1. ABC of Linux 2. Basic orers of Linux 3. Bash Programming.
ORAFACT The Linux File System. ORAFACT Filesystem Support Support for dozens of filesystem types including: Minix, ext2, MS-DOS, UMSDOS, VFAT, NTFS, NFS,
Linux Administration – Finding You Way on the Command Line The Linux File Directory or Tree.
BILKENT UNIVERSITY DEPARTMENT OF COMPUTER TECHNOLOGY AND INFORMATION SYSTEMS CTIS156 INFORMATION TECHNOLOGIES II FILES AND FILE SYSTEM STRUCTURE.
Linux Filesystem Management
Getting Started with Linux
Perl Scripting and The File system
Linux 101 Training Module Linux Basics.
UBUNTU INSTALLATION
Linux file system "On a UNIX system, everything is a file;
Chapter 6 File Systems CSNB113 SYSTEM ADMINISTRATION
C151 Multi-User Operating Systems
The Linux Operating System
BIF703 File Permissions.
Exploring the UNIX File System and File Security
Chapter 7 File and file System structure
Lecture 43 Syed Mansoor Sarwar
The Filesystem Chapter 5.
CSE 303 Concepts and Tools for Software Development
Software I: Utilities and Internals
Chapter 5 The Filesystem
Chapter 4: The Linux Filesystem
January 26th, 2004 Class Meeting 2
Presentation transcript:

Perl Scripting and The File system Perl & Chapter 5 Perl Scripting and The File system grep –color=auto option

Hey real quick aliases Aliases Aliases can be defined on the command line, in .bash_profile, or in .bashrc, using this form : alias name=‘command’ unalias will remove alias ll='ls -lh' alias ls='ls --color=auto' alias vi='vim ' alias c='clear’ $ unalias -a

Sessions A session started as a login session will read configuration details from the /etc/profile file first. It will then look for the first login shell configuration file in the user's home directory to get user-specific configuration details. It reads the first file that it can find out of ~/.bash_profile, ~/.bash_login, and ~/.profile and does not read any further files. In contrast, a session defined as a non-login shell will read /etc/bash.bashrc and then the user-specific ~/.bashrc file to build its environment. Non-interactive shells read the environmental variable called BASH_ENV and read the file specified to define the new environment.

Brief Perl Scripting Used for quick and dirty programs you can code in 3-5 minutes. (Using your favorite text editor) Perl comments are preceded with (#) A single line can be split into multiple lines with (\) and multiple lines can be put on a single line separated by (;)

Perl Scripting cont’ All perl scripts should start with: print "Hello, world!\n” (example in text editor) Tells the kernel to interpret this file as perl script for execution To run do the following $ chmod +x hello.pl $ ./hello (lets open CentOS and see what happens) #!/usr/bin/perl print "Hello, World!\n";

More Perl In Windows the .exe extension designates an executable file In Linux (and Unix) the execute bit is the designation. (we will learn more about the execute bit later in this chapter) Alternatively you can execute a bash script with perl filename OR ./filename (if its executable)

Output and Input The print command is for quick and dirty output. <STDIN> reads input from stdin (lets open CentOS and see results) #!/usr/bin/perl print "Whatever you type I will randomly echo\n"; print "command>"; #$a=<STDIN>; $a=<>; while() { sleep rand(5)+1; print "Hi there!!! $a \n"; }

The File system How your Linux systems represents system objects and resources. The file system contains: Some naming convention and organization Methods to navigate and manipulate the file system Security / access methods Code (software) that ties it all together

File system Types There are many different types of file systems used on different kernels FAT32 (Windows) NTFS (Windows) HFS+ (Mac OS X) Ext3 (Linux) Ext4 (Linux) XFS (Linux)

XFS – File System XFS is a highly scalable, high-performance file system which was originally designed at Silicon Graphics, Inc. XFS is the default file system for Red Hat Enterprise Linux 7 and CentOS 7. Main FeaturesXFS supports metadata journaling, which facilitates quicker crash recovery. The XFS file system can also be defragmented and enlarged while mounted and active. In addition, Red Hat Enterprise Linux 7 supports backup and restore utilities specific to XFS.

Pathnames The File system stores everything as a hierarchy starting with “/” This is known as the root directory Contains any number of subdirectories Traverse the file system using the “cd” command

Mounting A file tree is a collection of file systems A file system is collection of pathnames and files You add file systems to the file tree with the “mount” command Usage: mount location mount-point mount /dev/hda4 /users After mounting you could do ls –al and see all of the contents of the directory /etc/fstab

Unmounting “unmount” is used to detach a mounted file system (note**** nothing in the mounted file system can be use in order to unmount Usage: unmount mount-point The fuser command will tell you whats running in your mount-point Usage: fuser –mv mount-point

File tree Pathname Contents /bin Commands needed for minimal system operability /boot Kernel and files needed to load the kernel /dev Device entries for disks, printers, pseudo-terminals, etc. /etc Critical startup and configuration files /home Home directories for users /lib Libraries and parts of the C compiler /media Mount points for filesystems on removable media /opt Optional application software packages (not yet widely used) /proc Information about all running processes /root Home directory of the superuser (often just /) /sbin Commands for booting, repairing, and recovering the system /tmp Temporary files that may disappear between reboots /usr Hierarchy of secondary files and commands /usr/bin Most commands and executable files /usr/include Header files for compiling C programs /usr/lib Libraries; also, support files for standard programs /usr/local Local software (software you write or install) /usr/local/bin Local executables /usr/local/etc Local system configuration files and commands /usr/local/lib Local support files /usr/local/sbin Statically linked local system maintenance commands /usr/local/src Source code for /usr/local/* /usr/man On-line manual pages /usr/sbin Less essential commands for system administration and repair /usr/share Items that might be common to multiple systems (read-only) /usr/share/man On-line manual pages /usr/src Source code for nonlocal software packages (not widely used) /var System-specific data and configuration files /var/adm Varies: logs, system setup records, strange administrative bits /var/log Various system log files /var/spool Spooling directories for printers, mail, etc. /var/tmp More temporary space (preserved between reboots)

File Types Regular files Directories Character device files (rw char by char) Block device files (rw block chunks) Local domain sockets Named pipes (FIFOs) Symbolic Links ls –al tells all rm (delete) removes all [root@yumserver dev]# ls -l tty0 crw–w—- 1 root root 4, 0 Dec 31 11:45 tty0 [root@yumserver dev]# [root@yumserver dev]# ls -l sda1 brw-rw—- 1 root disk 8, 1 Dec 31 11:45 sda1 [root@yumserver dev]# Named pipes are created via mkfifo or mknod: $ mkfifo /tmp/testpipe

Regular Files Collection of bytes Data or text files, executable program, etc Nothing to see here move on……..

Directories You may have noticed “.” and “..” the are the directory itself and its parent directory representation mkdir creates a new directory rm –r deletes a directory and its subdirectories cp and ln (hardlink) (oldfile newfile) In-class examples

File Attributes $ ls -l /bin/gzip -rwxr-xr-x 3 root root 57136 Jun 15 2004 /bin/gzip The first field specifies the file’s type and mode. The first character is a dash, so the file is a regular file. The next nine characters in this field are the three sets of permission bits. The next field in the listing is the link count for the file. Every time a hard link is made to a file, the count is incremented by 1. The next two fields in the ls output are the owner and group owner of the file. The next field is the size of the file in bytes. Next comes the date of last modification: June 15, 2004. The last field in the listing is the name of the file, /bin/gzip.

More Types Device and block files Local Domain Sockets Named Pipes Device driver files that talk to system hardware Local Domain Sockets Connections between processes (not to be confused with network sockets but act in much the same way Aka UNIX domain sockets Named Pipes Like local domain sockets piping data from one process to another Symbolic Links ln –s command From the internet Removing the original file does not remove the attached symbolic link or symlink, but without the original file, the symlink is useless (the same concept like Windows shortcut).

More with Files $touch a $ ln a a1 $ ls –al then view results See that the Inode number for ‘a’ and ‘a1′ are same as we created ‘a1’ as hard link. But they are different for symbolic link Stat command

File Permissions Each file has set of 12 mode attributes called bits. Read, write, execute, and file type information Nine (9) bits define permissions for file owner, group, and world (or everyone else) -r,w,x octal chmod command is extremely useful In class examples

File Permissions Cont’ Each file has set of 12 mode attributes called bits. Read, write, execute, and file type information Nine (9) bits define permissions for file owner, group, and world (or everyone else) -r,w,x octal chmod command is extremely useful In class examples

chmod Changes the file permissions In class examples Only file owner or root can run chmod In class examples chown and chgrp(UNIX) commands allow you to change the ownership and group permission of a file umask command allows you to set a default list of permissions given to files you create