Chmod: Changes Access Permissions • When You Own a File, You Can Use the Chmod (Change Mode) Utility to Change Access Permissions for That File

Chmod: Changes Access Permissions • When You Own a File, You Can Use the Chmod (Change Mode) Utility to Change Access Permissions for That File

Fall 2009 Lecture 6 Operating Systems: Configuration & Use CIS345 The Linux Filesystem Mostafa Z. Ali [email protected] 1‐1 The Linux FileSystem • A filesystem is a set of data structures that usually resides on part of a disk and that holds directories of files. • Filesystems store user and system data that are the basis of users’ work on the system and the system’s existence The Hierarchical Filesystem • A hierarchical structure frequently takes the shape of a pyramid • Ex: One example of this type of structure is found by tracing a family’s lineage: A couple has a child, who may in turn have several children, each of whom may have more children. This hierarchical structure is called a family tree • Directory tree: Like the family tree it resembles, the Linux filesystem is called a tree. • This structure allows you to organize files so you can easily find any particular one. On a standard Linux system, each user starts with one directory, to which the user can add subdirectories to any desired level Directory Files and Ordinary Files • Ordinary files, or simply files, appear at the ends of paths that cannot support other paths. • Directory files, also referred to as directories or folders, are the points that other paths can branch off from • Pathname: is a series of names that trace a path along branches from one file to another Filenames • The maximum length of a filename varies with the type of filesystem • Linux supports several types of filesystems • Most of today’s filesystems allow you to create files with names up to 255 characters long • While you can use almost any character in a filename, you will avoid confusion if you choose characters from the following list • Uppercase letters (A–Z) • Lowercase letters (a–z) • Numbers (0–9) • Underscore (_) • Period (.) • Comma (,) Filename length • When you share your files with users on other systems, you may need to make long filenames differ within the first few characters. • Systems running DOS or older versions of Windows have an 8‐character filename body length and a 3‐ character filename extension length limit. • Some UNIX systems have a 14‐character limit and older Macintosh systems have a 31‐character limit. • The disadvantage of short filenames is that they are typically less descriptive than long filenames. • Linux is case sensitive. • It is a poor idea to use SPACEs within filenames because a SPACE is a special character, you must quote it on a command line. • Use periods or underscores instead of SPACEs: joe.05.04.26, new_stuff. • If you are working with a filename that includes a SPACE, such as a file from another operating system, you must quote the SPACE on the command line by preceding it with a backslash or by placing quotation marks on either side of the filename. $ lpr my\ file $ lpr "my file" Filename Extensions • A filename extension is the part of the filename following an embedded period • filename extensions help describe the contents of the file, but in some cases, however, filename extensions are optional • Use extensions freely to make filenames easy to understand. If you like, you can use several periods within the same filename—for example, notes.4.10.01 or files.tar.gz. Hidden Filenames • A filename that begins with a period is called a hidden filename (or a hidden file or sometimes an invisible file) because ls does not normally display it – The .plan file is hidden. – Two special hidden entries—a single and double period (. and ..)—appear in every directory • The command ls –a displays all filenames, even hidden ones The Working Directory • The directory you are associated with is called the working directory or current directory • The pwd (print working directory) utility displays the pathname of the working directory Home Directory • When you first log in on a Linux system or start a terminal emulator window, your working directory is your home directory • To display the pathname of your home directory, use pwd just after you log in Startup Files • Startup files, which appear in your home directory, give the shell and other programs information about you and your preferences • Frequently one of these files tells the shell what kind of terminal you are using and executes the stty (set terminal) utility to establish the erase and line kill keys Pathnames • a pathname shows the pathnames of directories and ordinary files in part of a filesystem hierarchy. An absolute pathname always starts with a slash (/), the name of the root directory Absolute Pathnames • An absolute pathname always starts with a slash (/), the name of the root directory • String all the filenames in the path together, separating each from the next with a slash (/) and preceding the entire group of filenames with a slash (/). • This path of filenames is called an absolute pathname because it locates a file absolutely by tracing a path from the root directory to the file • Example: To list all the files in the /etc/apt directory: $ pwd /home/sam $ ls /etc/apt Apt.conf.d sources.list sources.list.save trusted.gpg Secring.gpg sources.list.d trustdb.gpg trusted.gpg~ ~ (Tilde) in Pathnames • In another form of absolute pathname, the shell expands the characters ~/ (a tilde followed by a slash) at the start of a pathname into the pathname of your home directory. Using this shortcut, you can display your .bashrc startup file with the following command, no matter which directory is your working directory: $less ~/.bashrc • A tilde quickly references paths that start with your or someone else’s home directory. The shell expands a tilde followed by a username at the beginning of a pathname into the pathname of that user’s home directory. • For example, assuming he has permission to do so, Alex can examine Scott’s .bashrc file with the following command: $less ~scott/.bashrc Relative Pathnames • A relative pathname traces a path from the working directory to a file. The pathname is relative to the working directory • Any pathname that does not begin with the root directory (/) or a tilde (~) is a relative pathname • The simplest relative pathname is a simple filename, which identifies a file in the working directory Significance of the Working Directory • Files that are children of the working directory can be referenced by simple filenames. • Grandchildren of the working directory can be referenced by short relative pathnames: two filenames separated by a slash. • When you manipulate files in a large directory structure, using short relative pathnames can save you time and aggravation. • If you choose a working directory that contains the files used most often for a particular task, you need to use fewer long, cumbersome pathnames. Working with Directories mkdir: Creates a Directory • The mkdir utility creates a directory • The –F option to ls displays a slash after the name of each directory and an asterisk after each executable file (shell script, utility, or application). • When you call it with an argument that is the name of a directory, ls lists the contents of that directory. • Use the –p (parents) option to mkdir to create both the literature and promo directories with one command cd: Changes to Another Working Directory • The cd (change directory) utility makes another directory the working directory but does not change the contents of the working directory • The second cd command in the figure below does not have an argument so it makes Alex’s home directory the working directory The . and .. Directory Entries • mkdir automatically puts two entries in each directory you create: • a single period (.) ‐ working directory and can be used in its place • a double period (..) ‐ the pathname of the parent of the working directory • These entries are hidden because their filenames begin with a period rmdir: Deletes a Directory • The rmdir (remove directory) utility deletes a directory. • You cannot delete the working directory or a directory that contains files other than the . and .. entries. • You do not have to (nor can you) delete the . and .. entries; rmdir removes them automatically • The rm utility has a –r option that recursively deletes files, including directories, within a directory and also deletes the directory itself Using Pathnames • you can use touch to create an empty file • With /home/alex as the working directory, the following example uses cp with a relative pathname to copy the file letter to the /home/alex/literature/promo directory • The copy of the file has the simple filename letter.0610 mv, cp: Move or Copy Files • You can use this utility to move files from one directory to another (change the pathname of a file) as well as to change a simple filename. • If the working directory is /home/alex, Alex can use the following command to move the files names and temp from the working directory to the literature directory • This command changes the absolute pathnames of the names and temp files from /home/alex/names and /home/alex/temp to /home/alex/literature/names and /home/alex/literature/temp, respectively mv: Moves a Directory • Just as it moves ordinary files from one directory to another, so mv can move directories • If new‐directory does not exist, the existing‐ directory‐list must contain just one directory name, which mv changes to new‐directory (mv renames the directory). Although you can rename directories using mv, you cannot copy their contents with cp unless you use the –r option Important Standard Directories and Files • Check pages 194‐196 (Just for your knowledge) … you will need this later! Access Permissions • Ubuntu Linux supports two

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    50 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us