Basic File System Management Tasks

Дата канвертавання22.04.2016
Памер16.22 Kb.
Class Notes on 17 April 2015:

  • Basic File System Management Tasks :

  • Essentially, everything on your RHEL server is stored in a text or ASCII file. Therefore, working with files is a very i mportant task when administering Linux. . . .A Directory is a special kind of file, but it is still a (case sensitive) file. . .Each terminal window. . .any hard disk or partition and any processes are all represented somewhere in the file system as a file. . .It will become clear throughout this program, that everything in Linux is a file

  • All files on Linux (or Unix) are case sensitive: Meaning that FILE1 is different from file1 and /etc/hosts is different from /etc/Hosts

  • The “file” command determines the file type. . .Linux does not use extensions to determine the file type. . .

  • The command line does not care whether a file ends in .txt or .pdf

  • As a system administrator, you should use the “file” command to determine the file type.

  • For Example: # file /etc/passwd

  • The “file” command uses a magic file that contains pattersn to recognize file types. . .The magic file is located in “/usr/share/file/magic” . . Type “# man 5 magic” for more info.

  • cd command: use this command to change the current working directory. Example: cd /bin(pathname)

--- Names of commands and directories are case-sensitive

      • Pathnames [Two types: Absolute and Relative]

      • Absolute Pathnames: begins with the root directory and follows the tree branch by branch until the path to the desired directory or file is completed

      • Relative Pathnames: starts from the current working directory. To do this, it uses a couple of special symbols to represent relative positions in the file-system tree.

--- These special symbols are . (dot) and .. (dot dot):::::: The . symbol refers to the working directory and the .. symbol refers to the working directory’s parent directory :::::

show example: cd .. takes you to the working directory’s parent directory

--- Example: type “pwd”

  • mkdir command: use command to create a new directory.

--- Example: creating directory in root: mkdir /test

--- Example: create directory in apps directory: cd /opt/apps then mkdir test

    • It is possible to create a complete directory structure in one command:

--- use “-p option” with mkdir to make this possible

////start add on: 12 Mar 2015 ///////////
--- when -p option is used, no error is reported if a specified DIRECTORY already exists
--- The -p option allows you to create parent directories as needed (if parent do not already exits). For example, you can create the following directory structure:
Example: $ mkdir -p ~/public_html/images/trip
////end add on: 12 Mar 2015 ///////////

--- Example: mkdir –p /test/test2/test3

//// start add on: 12 Mar 2015 ///////////

-- -m, --mode option: Set file mode /

--- Example: mkdir -m a=rwx mydir (Create the mydir directory, and set its permissions such that all users may read, write, and execute the contents.)
////end add on: 12 Mar 2015 ///////////

  • rmdir command: This command is used to remove directories.

--- This command works with only directories that are empty

--- Example: rmdir /test

--- In order to remove both a parent directory and a subdirectory of that parent, the subdirectory must be specified first so the parent directory is empty when rmdir tries to remove it

--- Example Below

In this example, remove data, foo and bar if bar were empty, foo only contained bar and data only contained foo directories:

cd /home/nixcraft

rmdir -p data/foo/bar
--- -p - Each directory argument is treated as a pathname of which all components will be removed, if they are empty, starting with the last most component.

База данных защищена авторским правом © 2016
звярнуцца да адміністрацыі

    Галоўная старонка