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.

Slides:



Advertisements
Similar presentations
A Guide to Unix Using Linux Fourth Edition
Advertisements

Pre-Assessment Questions
Introduction to Unix (CA263) File System
Exploring the UNIX File System and File Security
Linux+ Guide to Linux Certification, Second Edition
Linux Linux File System.
Linux Files. Files and directories As in Windows directories are structures which contain –Other directories –Files.
The UNIX File System.
Guide To UNIX Using Linux Third Edition
UNIX Files and Security Software Tools. Slide 2 File Systems l What is a file system? A means of organizing information on the computer. A file system.
Linux Commands LINUX COMMANDS.
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.
1 THE UNIX FILE SYSTEM By Chokechai Chuensukanant ID COSC 513 Operating System.
The file structure and related utilities CS240 Computer Science II.
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.
1 Lecture 2 Working with Files and Directories COP 3344 Introduction to UNIX.
Linux Filesystem Last Update Copyright Kenneth M. Chipps Ph.D. 1.
Unix Basics Chapter 4.
Linux+ Guide to Linux Certification, Second Edition
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.
Filesystem Hierarchy Dr. Michael L. Collard 1.
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.
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.
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.
The Unix File system (UFS) Presented by: Gurpreet Singh Assistant Professor Department of School of Computing and Engineering Galgotias University.
2 Manual & Filestore Mauro Jaskelioff. Introduction Using the manual The UNIX filestore File permissions.
CS 245 – Part 1 Using Operating Systems and Networks for Programmers Jiang Guo Dept. of Computer Science California State University Los Angeles.
1 Lecture 2 Working with Files and Directories COP 3353 Introduction to UNIX.
BIF713 File and Directory Management. File System A File System is a structure used to organize programs and data on a computer ’ s storage device Files.
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.
1 Introduction to Unix. 2 What is UNIX?  UNIX is an Operating System (OS).  An operating system is a control program that helps the user communicate.
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.
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.
Date: 14-Oct-2014 LINUX and Vi Editor Vinit S Bhosle
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
Agenda The Linux File System (chapter 4 in text)
Linux 101 Training Module Linux Basics.
Linux file system "On a UNIX system, everything is a file;
Lecture 2 Working with Files and Directories
C151 Multi-User Operating Systems
9 Linux on the Desktop.
Exploring the UNIX File System and File Security
Chapter 7 File and file System structure
Perl Scripting and The File system
Software I: Utilities and Internals
Linux Commands LINUX COMMANDS.
Chapter 4: The Linux Filesystem
January 26th, 2004 Class Meeting 2
Presentation transcript:

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 /home/userid as their home directory. The root user has /root as it’s home directory.

ls Lists the names of files ls –l ls –la To view the contents of the current directory you can type: ls –l The –l option says to give a long list which includes file permissions, owner, group, size (in bytes), date created, and filename. ls –la You can view the hidden system files by including the –a option:

To view the contents of the /var/log directory type: ls /var/log You can include a path instead of just a filename to list. For example to view the contents of the / directory you can type: ls / Notice the –l option was not used so the directory will display only the file and directory names, not the properties. To view the contents of the /var/log directory type: ls /var/log

cat Displays a Text File

rm Deletes a file rm filename Rm –i filename have to hit y to remove To remove a directory use the rmdir command. rmdir scripts You must have write permission to remove a directory.

To remove a directory that has other files within it use the rm command with the –r option (recursive). To remove the /etc/skel/cron directory and any files and directories that may be within it type: rm –r /etc/skel/cron To remove one or more files use the rm command. To remove the file Welcome from the /etc/skel directory type: rm /etc/skel/Welcome

less Display a text file one screen at a time

hostname Displays the system name

Copying a file from the CLI Copy files with the cp command. When you copy a file you duplicate the file and it’s contents to another file. Filenames must be unique so if you copy the file to the same directory it must have a different name. To copy /root/myFile to the / directory type: cp /root/myFile /myFile

Copying a file from the CLI Copy files with the cp command. To copy /root/myFile to the / directory with the name myFile2 type: cp /root/myFile /myFile2 You can use wildcards with filenames as you did with the ls command. To copy /myFile and /myFile2 to the /root directory type: cp /myfile* /root If you are replacing an existing file you will be prompted if it can be overwritten.

Moving a File from the CLI To move a file use the mv command. When you move a file to another file in the same directory you are essentially renaming the file. To move /root/myFile to /root/myFile2 type: mv /root/myFile /root/myFile2 To move /root/myFile2 to /myFile type: mv /root/myFile2 /myFile To move /myFile to /root/myFile type: mv /myFile /root/myFile You must have read and write permissions to move a file.

lpr Prints a file

grep allows user to search for occurrence of a string of characters in a file

Head and Tail head Display the beginning of a file (the first 10 lines) Tail Display the end of a file (the last ten lines)

sort displays the lines of a file in order

uniq removes duplicate lines

echo copies the command line (but not the word echo) to the screen

Compressing and Archiving bzip2 bunzip2 gzip tar

who lists who is logged in

finger: lists who is logged in

Figure 5-19 Entering text with vim

Figure 5-20 The main vim Help screen

Figure 5-21 Help with insert commands

File system 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 /home/userid as their home directory. The root user has /root as it’s home directory. Type pwd to display the path

Linux File System Structure The file system structure used by Linux is a hierarchal list of directories called a directory tree. The top of the tree is the root directory indicated by a /. The upper directories are called parent directories and the directories beneath them are called child directories.

Figure 6-5 Absolute pathnames

Figure 6-6 Relative pathnames

Changing and Viewing Directories from the CLI Although you can view the contents of any directory from anywhere in the file system hierarchy you can also change to the individual directories. To change the current directory to the / directory type: cd / To change to jsmith’s Documents directory within his home directory type: cd /home/jsmith/Documents There are shortcut commands you can also use. For example, you can use the shortcut .. change to the parent directory of the current directory by typing: cd ..

Changing and Viewing Directories from the CLI You can change to your home directory with the shortcut ~ by typing: cd ~ (or just cd without any options) The root user goes back to /root with this command. You can display the current directory by typing the pwd command.

Linux File System Structure In order to find files within the file system, a standard exists that identifies where certain types of files go. This standard is the file system Hierarchy Standard (FHS) maintained by the file system Hierarchy Standard Group. The standard contains a set of requirements and guidelines for file and directory placement under UNIX-like operating systems. Use of the FHS provides interoperability of applications, system administration tools, development tools, and scripts. The FHS defines many common directories used in UNIX-like operating systems.

Linux File System Structure / - The root directory is the top of the file system hierarchy. The contents of the root file system must contain all the files needed to boot, restore, recover, and repair the system. /bin - The /bin directory contains commands used by the system administrator and other users. These are required commands when no other filesystems are mounted. /boot - The /boot directory contains all files, except configuration files, needed to boot the operating system. The /boot stores data that is used before the kernel begins executing user-mode programs.

Linux File System Structure /dev - The /dev directory contains file system entries which represent devices that are part of the system. /etc - The /etc directory contains local configuration files. No binaries are contained within /etc. /home - The /home directory contains user directories. The /home directory is optional. Typically, the /home directory contains a subdirectory for each user added to the system.

Linux File System Structure /lib - The /lib directory contains shared library images need to boot the system and run the commands in the root filesystem. /opt - The /opt directory contains add-on application software packages. /proc - The /proc file system is used to handle storage and retrieval of process information.

Linux File System Structure /root - The /root directory is the home directory of the root user. /sbin - The /sbin directory contains utilities used for system administration. These utilities are executed after /usr is known to be mounted and there are no problems. /tmp - The /tmp directory contains temporary files. These files are lost if the system restarts.

Linux File System Structure /usr - The /usr directory contains files that can be shared across all hosts. This directory is mounted read-only and contains the following subdirectories or symbolic links to directories: /usr/bin – contains most user commands /usr/include – contains header files included by C programs /usr/lib – contains libraries /usr/local – local hierarchy /usr/sbin – contains non-vital system binaries /usr/share – contains architecture-independent data

Linux File System Structure /var - The /var directory contains variable data files. This includes spool directories, log files, and temporary files. Some directories within /var are sharable and some are unsharable. The following directories are required in /var: /var/cache – contains application cache data /var/lib – contains variable state information /var/local – contains data for /usr/local /var/lock – contains lock files /var/log – contains log files and directories /var /opt - contains variable data for /opt /var/run – contains data relevant to running processes /var/spool – contains application spool data /var/tmp – contains temporary files preserved between system reboots

Permissions Every file or directory has a set of permissions that determines who can access and what they can do to the file. Permissions are represented by the characters r, w, and x which represent read, write, and execute. The r, w, and X have a different meaning depending if it is assigned to a file or a directory. r with a file means the file can be displayed or copied, with a directory means it can be listed. w with a file means the file can be changed, with a directory means it can be created or deleted. x means a file can be executed (script or program), with a directory allows files within it to be copied or moved.

Permissions For example: -rwx------ indicates a file that has read, write, and execute permissions for the owner only. -r-xr-xr-x indicates a file that has read and execute permissions for the owner, group, or anyone else. drwxr-x—x indicates a directory that allows read, write, and execute permission for the owner, read and execute for the group, and execute only for everyone else.

Permissions Permissions can also be viewed as octal numbers. r permission is represented by 4 w permission is represented by 4 x permission is represented by 1 Permissions 777 means r, w, and x permissions are enabled for the user, the user’s groups, and all others Permissions 541 means the user has r, and x permissions, the user’s group has only r permission, and all others have just x permissions.

The permission list, -rwxr-xr-x is treated as a block of binary digits, a bitfield. Translating this into octal, we would get 0755, which is 0111101101 base 2. We can then represent each permission for each user type by a single octal digit (plus an extra digit for the first bit). 400 -r-------- read by owner 040 ----r----- read by group 004 -------r-- read by anybody (other) 200 --w------- write by owner 020 -----w---- write by group 002 --------w- write by anybody 100 ---x------ execute by owner 010 ------x--- execute by group 001 ---------x execute by anybody 4000 s--------- suid 2000 s--------- sgid 1000 t--------- sticky These permissions on their own may not be very useful, but we can add the octal numbers to get a combination of permissions. For example, 4, which corresponds to r-- (for some user type), and 2, which corresponds to -w- (for some user type), can be added to get 6, 110 in binary, which corresponds to rw-, read and write. Note also that in a group of three octal digits, the "place" of the digit signifies where we assign the permission. 600 octal, in binary is 0110000000, so we are setting read and write permissions for us, but not the group or other users. 060 octal, in binary however is 0000110000, and sets it for the group only, and likewise. So, for example, if we want to set read and write for ourselves and the group, and have no permissions whatsoever for the other users, we could use the permission 660.

Changing Permissions with the CLI Change permissions for group and others to read and execute using octal numbering: chmod 755 IT250 You can also use chmod to add or remove specific permissions chmod u+w IT250 would add w permission for the user. chmod a-x IT250 would remove x permission for all (a) users.

Links A pointer to a file

Hard Links A pointer to a file – the directory entry points to the inode