Leson 3 part 2 Flashcards
How do you view directory contents page by page using ls?
Use ls -l | more to paginate the output. Note that more is not supported in GitBash for Windows.
What does the ls command do?
It lists directory contents, showing files and directories.
How do you change the current directory in UNIX/Linux?
Use the cd command followed by the directory path, e.g., cd /var/log.
What command displays the current working directory?
pwd
What additional details does ls -l provide?
It shows permissions, the group associated with the file, file size, timestamp, and the file name.
How do you create a new directory using UNIX/Linux commands?
Use mkdir [directory name], e.g., mkdir myproject.
What is the purpose of the cat command?
It can create, view, and concatenate files. For example, cat > newfilename creates a new file and allows input.
How can you use cat to copy the contents of one file to another?
Use cat sourcefilename > destinationfilename.
What does the touch command do?
It creates an empty file for editing later, e.g., touch filename.
How do you create a file with specific content using echo?
Use echo “Some line” > file1.txt to create a file with the text “Some line”.
What is the purpose of the grep command?
It searches for a string in files and directories. For example, grep Aaron filename searches for “Aaron” in the file “filename”.
What does the cp command do?
It copies files or directories. For example, cp second.txt third.txt copies second.txt to third.txt.
How does the diff command work?
It compares two files line by line and shows the differences. Use diff file1.txt file2.txt.
What does the mv command do?
It moves or renames files and directories. Examples include mv file1 directory1 and mv file1 file2 for renaming.
How do you prevent mv from overwriting existing files?
Use mv -i file1 directory1 to prompt before overwriting or mv -n file1 directory1 to not overwrite existing files.
How can you copy directories and their contents recursively with cp?
Use cp -r directory1 directory2.
What is the purpose of the rm command?
It deletes files or directories. For example, rm file1 deletes file1, and rm -r directory1 deletes directory1 and its contents.
How can you use rm to prompt before deleting a file?
Use rm -i file1 to interactively prompt before deletion.
Why is the command line still relevant despite the availability of GUIs?
It is efficient for repetitive tasks, faster in execution, and useful when GUIs are not available (e.g., on servers).
What are some capabilities of a Version Control System?
Maintain multiple versions, go back to previous versions, parallel development, audit changes, synchronize code, copy/merge/undo changes, find differences between versions, backup, review history, and support for both small and large projects.
What advantage does the command line have over GUIs in terms of scripting?
Command-line programs can be scripted for batch processing, making repetitive tasks easier to automate compared to GUIs.
What is the purpose of version control (VCS)?
VCS manages source code changes, allowing you to maintain multiple versions of code, go back to previous versions, work in parallel, and audit changes.
What are the two types of Version Control Systems?
Centralized Version Control System (CVCS) and Distributed Version Control System (DVCS).
How does version control help in a team environment with multiple developers?
It avoids issues like incomplete backups, lost modules, lack of change traceability, and allows parallel development and global collaboration.