Lesson Unix file system

31 41 0
Lesson Unix file system

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Lesson Unix file system present the content: made for power and flexibility, navigation is cryptic, single root directory, the root directory is designated, everything in Unix is a file...

Unix File System Unix File System File System Unix Overview File System The file system has the following qualities: • Made for power and flexibility • Navigation is cryptic • Single root directory – The root directory is designated / • Everything in Unix is a file File System Directories are special files: • Hold names of files or directories • Looks like a hierarchical tree • Similar to DOS • Unix uses forward slashes (/) • DOS uses backslashes (\) Unix Overview Unix File System File Attributes File Attributes File Name: • String of characters • No relevance to periods or other characters • Some programs can expect specific type of file names – Compilers can expect file extensions Unix Overview File Attributes File Path: • Full path specifies all directories -> /usr/aci/class02/temp • Filename used when in current directory File Attributes / “/” represents the root directory aci class02 tempfile /aci/class02/tempfile Unix Overview File Attributes File Permissions: • Each file has permissions for owner, group, and others access • Read, write, and execute are the permissions • Permissions can be set different for owner, group, and others usage • Permissions apply to directories as well as files Unix File System File Types Unix Overview File Types Unix has four file types: • Ordinary files • Directory • Device • Link File Types Ordinary files: • Text files - ASCI -> program source code • Binary files -> Compiled objects • Hidden files – profiles or configuration files -> Begin with a period -> Are not displayed when listing files unless the “all” option is used Unix Overview File Types Directory files: • A directory is considered to be a file since it also contains information about its contents, such as file names, file sizes, and last modification time File Types Device files: • Physical devices are represented as files the same read() and write() functions that work on files also work on devices Unix Overview File Types Link files: • A link file is an alias to an existing file • Both names use the same physical file • If the link is removed, the file still exists • If the file name is removed with a link to it, the file remains but uses the link name File Types Example of file types Unix Overview Unix File System Working With Directories Working With Directories Know where you are to work effectively! • To change directories • To manipulate files • To run processes Know the directory you are in!!! Unix Overview Working With Directories Unix has a command to identify the current working directory • Print Working Directory – pwd Working With Directories pwd Command Unix Overview 10 Working With Directories cd Working With Directories • To change from one directory to another directory, the change directory command can be used with a complete directory path starting at the root directory ( / ) Unix Overview 17 Working With Directories cd /directory name/ … Working With Directories • To return to the previous directory use the change directory command and two periods • Separate change directory command and the two periods with a space Unix Overview 18 Working With Directories cd Working With Directories • To change from one directory to another that is more than one directory from the current directory, use the change directory command with the current directory option ( /) cd /next directory/next directory/… Unix Overview 19 Working With Directories To display the contents of a directory use the list command Depending on what information you wish to display will determine what options to include • List contents of a directory command – ls • Options are included by using a space and a hyphen followed by the list of options Working With Directories The list command has a number of options: • No options returns a file list • -a -> include all files (hidden files too) • -l -> see file information • -r -> list in reverse order • -t -> sort by modification Unix Overview 20 Working With Directories When using ls –l option, the file information is read from right to left and includes: • The file name • The last modification date and time • The file size in bytes • The group of the file owner • The owner of the file • The number of links to the file • The file permissions Working With Directories Examples of the ls command Unix Overview 21 Working With Directories Examples of the ls command Unix File System File Permissions Unix Overview 22 File Permissions • Unix has several users and groups • A user can belong to multiple groups, but • • can be active in only a single group at a time Users are assigned a primary group and can assume the privileges of secondary groups Files have user, group, and others permissions File Permissions File permissions are defined for three levels of access: • u -> owner/user • g -> group • o -> others When changing permissions by groups to the same setting, you can use the all group level: • a -> all Unix Overview 23 File Permissions File permissions define what actions may be taken on a file in Unix: • r -> Read • w -> Write • x -> Execute File Permissions • Read permissions control whether • • Unix Overview someone can view a file Write permissions allows or disallows changes to be made to a file such as update or delete Execute permissions control whether a file can be run 24 File Permissions The permissions on a file are displayed when a long list command (ls -l) is performed The right-most 10 characters displayed: • Positon is the file type • Postions 2-4 are the owner permissions • Postions 5-7 are the group permissions • Postions 8-10 are the others permissions File Permissions 051o:/db01/pmdev/r051o>ls total 240 drwxrwxr-x pmdev drwxrwxr-x pmdev drwxrwxr-x pmdev drwxrwxr-x pmdev drwxrwxr-x pmdev drwxrwxr-x pmdev drwxrwxr-x pmdev drwxrwxr-x pmdev drwxr-xr-x pmdev drwxr-xr-x 10 pmdev -rw-r r-1 pmdev • • • • Unix Overview File Type User Permissions Group Permissions World Permissions -lrt pmdev pmdev pmdev pmdev pmdev pmdev pmdev pmdev pmdev pmdev pmdev 96 96 96 96 96 96 16384 8192 8192 8192 45 Column Columns Columns Columns May May May May May May May May May Jun Jun 4 4 4 13 19 22 27 2005 2005 2005 2005 2005 2005 2005 2005 2005 2005 2005 fh hm ip mc sz vs dcllib testdata script PMJournalFeed afiedt.buf 2-4 5-7 8-10 25 File Permissions The first position displays the file type • - -> a file • d -> a directory • l -> a linked file File Permissions The following ls –la command returns directories and files Unix Overview 26 File Permissions To create an empty file use the touch command with a file name • touch myfile File Permissions touch command Unix Overview 27 File Permissions The file permissions for myfile are: • - file type is file • rw-> owner permissions for read and write • r > group permissions of read only • r > others permissions of read only File Permissions The change mode command is used to change file permissions • chmod –rwxr-xr-x myfile (include the file type in position 1) • chmod 755 myfile • chmod u=rwx,g=rx,o=rx myfile • chmod g=rwx myfile • chmod a=rwx myfile Unix Overview 28 File Permissions chmod -rwxr-xr-x myfile • chmod can use a string of nine permissions r -> sets the read permission w -> sets the write permission x -> sets the execute permission -> does not set permission File Permissions chmod 755 myfile • chmod can use octal number -> For each permission set use or to indicate the permission is unset or set -> Convert the digit binary number of each set to an octal number -> Use chmod with the octal numbers Unix Overview 29 File Permissions Calculating the Octal number Permissions Binary Octal x 001 -w010 -wx 011 r-100 r-x 101 rw110 rwx 111 File Permissions chmod using Octal numbers example • User read, write, execute • Group read and execute • Others read only -> chmod -rwxr-xr myfile -> chmod 754 myfile Unix Overview 30 File Permissions To see other usages of chmod, use the following command at the Unix prompt man chmod You can browse the help by hitting , or you can use to Return to the Unix prompt File Permissions Example: man chmod Unix Overview 31 ... directories as well as files Unix File System File Types Unix Overview File Types Unix has four file types: • Ordinary files • Directory • Device • Link File Types Ordinary files: • Text files - ASCI ->... 26 File Permissions To create an empty file use the touch command with a file name • touch myfile File Permissions touch command Unix Overview 27 File Permissions The file permissions for myfile... file permissions • chmod –rwxr-xr-x myfile (include the file type in position 1) • chmod 755 myfile • chmod u=rwx,g=rx,o=rx myfile • chmod g=rwx myfile • chmod a=rwx myfile Unix Overview 28 File

Ngày đăng: 06/08/2020, 04:51

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan