click below
click below
Normal Size Small Size show me how
Linux+ SG chp 3
CompTIA Linux+ 005 Chp 3 Managing Files Dirm and text T/D
| Term | Definition |
|---|---|
| Gnu / Linux Shell | The shell is a special inter- active utility that allows users to run programs, manage files, handle processes, and so on. The shell provides a command-line interface, which furnishes a prompt at which you can enter text-based commands. These commands are actually programs. |
| Virtual directory | is the Files on a Linux system are stored within a single directory structure. It contains files from all the computer’s storage devices and merges them into a single directory structure |
| Root directory | The single base directory of the virtual directory |
| metadata | is information that describes and provides additional details about data. |
| syntax | Command [option (switch)]...[file (argument)] is the set of rules that define how the command should be written. The basic syntax of a Linux command is: command [options] [arguments] The command is the name of the command that you want to execute. The options are the optional arguments that you can pass to the command. |
| Arguments | Can be defined as input given to a command line to process that input with the help of given command. Argument can be in the form of a file or directory. Arguments are entered in the terminal or console after entering command. They can be set as a path. We can also write more than one argument together, they will be processed in the order they are writtten. |
| man pages | help to find info. about a command |
| ls | NAME ls - list directory contents SYNOPSIS ls [OPTION]... [FILE]... DESCRIPTION List information about the FILEs (the current directory by default). Sort entries alphabetically if none of -cftuvSUX nor --sort is specified. -a --all (Display all -d --directory list directories themselves -F --Classify append indicator to entries -i --inode print the index number of each file -l use a long listing format -R list subdirectories recursively |
| pwd | NAME pwd - print name of current/working directory SYNOPSIS pwd [OPTION]... DESCRIPTION Print the full filename of the current working directory. |
| alias | at the Linux command line is simply a short command that represents another, typically complicated, command. You can view all the current aliases your process has by typing alias at the command line. |
| tree | NAME tree - list contents of directories in a tree-like format. DESCRIPTION Tree is a recursive directory listing program that produces a depth indented listing of files, which is colorized ala dircolors if the LS_COLORS environment variable is set and output is to tty. With no arguments, tree lists the files in the current directory. When directory arguments are given, tree lists all the files and/or directories found in the given directories each in turn. |
| touch | command will allow you to create empty files on the fly. This command’s pri- mary purpose in life is to update a file’s timestamps—access and modification. NAME touch - change file timestamps SYNOPSIS touch [OPTION]... FILE... DESCRIPTION Update the access and modification times of each FILE to the current time. |
| folders | Directories are sometimes called folders |
| mkdir | NAME mkdir - make directories SYNOPSIS mkdir [OPTION]... DIRECTORY... DESCRIPTION Create the DIRECTORY(ies), if they do not already exist. -p no error if existing, make parent directories as needed (overwrite) -v verify |
| cp | Copy NAME cp - copy files and directories SYNOPSIS cp [OPTION]... [-T] SOURCE DEST cp [OPTION]... SOURCE... DIRECTORY cp [OPTION]... -t DIRECTORY SOURCE... DESCRIPTION Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY. -a --archive -f --force -i --interactive (ask) -n --no-clobber -R -r --recursive -u --update -v --verbose |
| mv | Move or rename NAME mv - move (rename) files SYNOPSIS mv [OPTION]... [-T] SOURCE DEST mv [OPTION]... SOURCE... DIRECTORY mv [OPTION]... -t DIRECTORY SOURCE... DESCRIPTION Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY. -i --interactive |
| rsync | command- syntax is similar to the mv command’s syntax. It is as follows: rsync [OPTION]... SOURCE DEST -a --archive -D retain device and special files -g --group -h --human-readable -l --links -o --owner -p --perms n/a --progress -r --recursive n/a --stats -t --times -v --verbose |
| scp | Secure copy NAME scp — secure copy (remote file copy program) DESCRIPTION scp copies files between hosts on a network. It uses ssh(1) for data transfer, and uses the same authentication and provides the same security as ssh(1). scp will ask for passwords or ssphrases if they are needed for authentication. |
| speedup rating | in its output. This rating is related to conducting synchronized backups. If you are using the rsync command to conduct periodic backups of a particular directory to another directory location, the speedup rating lets you know how many files did not need to be copied because they had not been modified and were already backed up. |
| rm | NAME rm - remove files or directories SYNOPSIS rm [OPTION]... [FILE]... DESCRIPTION This manual page documents the GNU version of rm. rm removes each specified file. By default, it does not remove directories. |
| Symbolic link | Soft Link provides a pointer to a file that may reside on another filesystem. The two files do not share inode numbers because they do not point to the same data. |
| Hard Link | is a file or directory that has one index (inode) number but at least two differ- ent filenames. Having a single inode number means that it is a single data file on the filesys- tem. Having two or more names means the file can be accessed in multiple ways. file has two names but is physically one file |
| ln | To create a hard link the original file must exist prior to issuing the ln command. The linked file must not exist. It is created when the command is issued |
| ln -s | Create a soft link |
| dead link | is when a soft link points to a file that was deleted or moved. The soft-linked file itself is not removed or updated. If a file with the original file’s name and location is created, the soft link now points to that new file |
| cat | concatenate Read file cat [OPTION]... [FILE]... |
| pr | Read file printing pr [OPTION]... [FILE]... |
| grep | For reading can help you find a file line (or lines) that contain certain text strings. grep [OPTIONS] PATTERN [FILE...] grep command to find a file $ sudo grep -d skip hosts: /etc/* /etc/nsswitch.conf:hosts: files [...] $ The grep utility displays the configuration filename, fol- lowed by a colon (:) and the file’s line where the setting is located. If you are not sure where in the /etc/ directory tree the configuration file is placed, you can tack on the -R (or -r, or ––recursive) |
| head | head [OPTION]... [FILE]... |
| tail | tail [OPTION]... [FILE]... Watching a log file with the tail command $ sudo tail -f /var/log/auth.log |
| more | utility allows you to view one text page at a time and move through the text at your own pace |
| less | More flexable than less. utility allows you to view one text page at a time and move through the text at your own pace |
| file | can provide basic information about the file type of a specified file $ file mytest mytest: Bourne-Again shell script, ASCII text executable |
| stat | If you’d like to see information about when a file was created, modified, or last accessed, $ stat mytest File: mytest Size: 1016 Blocks: 8 IO Block: 4096 regular file Device: 805h/2053d Inode: 1054186 Links: 1 Access: (0764/-rwxrw-r--) Uid: ( 1000/ rich) Gid: ( 1000/ rich) Access: 2021-11-06 09:18:23.856584608 -0500 Modify: 2021-10-31 11:25:22.048406517 -0500 Change: 2021-10-31 11:25:22.048406517 -0500 Birth: - |
| diff | diff [OPTION]... FILES |
| Which | command shows you the full path name of a shell command passed as an argument. |
| echo $PATH | $ echo $PATH /usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin: /home/Christine/.local/bin:/home/Christine/bin $ the PATH variable sets the directories Linux will search for the program binary. It is also used by other commands, such as the which utility. Note that directory names are separated by a colon (:) in the PATH list. |
| Whereis | This utility allows you to not only locate any command’s program binaries but also locate source code files as well as any man pages. |
| locate | This utility searches a database, mlocate.db, which is located in the /var/lib/mlocate/ directory, to determine if a particular file exists on the local system. The basic syntax for the locate command is as follows: locate [OPTION]... PATTERN... |
| find | find [PATH...] [OPTION] [EXPRESSION] You can use a single period (.) to designate your present working directory as the starting point directory. $ find . -name "*.txt" ./Project47.txt ./Answers/Project42.txt |
| 1. You are looking at a directory that you have not viewed in a long time and need to determine which files are actually directories. Which command is the best one to use? A. mkdir -v B. ls C. ls -F D. ls -i E. ll | C |
| 2. You are using the ls command to look at a directory file’s metadata but keep seeing meta- data for the files within it instead. What command option will rectify this situation? A. -a B. -d C. -F D. -l E. -R | B |
| 3. You have just created an empty directory called MyDir. Which command did you most likely use? A. mkdir -v MyDir B. touch MyDir C. cp -R TheDir MyDir D. mv -r TheDir MyDir E. rmdir MyDir | A |
| 4. You have a file that is over 10 GB in size, and it needs to be backed up to a locally attached drive. What is the best utility to use in this situation? A. readlink -f B. mv C. cp D. scp E. rsync | E |
| 5. A long-time server administrator has left the company, and now you are in charge of her system. Her old user account directory tree, /home/Zoe/, has been backed up. Which command is the best one to use to quickly remove her files and still indicate that you are removing the correct directory, but without forcing you to confirm every file deletion? A. cp -R /home/Zoe/ /dev/null/ B. mv -R /home/zoe/ /dev/null/ C. rm -Rf /home/Zoe/ D. rm -ri /home/Zoe/ E. rm -rI /home/Zoe | E |
| 6. There is a large directory structure that needs to be renamed. What mv command options should you consider employing? (Choose all that apply.) A. -f B. -i C. -n D. -r E. -v | B, C, E |
| 7. should you use a hard or a symbolic link for a 5GB data file mission-critical data, & is accessed via the cmd line by 3 others A. C a hard link so that the file can reside on a diff filesystem for data protection. B. C 3 hard links & provide the links to the 3 others 4 data protc C. C 3 symbolic links and protect the links from the three other people for data protection. D. C a symbolic link so that the file can reside on a diff filesystem. E. C a symbolic link so that the links can share an inode # | B |
| 8. A short text-based control file is no longer working properly with the program that reads it. You suspect the file was accidentally corrupted by a control code update you performed recently, even though the file’s control codes are all correct. Which command should you use next on the file in your problem investigation? A. cat -v B. cat -z C. cat -n D. cat -s E. cat -E | A |
| 9. You have two short text files that have maximum record lengths of 15 characters. You want to review these files side by side. Which of the following commands would be the best to use? A. pr -m B. pr -tl 20 C. cat D. pr -mtl 20 E. pr -ml 20 | D |
| 10. You have a lengthy file named FileA.txt. What will the head -15 FileA.txt command do? A. Display all but the last 15 lines of the file. B. Display all but the first 15 lines of the file. C. Display the first 15 lines of the file. D. Display the last 15 lines of the file. E. Generate an error message. | C |
| 11. issued the command grep Hal on a text file you generated using information from a failed login attempts file. It returns nothing, you performed a test case by failing to log into the Hal account. Which is the best choice? A. the tail command to peruse the text file. B. the cat command to view the text file. C. Delete the text file and regenerate it using information from the failed login D. the grep -d skip Hal command on the text file. E. the grep -i Hal command on the text file. | E |
| 12. You are trying to peruse a rather large text file. A coworker suggests you use a pager. Which of the following best describes what your coworker is recommending? A. Use a utility that allows you to view the first few lines of the file. B. Use a utility that allows you to view one text page at time. C. Use a utility that allows you to search through the file. D. Use a utility that allows you to filter out text in the file. E. Use a utility that allows you to view the last few lines of the file. | B |
| 13. Which of the following does not describe the less utility? A. It does not read the entire file prior to displaying the file’s first page. B. You can use the up and down arrow keys to move through the file. C. You press the spacebar to move forward a page. D. You can use the Esc+V key combination to move backward a page. E. You can press the X key to exit from the utility. | E |
| 14. Which diff option is the best option to allow you to quickly determine if two text files are different from one another? A. -e B. -q C. -s D. -W E. -y | B |
| 15. You are working on a Linux server at the command line, and you try to issue a diff command and receive a response stating that the command was not found. What is the next best step to take in order to start the troubleshooting process? A. Hit your up arrow key and press Enter. B. Log out, log back in, and retry the command. C. Enter the which diff command. D. Enter the whereis diff command. E. Reboot the server and retry the command. | C |
| 16. find a file on your Linux server whose name is conf. Employing the locate conf command for your search shows many directories that contain the letters conf. What is the best description for why this is happening? A. The locate utility searches for only for directory names. B. You did not employ the -d skip switch. C. It is most likely because the locate database is corrupted. D. You did not employ the appropriate regular expression. E. It is due to file globbing on the pattern name. | E |
| 17. You downloaded a large important file, fortytwo.db, from your company’s local website to your Linux server but got interrupted by an emergency. Now you cannot remember where you stored the file. What is the best first step to fixing this problem? A. Issue the sudo updatedb command. B. Issue the locate -b fortytwo.db command. C. Issue the locate -b 'fortytwo.db' command. D. Download the file from the company’s local website again. E. Issue the locate fortytwo.db command. | A |
| 18. You want to search for a particular file, main.conf, using the find utility. This file most likely is located somewhere in the /etc/ directory tree. Which of the following commands is the best one to use in this situation? A. find -r /etc -name main.conf B. find / -name main.conf C. find /etc -maxdepth -name main.conf D. find /etc -name main.conf E. find main.conf /etc | D |
| 19. Yesterday a coworker, Michael, was fired for nefarious behavior. His account and home directory were immediately deleted. You need to audit the server to see if he left any files out in the virtual directory system. Which of the following commands is the best one to use in this situation? A. find / -name Michael B. :find / -user Michael C. find / -mmin 1440 D. find ~ -user Michael E. find / -nouser | E |
| 20. You need to figure out what configuration file(s) hold a hostname directive. Which of the following commands is the best one to use? A. which B. whereis C. grep D. locate E. find | C |
| From root ls -a | [cloud_user@9f3c0597392c /]$ ls -a . .. bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var -a, --all do not ignore entries starting with . In Linux, hidden files start with . (dot) symbol and they are not visible in the regular directory. The (ls -a) command will enlist the whole list of the current directory including the hidden files. |
| ls -l | It will show the list in a long list format. [cloud_user@9f3c0597392c Learning]$ ls -l total 0 drwxrwxr-x. 7 cloud_user cloud_user 69 Dec 6 16:30 Cloud drwxrwxr-x. 2 cloud_user cloud_user 6 Dec 6 20:19 CrashTest drwxrwxr-x. 4 cloud_user cloud_user 45 Dec 6 16:31 Linux |
| ls -i | |
| ls -F | |
| ls -R | |
| ls --author | |
| ls -b or --escape | |
| ls -B | |
| ls -c | |
| ls -d |