Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

a. Enter the command to change to your user2 directory by either relative or absolute pathname from your home directory. What command did you use?

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

a. Enter the command to change to your user2 directory by either relative or absolute pathname from your home directory. What command did you use? b. Enter this command to verify the directory you are in again. c. What was the response? d. Enter the following command: $ ls dirl e. What is it displayed? Step 6. Use the Is Command with Arguments The la command will list any subdirectories and files that are in the current working directory. You do NOT need to change the location to list the files and subdirectories. Arguments for the ls command can be directory name(s) and file name(s) (by using either relative or absolute pathname). For example, use the absolute pathname to list all files or directories of user2 under the user's home directory $ ls /home/csc156/yourusername /user2 Or, we can use the relative pathname to list all files and subdirectories of the user2 directory if the user at his/her home directory. $ ls user2 same as $ ls /user2 a Enter the command to change back your home directory. What command did you use? b. Enter the command to display (or list) the contents of the dir2 directory using a relative pathname from your home directory What command did you use? What was the response? c. Enter the command to list all the files in the /etc directory (a standard LINUX directory under the root "") using an absolute pathname. What command did you use? d. Enter the command to list the files in the planets directory from the diagram using an absolute path name? What command did you use? e. Enter the command to list only the dante file from your home directory (to see if it exists and not see all other files and directories). What command did you use? (Using either absolute or relative pathname) 1. Enter the command to list the contents of coffees directory from your home directory What command do you enter at the command prompt by using the relative pathname? Step 7. Use the Is Command to see Hidden Files with a option File names that begin with a dot (.) are called hidden files. Hidden files are frequently used to customize a user's work environment (ex: profile, .dtprofile .kshrc, .cshrc etc.). They are not shown by default because they are infrequently edited. The current directory link (.) and parent directory link (..) are also hidden and will not be displayed either since they begin with a dot. Using the Is command with the -a (all) option will list all files in a directory, including hidden (.) files. Note that the-a option is lower case. Note: You should be in your home directory to answer the following questions. If not, change to your home directory first then answer the following questions. a. Enter the command to verify where you are. What command did you use? b. What is the result? c. Enter the basic ls command without the any options. Do you to see any hidden files (those that begin with a dot)? d. Enter the command that will allow you to see ALL files in your home directory? e. How many hidden files are there? f. Enter the following to create a new empty file called hidden file using the touch command (be sure to make the first character a dot). S touch hiddenfile g. Enter the ls -a command again. Is hiddenfile listed? Step 8. Use the Is Command to See File Types with-F option When using the ls command by itself, you can obtain a listing of directory contents but cannot tell which files are and which directories are. By using the ls command with the - F (File type) you can display a listing with a symbol to tell what the type of the file is -E.--classify append indicator (one of ZI@) to entries The symbol (if present) is found at the end of the file or directory name. Note that the-F option is an upper case F. There are four LINUX/UNIX file types: Directory, Executable, ASCII text file, and Symbolic link. Directory - A forward slash (l) after the name indicates this is a directory (or subdirectory). A directory is considered a type of file with LINUX/UNIX. ASCII Text File - If there is no symbol after the name this indicates a plain ASCII text file with no formatting characters in it. (ASCII is the American Standard Code for Information Interchange). An ASCII text file is similar to a DOS text file. Executable-An asterisk (*) after the name indicates that this is a command, an application or a script file, which can be run or executed. Symbolic Link -An at sign (@) after the name indicates a symbolic link which is a way of giving a file an alternate name. Symbolic links are covered later in this course. a. Enter the command that will allow you to see the file names from your home directory and their TYPE. The /usr/bin directory (a standard LINUX directory under the root) contains many LINUX/UNIX executable commands, some of which you have already used. Enter the command to see the fies and types in the /usr/bin directory. What command did you use? d. What types of files are present? e. The /etc directory (a standard LINUX directory under the root) contains many different type of LINUX/UNIX system files. Enter the command to see the files and types in the /etc directory. What command did you use? Which different kinds of file types do you see? f 9. Enter the command to find the file type of the auto.net file under /etc directory from your current home directory? Step 9. Use the Is Command to Displaying a Long Listing format and more options The previous versions of the is command displayed the names of directories and files in a wide format(across the screen). The ls command can be used with the - (long) option to see more detailed information on each file or directory. The ls -l option will also distinguish between files and directories. Note that the option is a lower case letter L. For example, Enter the command: $ ls -1 Shown below is an example of a long listing for a file (dante) and a directory (dir) from your user2 directory. The listing is interpreted as follows: -IW-r--I-- 1 user2 staff 320 Dec 7 11:43 dante drwxr-xr-x 5 user2 staff 512 Dec 4 13:43 dirl The first position of the display indicates whether this is a file or a directory. The lower case letter d indicates a directory: the dash (-) indicates a file. The next group of characters (r.wx and dashes) are the permissions for the file or directory. Next is the number of links (1,5), followed by the file owner (user2), the file or directory access group (staff), file size (320, 512), the date and time created (or modified) and then the name of the file or directory. Links, owner and group are covered later in the course. e to your user2 directory form your home directory. What command did you use by using the relative pathname? b. From your user2 directory, enter the basic ls diri/coffees command without any options. What information was displayed on the screen? C. Enter the command that will allow you to see a long listing for the file names at your dirt/coffees directory. What command did you enter? d. Which file is over 300 bytes in size? e. Who is the owner of these files? Note: Using -t (time) option will list files with the most recently modified at the top of the list. To get a detailed (long) listing of files sorted by time (most recent at the top) use the $ls -lt version of the command. f. Enter the ls -lt command. What is the most recently created or modified file? Using -S option (uppercase S) to sort files by file sizes g. Enter the command to sort by file sizes as well as display it as a long list What command do you use? h. What is the filename for the biggest file size? Using -s option (lowercase s) to print the allocated size of each file, in blocks a. Enter the command to print the allocated size of each files under the dir1 subdirectory. What command do you use? b. How many blocks for the coffees subdirectory? Using -r option to sort files by the reverse order. C. Enter is command, do you see all files list by the alphabetical order? d. Enter the command to list long listing as well as sort the files by the reverse order, what command do you use? e. What is the first filename from the list? Step 10. Use the ls Commandwith-i option to List inode (index) number An inode is an entry in inode table, containing information (the metadata) about a regular file and directory. An inode is a data structure on a traditional Unic-style file system such as ext3 or ext4. Use $ ls - lower case i option to display the inode (index) number for each file and directory under the current location. a. Type pwd command, what is the result? b. If you are not at the user2 directory, change to the user2 directory. If yes, continue the following steps. c. What command do you use to find out the inode number of the practice directory? d. What is the inode number of the practice directory? e. Use the command to find out the inode number for fruit2 file from the user2 directory, what command do you use? f. What is the inode number for the fruit2 file? 9. What command do you use to find out the inode number of the fruit directory which is under diri directory? h. What is the inode number for the fruit subdirectory? Step 11. Use the ls Command to List Individual Directories and Recursively Is command with option: d. --directory list directory entries instead of contents, and do not dereference symbolic link Use ls -ld to display detailed information about a directory, but not its contents. This is useful when you want to see the properties of a directory and not the information about its contents. Use ls -R (recursive) play the contents of a directory and all of its subdirectories Note that the -R option is an upper case R. Recursive means to do again and again. This option is useful if you want to see all directories, subdirectories and their contents for a particular part of the directory tree. If this is done at a high level in the directory structure the output can be substantial. a. Change back to your home directory. What command did you use? b. From your home directory, what command do you use to provide a long listing for the contents of dir2 directory? From your home directory, enter the command that will provide a long listing of just the information for the dir2 directory itself not the contents. (Either absolute or relative) d. From your home directory, enter the command that will provide a long listing for just the information on the planets directory itself by using a relative path name. e. From your home directory, enter the command that will provide a recursive listing for the dir2 directory. a. From your home directory, enter the command that will provide a recursive listing for the coffees directory Step 12. Determine File Type with the file Command There are many types of files found on a LINUX/UNIX system. The file type can be determined by using the file command. This information can be important when a user is attempting to open or read a file. Determining the file type can help a user decide which program or command to use to open the file. The output from this command will most often be one of the following: Text, Executable or Data $ file my file My_file: ASCII text The file in the preceding example is a text file. Text Files - Examples include ASCII or English text, commands text, and executable shell scripts. This type of file can be read using the cat or more commands and can be edited using vi or another text editor a. Change to the user2 directory, what command do you use? b. Use the file command to determine the file type for the dante file in your user 2 directory. What command do you use? c. What kind of file is it? Executable or Binary Files - Examples include 32-bit executable and extensible linking format (ELF) code files and other dynamically linked executables. This file type indicates that the file is a command or program, Use the file command to determine the file type for the cal file under the /usr/bin directory. (Hint: the standard directory /usr/bin directly under the root) What command do you use? a. US b. What kind of file is it? Data Files - Data files are created by applications running on the system. In some cases the type of file is indicated, for example, FrameMaker (Desktop Publishing software) document. a. Use the file command to determine the file type for the beans file is in the dir/coffees subdirectory. What command do you use? b. What kind of file is it? a. Use this command to determine the file type of auto.net file under letc directory, what command do you use? b. What is the result? c. What command do you use to find out what the dante file is from you home directory by using the relative pathname? d. What is the result? Step 13. Use the ls Command With the Asterisk (*) Metacharacter The asterisk (*) is a substitution symbol that represents zero or more characters, except the leading dot on a hidden file. The asterisk is often referred to as a wildcard character. If there were a large number of files in a directory and you only wanted to see a listing of project files that started with p1 you could use the asterisk to limit the numbers of files listed. As an example, enter the command as: $ls p* This command would list all files and directories starting with p and any number of characters after that. The asterisk can be placed anywhere (beginning, middle or end) of the string being tested and can appear multiple times. If you enter $ls d you will see only those files beginning with the letter d and the contents of any subdirectories that start with the letter d. a. What command will you change to user2 directory? b. Enter the command to list files and directories from your user2 directory that start with the letter f. What command did you use? c. What was listed? d. Enter the command to list files and directories in vour user2 directory that start with the letter d. What command did you use? e. Enter the command to list files and directories in your user2 directory that end with the number 1. What command did you use? 1. Enter the command to list files and directories in your user2 directory that have the characters 'ru' anywhere in the file name. (Hint: maybe it starts with ru or in the middle or at the end of filenames.) What command did you use? g. What was listed? What command did you use? i. What was listed? 1. What command did you use to list files and directories in the dir2 directory that end with the letters using a relative path name? k. What was listed? Step 14. Use the ls Command With the Question Mark The question mark (2) is a substitution character that matches any single character, except for the leading dot on a hidden file. The question mark is also referred to as a wildcard character The example below shows the use of the Is command using the question mark in the fourth position. Enter the command: $ ls dir? This indicates that the file or directory name must start with dir but any character can be in the fourth position and the file name cannot be more than four characters long. a. Enter the command to list files and directories in your user2 directory that start with the letters file in the first four positions with anything in the fifth position but are not longer than five characters. What command did you use? b. What was listed? Enter the command to list files and directories in your user2 directory that start with the letter f in the first position with anything in the second and third positions and the characters e3 in the last two positions that are not longer than five characters. What command did you use? d. What was listed? Step 15. Use the ls Command With Square Brackets Square brackets (0) can be used to match a set or range of characters for a single character position in the file or directory. The characters inside the brackets do not generally need to be in any order, for example, [abc) is the same as (cab]. However, if you are looking for a range of characters, they must be in proper order (for example, [a-z] or [3-9]). If you want to search for all alphabetic characters, whether lowercase or uppercase, use (A-2) for the can use alphabetic or numeric characters for the search pattern. The examples below uses square brackets along with the asterisk wildcard character. The first example defines a range and will list all files and directories that start with the lower case letters b through f with anything after that. The second example specifies that the first character must be either the letter a orf and anything can be after that. $ ls [b-p] dante diri dir3 filel file3 fruit practice dante i dir2 dir4 file2 file4 fruit2 $ ls [af]* filel file2 file3 file4 fruit fruit2 a. Enter the command to list files and directories in your user 2 directory that start with the letters through p with anything in the remaining positions. What command did you use? Enter the command to list files and directories in your user2 directory that start with any characters but have the numbers 1 through 3 in the last character. What command did you use? C. Enter the command to list files and directories in your user2 directory that start with either dorp and have any characters in the remaining positions What command did you use? Step 16. Use Is command alongside wildcard metacharacters a. At the command prompt, type is file and press Enter. What is listed? b. At the command prompt, type is file? and press Enter. What is listed? c. At the command prompt, type is file?? and press Enter. What is listed? d. At the command prompt, type is file [13] and press Enter. What is listed? e. At the command prompt, type is file[113and press Enter. What is listed? At the command prompt, type Is file[1-3] and press Enter. What is listed? g. At the command prompt, type is file/!1-2) and press Enter. What is listed? Step 17. Use the BASH Shell Metacharacters Another import feature of the shell includes shell metacharacters (",) which are keyboard characters that have special meaning. The shell metacharacters are shown in the following table: Metacharacter(s) - >> Description Shell variable Special home directory variable Background command execution Command termination Input/output redirection Command piping Shell wildcards Metacharacter quotes Command substitution Command grouping *?0 00 a. At the prompt type echo This is OK. What will it display? b. At the command prompt, type echo Don't do this and press Enter. Press the Ctrl and c keys together to cancel your command and return to a shell prompt. Which character needs to be protected in this above command? d. At the command prompt, type echo Don't do this and press Enter. What is displayed on the terminal screen? e. At the command prompt, type echo SSHELL and press Enter to view the expansion of a variable using a shell metacharacter. What is displayed on the terminal screen? Next, type echo $TEST and press Enter to find out what happens when a variable that does not exist is used in a command. What is displayed? 9. At the command prompt, type echo $0 (Hine: number zero not letter O) and press Enter to view the expansion of a variable using a shell metacharacter What is the result? h. At the command prompt, type echo You have $4.50 and press Enter. What is displayed? 1. Which character needs to be protected in the previous command? At the command prompt, type echo 'You have $4.50 and press Enter What is displayed? k. Did the single quotation marks protect this metacharacter from shell interpretation? 1. At the command prompt, type echo "You have $4.50" and press Enter. What is displayed? m. Did the double quotation marks protect this metacharacter from shell interpretation? n. At the command prompt, type echo You have 1$4.50 and press Enter. What is displayed? Did the backslash protect this metacharacter from shell interpretation? At the command prompt, type echo My name is 'whoami' (note: back quote' here that is the one key above the Tab key) and press Enter. What is displayed? What function do back quotes (") perform here? At the command prompt, type echo There are $(who wc -1) users on the system and press Enter. (note: (pipe) is one key above the Enter key) What is displayed? What function do $(commands) perform? 4. At the command prompt, type echo dir1/coffees*, what is the result? r. At the command prompt, type echo dirt/coffeesl", what is the result? a. Enter the command to change to your user2 directory by either relative or absolute pathname from your home directory. What command did you use? b. Enter this command to verify the directory you are in again. c. What was the response? d. Enter the following command: $ ls dirl e. What is it displayed? Step 6. Use the Is Command with Arguments The la command will list any subdirectories and files that are in the current working directory. You do NOT need to change the location to list the files and subdirectories. Arguments for the ls command can be directory name(s) and file name(s) (by using either relative or absolute pathname). For example, use the absolute pathname to list all files or directories of user2 under the user's home directory $ ls /home/csc156/yourusername /user2 Or, we can use the relative pathname to list all files and subdirectories of the user2 directory if the user at his/her home directory. $ ls user2 same as $ ls /user2 a Enter the command to change back your home directory. What command did you use? b. Enter the command to display (or list) the contents of the dir2 directory using a relative pathname from your home directory What command did you use? What was the response? c. Enter the command to list all the files in the /etc directory (a standard LINUX directory under the root "") using an absolute pathname. What command did you use? d. Enter the command to list the files in the planets directory from the diagram using an absolute path name? What command did you use? e. Enter the command to list only the dante file from your home directory (to see if it exists and not see all other files and directories). What command did you use? (Using either absolute or relative pathname) 1. Enter the command to list the contents of coffees directory from your home directory What command do you enter at the command prompt by using the relative pathname? Step 7. Use the Is Command to see Hidden Files with a option File names that begin with a dot (.) are called hidden files. Hidden files are frequently used to customize a user's work environment (ex: profile, .dtprofile .kshrc, .cshrc etc.). They are not shown by default because they are infrequently edited. The current directory link (.) and parent directory link (..) are also hidden and will not be displayed either since they begin with a dot. Using the Is command with the -a (all) option will list all files in a directory, including hidden (.) files. Note that the-a option is lower case. Note: You should be in your home directory to answer the following questions. If not, change to your home directory first then answer the following questions. a. Enter the command to verify where you are. What command did you use? b. What is the result? c. Enter the basic ls command without the any options. Do you to see any hidden files (those that begin with a dot)? d. Enter the command that will allow you to see ALL files in your home directory? e. How many hidden files are there? f. Enter the following to create a new empty file called hidden file using the touch command (be sure to make the first character a dot). S touch hiddenfile g. Enter the ls -a command again. Is hiddenfile listed? Step 8. Use the Is Command to See File Types with-F option When using the ls command by itself, you can obtain a listing of directory contents but cannot tell which files are and which directories are. By using the ls command with the - F (File type) you can display a listing with a symbol to tell what the type of the file is -E.--classify append indicator (one of ZI@) to entries The symbol (if present) is found at the end of the file or directory name. Note that the-F option is an upper case F. There are four LINUX/UNIX file types: Directory, Executable, ASCII text file, and Symbolic link. Directory - A forward slash (l) after the name indicates this is a directory (or subdirectory). A directory is considered a type of file with LINUX/UNIX. ASCII Text File - If there is no symbol after the name this indicates a plain ASCII text file with no formatting characters in it. (ASCII is the American Standard Code for Information Interchange). An ASCII text file is similar to a DOS text file. Executable-An asterisk (*) after the name indicates that this is a command, an application or a script file, which can be run or executed. Symbolic Link -An at sign (@) after the name indicates a symbolic link which is a way of giving a file an alternate name. Symbolic links are covered later in this course. a. Enter the command that will allow you to see the file names from your home directory and their TYPE. The /usr/bin directory (a standard LINUX directory under the root) contains many LINUX/UNIX executable commands, some of which you have already used. Enter the command to see the fies and types in the /usr/bin directory. What command did you use? d. What types of files are present? e. The /etc directory (a standard LINUX directory under the root) contains many different type of LINUX/UNIX system files. Enter the command to see the files and types in the /etc directory. What command did you use? Which different kinds of file types do you see? f 9. Enter the command to find the file type of the auto.net file under /etc directory from your current home directory? Step 9. Use the Is Command to Displaying a Long Listing format and more options The previous versions of the is command displayed the names of directories and files in a wide format(across the screen). The ls command can be used with the - (long) option to see more detailed information on each file or directory. The ls -l option will also distinguish between files and directories. Note that the option is a lower case letter L. For example, Enter the command: $ ls -1 Shown below is an example of a long listing for a file (dante) and a directory (dir) from your user2 directory. The listing is interpreted as follows: -IW-r--I-- 1 user2 staff 320 Dec 7 11:43 dante drwxr-xr-x 5 user2 staff 512 Dec 4 13:43 dirl The first position of the display indicates whether this is a file or a directory. The lower case letter d indicates a directory: the dash (-) indicates a file. The next group of characters (r.wx and dashes) are the permissions for the file or directory. Next is the number of links (1,5), followed by the file owner (user2), the file or directory access group (staff), file size (320, 512), the date and time created (or modified) and then the name of the file or directory. Links, owner and group are covered later in the course. e to your user2 directory form your home directory. What command did you use by using the relative pathname? b. From your user2 directory, enter the basic ls diri/coffees command without any options. What information was displayed on the screen? C. Enter the command that will allow you to see a long listing for the file names at your dirt/coffees directory. What command did you enter? d. Which file is over 300 bytes in size? e. Who is the owner of these files? Note: Using -t (time) option will list files with the most recently modified at the top of the list. To get a detailed (long) listing of files sorted by time (most recent at the top) use the $ls -lt version of the command. f. Enter the ls -lt command. What is the most recently created or modified file? Using -S option (uppercase S) to sort files by file sizes g. Enter the command to sort by file sizes as well as display it as a long list What command do you use? h. What is the filename for the biggest file size? Using -s option (lowercase s) to print the allocated size of each file, in blocks a. Enter the command to print the allocated size of each files under the dir1 subdirectory. What command do you use? b. How many blocks for the coffees subdirectory? Using -r option to sort files by the reverse order. C. Enter is command, do you see all files list by the alphabetical order? d. Enter the command to list long listing as well as sort the files by the reverse order, what command do you use? e. What is the first filename from the list? Step 10. Use the ls Commandwith-i option to List inode (index) number An inode is an entry in inode table, containing information (the metadata) about a regular file and directory. An inode is a data structure on a traditional Unic-style file system such as ext3 or ext4. Use $ ls - lower case i option to display the inode (index) number for each file and directory under the current location. a. Type pwd command, what is the result? b. If you are not at the user2 directory, change to the user2 directory. If yes, continue the following steps. c. What command do you use to find out the inode number of the practice directory? d. What is the inode number of the practice directory? e. Use the command to find out the inode number for fruit2 file from the user2 directory, what command do you use? f. What is the inode number for the fruit2 file? 9. What command do you use to find out the inode number of the fruit directory which is under diri directory? h. What is the inode number for the fruit subdirectory? Step 11. Use the ls Command to List Individual Directories and Recursively Is command with option: d. --directory list directory entries instead of contents, and do not dereference symbolic link Use ls -ld to display detailed information about a directory, but not its contents. This is useful when you want to see the properties of a directory and not the information about its contents. Use ls -R (recursive) play the contents of a directory and all of its subdirectories Note that the -R option is an upper case R. Recursive means to do again and again. This option is useful if you want to see all directories, subdirectories and their contents for a particular part of the directory tree. If this is done at a high level in the directory structure the output can be substantial. a. Change back to your home directory. What command did you use? b. From your home directory, what command do you use to provide a long listing for the contents of dir2 directory? From your home directory, enter the command that will provide a long listing of just the information for the dir2 directory itself not the contents. (Either absolute or relative) d. From your home directory, enter the command that will provide a long listing for just the information on the planets directory itself by using a relative path name. e. From your home directory, enter the command that will provide a recursive listing for the dir2 directory. a. From your home directory, enter the command that will provide a recursive listing for the coffees directory Step 12. Determine File Type with the file Command There are many types of files found on a LINUX/UNIX system. The file type can be determined by using the file command. This information can be important when a user is attempting to open or read a file. Determining the file type can help a user decide which program or command to use to open the file. The output from this command will most often be one of the following: Text, Executable or Data $ file my file My_file: ASCII text The file in the preceding example is a text file. Text Files - Examples include ASCII or English text, commands text, and executable shell scripts. This type of file can be read using the cat or more commands and can be edited using vi or another text editor a. Change to the user2 directory, what command do you use? b. Use the file command to determine the file type for the dante file in your user 2 directory. What command do you use? c. What kind of file is it? Executable or Binary Files - Examples include 32-bit executable and extensible linking format (ELF) code files and other dynamically linked executables. This file type indicates that the file is a command or program, Use the file command to determine the file type for the cal file under the /usr/bin directory. (Hint: the standard directory /usr/bin directly under the root) What command do you use? a. US b. What kind of file is it? Data Files - Data files are created by applications running on the system. In some cases the type of file is indicated, for example, FrameMaker (Desktop Publishing software) document. a. Use the file command to determine the file type for the beans file is in the dir/coffees subdirectory. What command do you use? b. What kind of file is it? a. Use this command to determine the file type of auto.net file under letc directory, what command do you use? b. What is the result? c. What command do you use to find out what the dante file is from you home directory by using the relative pathname? d. What is the result? Step 13. Use the ls Command With the Asterisk (*) Metacharacter The asterisk (*) is a substitution symbol that represents zero or more characters, except the leading dot on a hidden file. The asterisk is often referred to as a wildcard character. If there were a large number of files in a directory and you only wanted to see a listing of project files that started with p1 you could use the asterisk to limit the numbers of files listed. As an example, enter the command as: $ls p* This command would list all files and directories starting with p and any number of characters after that. The asterisk can be placed anywhere (beginning, middle or end) of the string being tested and can appear multiple times. If you enter $ls d you will see only those files beginning with the letter d and the contents of any subdirectories that start with the letter d. a. What command will you change to user2 directory? b. Enter the command to list files and directories from your user2 directory that start with the letter f. What command did you use? c. What was listed? d. Enter the command to list files and directories in vour user2 directory that start with the letter d. What command did you use? e. Enter the command to list files and directories in your user2 directory that end with the number 1. What command did you use? 1. Enter the command to list files and directories in your user2 directory that have the characters 'ru' anywhere in the file name. (Hint: maybe it starts with ru or in the middle or at the end of filenames.) What command did you use? g. What was listed? What command did you use? i. What was listed? 1. What command did you use to list files and directories in the dir2 directory that end with the letters using a relative path name? k. What was listed? Step 14. Use the ls Command With the Question Mark The question mark (2) is a substitution character that matches any single character, except for the leading dot on a hidden file. The question mark is also referred to as a wildcard character The example below shows the use of the Is command using the question mark in the fourth position. Enter the command: $ ls dir? This indicates that the file or directory name must start with dir but any character can be in the fourth position and the file name cannot be more than four characters long. a. Enter the command to list files and directories in your user2 directory that start with the letters file in the first four positions with anything in the fifth position but are not longer than five characters. What command did you use? b. What was listed? Enter the command to list files and directories in your user2 directory that start with the letter f in the first position with anything in the second and third positions and the characters e3 in the last two positions that are not longer than five characters. What command did you use? d. What was listed? Step 15. Use the ls Command With Square Brackets Square brackets (0) can be used to match a set or range of characters for a single character position in the file or directory. The characters inside the brackets do not generally need to be in any order, for example, [abc) is the same as (cab]. However, if you are looking for a range of characters, they must be in proper order (for example, [a-z] or [3-9]). If you want to search for all alphabetic characters, whether lowercase or uppercase, use (A-2) for the can use alphabetic or numeric characters for the search pattern. The examples below uses square brackets along with the asterisk wildcard character. The first example defines a range and will list all files and directories that start with the lower case letters b through f with anything after that. The second example specifies that the first character must be either the letter a orf and anything can be after that. $ ls [b-p] dante diri dir3 filel file3 fruit practice dante i dir2 dir4 file2 file4 fruit2 $ ls [af]* filel file2 file3 file4 fruit fruit2 a. Enter the command to list files and directories in your user 2 directory that start with the letters through p with anything in the remaining positions. What command did you use? Enter the command to list files and directories in your user2 directory that start with any characters but have the numbers 1 through 3 in the last character. What command did you use? C. Enter the command to list files and directories in your user2 directory that start with either dorp and have any characters in the remaining positions What command did you use? Step 16. Use Is command alongside wildcard metacharacters a. At the command prompt, type is file and press Enter. What is listed? b. At the command prompt, type is file? and press Enter. What is listed? c. At the command prompt, type is file?? and press Enter. What is listed? d. At the command prompt, type is file [13] and press Enter. What is listed? e. At the command prompt, type is file[113and press Enter. What is listed? At the command prompt, type Is file[1-3] and press Enter. What is listed? g. At the command prompt, type is file/!1-2) and press Enter. What is listed? Step 17. Use the BASH Shell Metacharacters Another import feature of the shell includes shell metacharacters (",) which are keyboard characters that have special meaning. The shell metacharacters are shown in the following table: Metacharacter(s) - >> Description Shell variable Special home directory variable Background command execution Command termination Input/output redirection Command piping Shell wildcards Metacharacter quotes Command substitution Command grouping *?0 00 a. At the prompt type echo This is OK. What will it display? b. At the command prompt, type echo Don't do this and press Enter. Press the Ctrl and c keys together to cancel your command and return to a shell prompt. Which character needs to be protected in this above command? d. At the command prompt, type echo Don't do this and press Enter. What is displayed on the terminal screen? e. At the command prompt, type echo SSHELL and press Enter to view the expansion of a variable using a shell metacharacter. What is displayed on the terminal screen? Next, type echo $TEST and press Enter to find out what happens when a variable that does not exist is used in a command. What is displayed? 9. At the command prompt, type echo $0 (Hine: number zero not letter O) and press Enter to view the expansion of a variable using a shell metacharacter What is the result? h. At the command prompt, type echo You have $4.50 and press Enter. What is displayed? 1. Which character needs to be protected in the previous command? At the command prompt, type echo 'You have $4.50 and press Enter What is displayed? k. Did the single quotation marks protect this metacharacter from shell interpretation? 1. At the command prompt, type echo "You have $4.50" and press Enter. What is displayed? m. Did the double quotation marks protect this metacharacter from shell interpretation? n. At the command prompt, type echo You have 1$4.50 and press Enter. What is displayed? Did the backslash protect this metacharacter from shell interpretation? At the command prompt, type echo My name is 'whoami' (note: back quote' here that is the one key above the Tab key) and press Enter. What is displayed? What function do back quotes (") perform here? At the command prompt, type echo There are $(who wc -1) users on the system and press Enter. (note: (pipe) is one key above the Enter key) What is displayed? What function do $(commands) perform? 4. At the command prompt, type echo dir1/coffees*, what is the result? r. At the command prompt, type echo dirt/coffeesl", what is the result

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Heikki Topi, Jeffrey A Hoffer, Ramesh Venkataraman

13th Edition

0134773659, 978-0134773650

More Books

Students also viewed these Databases questions

Question

What is the message frequency?

Answered: 1 week ago

Question

What is the schedule for this project?

Answered: 1 week ago

Question

Who is responsible for this project?

Answered: 1 week ago