Presentation is loading. Please wait.

Presentation is loading. Please wait.

Workbook 2 Part 1 - Filesystem Basic’s RH030 Linux Computing Essentials.

Similar presentations


Presentation on theme: "Workbook 2 Part 1 - Filesystem Basic’s RH030 Linux Computing Essentials."— Presentation transcript:

1 Workbook 2 Part 1 - Filesystem Basic’s RH030 Linux Computing Essentials

2 Linux+ Guide to Linux Certification, 2e 2 Workbook 2 covers: Basic Understanding of the FSH  The Linux Directory Structure  Filesystem Navigation Commands  Understanding the System Directories Managing Files & Directories  Displaying the contents of files & directories  Understanding the types of items in directories  Understanding the different types of files  Using Globbing, wildcards, metacharacters Editing Files will be covered next week.

3 Linux+ Guide to Linux Certification, 2e 3 FSH or Filesystem: Manages the storage and permissions of items in a hierarchical structure called the directory tree structure and allows the user access to items within this structure by using pathnames as their addresses. Root Directory/Sub-directories: 1st directory at the top level of the hierarchical filesystem structure always referred to using the / character. Pathname: The address which is used to identify where an item is logically located within the hierarchal filesystem structure. Absolute pathname: This type of pathname is determined from the root directory at the top of the hierarchal filesystem structure to a certain file or directory. Relative pathname: This type of pathname is determined from your current location in the hierarchical filesystem structure to a specific file or directory. Recall these terms:

4 Linux+ Guide to Linux Certification, 2e 4 System Directories Table 5-1: Linux directories defined by FHS

5 /etc holds the system configuration files There are many many configuration files. Such as the file to list what shells are available.  This file is used to list the available shells in the system  Absolute pathname is /etc/shells Which lists the absolute pathname to the available executable files which are used to run each shell.  These are all stored in /bin  It is common for the name of a shell to end in *sh.  So their absolute pathname’s would be: /bin/*sh Bash = /bin/bash Bourne = /bin/sh Cshell = /bin/csh

6 Some really fundamental system configuration files – you should know. /etc/passwd This file is used to list the attributes of the accounts in the system /etc/group This file is used to list created groups within the system /etc/shadow This file is used to store the encrypted passwords within the system /etc/shells This file is used to tell the system what shells are available to it.

7 Linux+ Guide to Linux Certification, 2e 7 Sometimes System Files are hidden.  Configuration files are often hidden.  Filenames that start with a. are hidden files.  You can hide any file by renaming it with a. at the start.  Or unhide it by removing the.  Such as your local user bash startup initialization files …. ~/.bash_profile, ~/.bashrc

8 Linux+ Guide to Linux Certification, 2e 8 Filename Extensions Files on Linux do not have to use an extension But they are often used to denote their file type When used they are similar to windows & are used as identifiers. The extension is placed after the filename following a dot (.) Text configuration files often end in.conf Such as httpd.conf Data files commonly use extensions to identify their application. Executables do not commonly use an extension. But sometimes a command can put an extension onto their output. Such as winzip does with compression. Or they are sometimes used to identify how the system uses it.

9 Linux+ Guide to Linux Certification, 2e 9 Common Extensions Table 4-1: Common filename extensions

10 Linux+ Guide to Linux Certification, 2e 10 In a Linux system there are many different types of files Text files:  Stores information in a readable ASCII text format Data files:  Associated with a specific application program it’s specific format. Executable files:  These are the Binary files which are used to run the commands and programs. Linked files:  Like shortcuts a link just associates an item with another item.  Well discuss these more later. Special device files:  These represent the system devices within the /dev directory. Such as …. hd=ide hardrive tty=terminal

11 Linux+ Guide to Linux Certification, 2e 11 File Command Sometimes you need to discover the origins of a file.  Because Linux does not follow the same pattern as Windows with the use a extensions you sometimes have to be able to identify for yourself what type of file you are working with.  This is done with the file command. file /etc/passwd file /etc/passwd /bin/ls ~/dir1/coffees/beans file ~/class-files/* file./*

12 Linux+ Guide to Linux Certification, 2e 12 Locating Commands whatis command:  used to display what this command does  display 1 st line from the man pages. whereis command:  Used to locate the binary, source and man pages for a command. which command:  Used only for executable files  Searches through the System Variable $PATH  Lists directories on system where executable files are located  Allows executable files to be run without specifying absolute or relative path

13 Linux+ Guide to Linux Certification, 2e 13 Viewing Directories ls command: Most commonly used options: ls – l : detailed display or long listing of items. ll command: Is the default Alias for ls -l ls – a : displays hidden files ls – F : used to identify types of items in the directory. ls – r : list in reverse ls – R : list contents of everything – even irectories ls – ld : detailed display of actual cwd not it’s contents.

14 Linux+ Guide to Linux Certification, 2e 14 ls –F = Display types items in a directory Modifies the displayed listing so each item is displayed with a symbol to tell what the type of item it is:  /= directory – A forward slash (/) after the name = ASCII Text File – no symbol  *= Executable – asterisk (*) after the name Symbolic Link – An at sign (similar to a shortcut in Windows )

15 Linux+ Guide to Linux Certification, 2e 15 ls –l = Long Detailed Listing

16 Linux+ Guide to Linux Certification, 2e 16 ls –R = Recursive Listing ls -R (recursive) command - displays the contents of all directories, subdirectories and their contents for a particular part of the directory tree If done at a high level in the directory structure, the output can be substantial!

17 Linux+ Guide to Linux Certification, 2e 17 Globbing Wildcard Metacharacters A metacharacter is any keyboard character that has a “special” meaning to a shell when used in a command-line.  Used to simplify commands specifying multiple filenames  Can be used with most Linux filesystem commands

18 Linux+ Guide to Linux Certification, 2e 18 Using Metacharacters Asterik ‘*’  ‘*’ matches zero or more characters. Except the leading dot ‘.’ on a hidden file.  Commonly referred to as a wildcard character.  Using with the ls command will list all the files that match the pattern made by using ‘*’, as well as the directories and their contents that match. Question Mark ‘?’  Matches a single character. Except the leading dot ‘.’ on a hidden file.

19 Linux+ Guide to Linux Certification, 2e 19 Using Metacharacters Square Brackets ‘[ ]’  These are called ranges  If looking for a range, then the characters must be in order. [az] looks for the 2 lower case characters ‘a’ or ‘z’ inclusive [a-z] looks for any lower case character between ‘a’ and ‘z’ Case sensitive. [a-z] and [A-Z] are not the same Semicolon ‘;’  Enables typing in multiple commands on the command line without having to press “enter” in between them.  Put the ‘;’ in between each command.  Called the “command separator.”

20 Linux+ Guide to Linux Certification, 2e 20 Example of use.

21 Linux+ Guide to Linux Certification, 2e 21 What does this command do? $ ls *[1-5]*p Metacharacters Exercise

22 Linux+ Guide to Linux Certification, 2e 22 There are many commands commonly used: cat head tail more less Displaying the contents of Text Files

23 Linux+ Guide to Linux Certification, 2e 23 Cat command Really there are multiple uses for this command. 1. Mainly used to display contents of a text file on the screen -n switch: Displays line number and contents cat /etc/passwd 2. Concatenation: Joining text files together cat file1 file2 file3 > new-big-file 3. Create new quick files – similar to ‘DOS copy con’ cat > new-file tac command: Displays content of files in reverse order

24 Linux+ Guide to Linux Certification, 2e 24 head command: Views first 10 lines of a file by default  You can also specify how many lines to show  head - 6 tail command: Views last 10 lines of a file by default  You can also specify how many lines to show  tail - 15  You can also specify what line number to start the display from.  tail + 50 more command: Displays output page-by-page  Use the Space key to go to the next page  Use the Enter key to go to the next line less command: Same as more command.  But can also use cursor to scroll backwards. Displaying the Contents of Text Files

25 Linux+ Guide to Linux Certification, 2e 25 Using more/less with a pipe more and less is often used with the output from other commands If output is too large to fit on terminal screen, you would use the “|” pipe metacharacter with the more or less command. ls -l | more cat dante | more more dante

26 Linux+ Guide to Linux Certification, 2e 26 $ ls -al | head > myfiles What does this command do?

27 Linux+ Guide to Linux Certification, 2e 27 $ ls -al | head > myfiles take the top ten files listed and put this part of the listing in a file called myfiles Piping & Redirection Solution

28 Linux+ Guide to Linux Certification, 2e 28 There are many commands commonly used: mkdir rmdir rm cp mv Working with Directories

29 Linux+ Guide to Linux Certification, 2e 29 Managing Files and Directories mkdir command: Creates new directories mkdir Will make a new directory mkdir –p Will make a hierarchical pathname structure using a only a single command. mkdir –p ~/newdir1/newdir2/newdir3 rm command: Removes files only rm -r command: Removes directories +files + sub-directories etc -r recursive copy entire contents of a directory -i interactive prompts user before overwriting files -f force action overrides interactive mode rmdir command: Removes directories only if they are empty

30 Linux+ Guide to Linux Certification, 2e 30 Managing Files and Directories cp command: Copies files 2 arguments minimum: Source file/directory (may specify multiple sources) Target file/directory - mandatory. = cwd -r recursive copy entire contents of a directory -i interactive prompts user before overwriting files -f force action overrides interactive mode mv command: Move/Rename files or directories Used to move items Also used to rename items Same use of arguments as the cp command

31 Linux+ Guide to Linux Certification, 2e 31 $ mv ??[abc]../.. What does this command do?

32 Linux+ Guide to Linux Certification, 2e 32 $ mv ??[abc]../.. move any file(s) with only three characters in the name, anything in the first two character positions, a or b or c in the third position, up two directory levels solution

33 Workbook 2 - Command Summary /etc /home /root /boot /var /usr /bin /sbin ls cd pwd /... ~ touch whoami which exit > >> cp mv rm echo mkdir rmdir rm - r cp -r ls – F r a l s R *, ?, [a-z], [az] ranges file cat less head more


Download ppt "Workbook 2 Part 1 - Filesystem Basic’s RH030 Linux Computing Essentials."

Similar presentations


Ads by Google