Presentation is loading. Please wait.

Presentation is loading. Please wait.

Managing Files. Module 5 Managing Files ♦ Introduction “On a Linux system, everything is a file; if something is not a file, it is a process.” ♦ Topics.

Similar presentations


Presentation on theme: "Managing Files. Module 5 Managing Files ♦ Introduction “On a Linux system, everything is a file; if something is not a file, it is a process.” ♦ Topics."— Presentation transcript:

1 Managing Files

2 Module 5 Managing Files ♦ Introduction “On a Linux system, everything is a file; if something is not a file, it is a process.” ♦ Topics ► What is a File? ► File Characteristics ► What can we do with Files?

3 Managing Files What is a File? ♦ A file is a container for data or link to a device. ♦ Every file has a name and may hold data that resides on a disk. ♦ A file is a name and the associated data is stored on a mass storage device. It is a stream of data bytes. ♦ The different types of files are: ► Regular files ► Can be text, data and drawings. ► Executable programs. ► Directories. ► Special files.

4 Managing Files [root@localhost root]# ls -l total 1872 -rw-r--r-- 1 root root 1134 Sep 28 12:31 anaconda-ks.cfg drwxr-xr-x 3 root root 4096 Oct 3 15:29 Desktop drwx------ 8 root root 4096 Oct 3 15:15 evolution -rw-r--r-- 1 root root 47186 Sep 28 12:30 install.log -rw-r--r-- 1 root root 3436 Sep 28 12:30 install.log.syslog drwxr-xr-x 3 root root 4096 Oct 1 12:48 intro-linux -rw------- 1 root root 1832960 Oct 1 12:42 intro-linux.html.tar drwx------ 7 root root 4096 Oct 1 14:45 Mail -rw-r--r-- 1 root root 51 Oct 3 12:44 new.txt [root@localhost root]# File Characteristics ♦ A file has several characteristics associated with it. They can be displayed using the ls –l command as shown below: Contd…

5 Managing Files File Characteristics ♦ Example: -rw-r--r-- 1 root root 1134 Sep 28 12:31 anaconda-ks.cfg 0 1 2 3 4 5 6 7 ♦ The explanation of output is as follows: ► File Type ► – regular file ► d directory ► l link file ► c character special file ► b block special file ► p pseudo special file ► Permissions ► No. Of links to the File Contd…

6 Managing Files File Characteristics ► Owner ► Group ► File Size Bytes ► Time Stamp ► File Name

7 Managing Files What can we do with Files? ♦ A file is a collection of data, stored on disk and that can be manipulated by listing the contents in the directory, changing the locations of files and directories, viewing files, creating and editing files, moving, copying and deleting files. ♦ The user can also create directories, change directories, delete directories and view PDF files. ♦ A directory is also a file that acts as a folder for other files. ♦ A directory can also contain other directories (subdirectories); a directory that contains another directory is called the parent directory of the directory it contains.

8 Managing Files ♦ Copying files Copying files and directories is done using the cp command. The cp command is used to copy the files and directories from the specified source to the specified destination. The user can copy a file into the directory, but under a different name. Syntax cp Example: # cp file1 dir1 ♦ Removing files The rm command is used to remove single files, rmdir to remove empty directories (Use ls -a to check whether a directory is empty or not). The rm command also has options for removing non-empty directories with all their subdirectories, read the Info pages for different options of rm command. Contd… Manipulating files and directories

9 Managing Files Manipulating files and directories ♦ Moving and Renaming files The mv command is used to move a file from its source to any location within the file structure. Example of moving a file: # mv file1 /iiht/file1 The above example says, the file file1 is moved to a different directory iiht. ► The mv command is also used to rename a file or a directory ► Example of renaming a directory: # mv iiht dir1 Contd…

10 Managing Files ♦ Linking files A link is nothing more than a way of matching two or more file names to the same set of file data. There are two ways to achieve this: ► Hard link ► Soft link ♦ Hard link Associates two or more file names with the same inode. Hard links share the same data blocks on the hard disk, while they continue to behave as independent files. ♦ Soft link or symbolic link (or symlink) Soft link is a small file that is a pointer to another file. A symbolic link contains the path to the target file instead of a physical location on the hard disk. Since inodes are not used in this system, soft links can span across partitions. Manipulating files and directories

11 Managing Files Lab Exercise ♦ Create a directory by name test and create the files file1 file2 and file3, create hardlink for file1 to new file data. ♦ Differentiate deleting hard link files and soft link files.


Download ppt "Managing Files. Module 5 Managing Files ♦ Introduction “On a Linux system, everything is a file; if something is not a file, it is a process.” ♦ Topics."

Similar presentations


Ads by Google