Leson 3 part 2 Flashcards

1
Q

How do you view directory contents page by page using ls?

A

Use ls -l | more to paginate the output. Note that more is not supported in GitBash for Windows.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
1
Q

What does the ls command do?

A

It lists directory contents, showing files and directories.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you change the current directory in UNIX/Linux?

A

Use the cd command followed by the directory path, e.g., cd /var/log.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What command displays the current working directory?

A

pwd

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What additional details does ls -l provide?

A

It shows permissions, the group associated with the file, file size, timestamp, and the file name.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you create a new directory using UNIX/Linux commands?

A

Use mkdir [directory name], e.g., mkdir myproject.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the purpose of the cat command?

A

It can create, view, and concatenate files. For example, cat > newfilename creates a new file and allows input.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How can you use cat to copy the contents of one file to another?

A

Use cat sourcefilename > destinationfilename.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does the touch command do?

A

It creates an empty file for editing later, e.g., touch filename.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you create a file with specific content using echo?

A

Use echo “Some line” > file1.txt to create a file with the text “Some line”.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the purpose of the grep command?

A

It searches for a string in files and directories. For example, grep Aaron filename searches for “Aaron” in the file “filename”.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does the cp command do?

A

It copies files or directories. For example, cp second.txt third.txt copies second.txt to third.txt.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How does the diff command work?

A

It compares two files line by line and shows the differences. Use diff file1.txt file2.txt.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does the mv command do?

A

It moves or renames files and directories. Examples include mv file1 directory1 and mv file1 file2 for renaming.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you prevent mv from overwriting existing files?

A

Use mv -i file1 directory1 to prompt before overwriting or mv -n file1 directory1 to not overwrite existing files.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How can you copy directories and their contents recursively with cp?

A

Use cp -r directory1 directory2.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the purpose of the rm command?

A

It deletes files or directories. For example, rm file1 deletes file1, and rm -r directory1 deletes directory1 and its contents.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How can you use rm to prompt before deleting a file?

A

Use rm -i file1 to interactively prompt before deletion.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Why is the command line still relevant despite the availability of GUIs?

A

It is efficient for repetitive tasks, faster in execution, and useful when GUIs are not available (e.g., on servers).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What are some capabilities of a Version Control System?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What advantage does the command line have over GUIs in terms of scripting?

A

Command-line programs can be scripted for batch processing, making repetitive tasks easier to automate compared to GUIs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is the purpose of version control (VCS)?

A

VCS manages source code changes, allowing you to maintain multiple versions of code, go back to previous versions, work in parallel, and audit changes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What are the two types of Version Control Systems?

A

Centralized Version Control System (CVCS) and Distributed Version Control System (DVCS).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

How does version control help in a team environment with multiple developers?

A

It avoids issues like incomplete backups, lost modules, lack of change traceability, and allows parallel development and global collaboration.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

How does Centralized Version Control (CVCS) work?

A

It operates on a client-server relationship with a single central repository accessed by multiple clients.

22
Q

How does Distributed Version Control (DVCS) differ from CVCS?

A

In DVCS, every user has a local copy of the repository in addition to the central server repository.

23
Q

What is Git and why is it popular?

A

Git is a distributed version control system known for its speed and efficiency in managing code changes, with most operations being local.

24
Q

What are the three main states of files in Git?

A

Modified, staged, and committed.

25
Q

What is the working tree in Git?

A

The working tree is the directory where files are edited and managed; it’s a single checkout of one version of the project on your local machine.

26
Q

What is the staging area in Git?

A

The staging area (or index) is where changes are prepared to be committed. It stores information about what will be included in the next commit.

27
Q

What is the Git directory?

A

The Git directory contains metadata and the object database for the project. It is copied when cloning a repository.

28
Q

Describe the basic Git workflow.

A

Modify files in the working directory, stage the changes, and then commit the staged changes to the Git directory.

29
Q

How do you install Git on Linux?

A

Use package managers like dnf for Fedora (sudo dnf install git-all) or apt for Debian-based distributions (sudo apt install git-all).

30
Q

What is Git Bash?

A

Git Bash is a terminal application for Windows that provides a Git command line experience, including the Bash shell, commonly used on Linux and macOS.

31
Q

What is a Git repository?

A

A Git repository tracks and saves the history of all changes made to the files in a Git project. It stores this data in a directory called .git.

31
Q

What is the easiest way to install Git on macOS?

A

Install Xcode Command Line Tools by running git –version in Terminal, which will prompt the installation if needed.

32
Q

What are the benefits of using a Version Control System (VCS)?

A

It saves disk space by avoiding file duplication, provides full history and traceability, allows reverting to previous revisions, prevents code loss, identifies file differences, supports independent code versions, and enables global collaboration.

33
Q

What is the purpose of the .gitignore file?

A

The .gitignore file tells Git which files or folders to ignore in a project. It helps in preventing unnecessary files, like build artifacts or sensitive information, from being tracked by Git.

34
Q

What does the command git clone [url] [directory] do?

A

It clones an existing Git repository from the specified URL into a local directory. The directory name is optional; if not specified, it clones into the current directory.

34
Q

How do you initialize a new Git repository in an existing directory?

A

Use the command git init inside the project’s directory.

35
Q

How can you upload local changes to a remote repository?

A

Use the command git push [remote] [branch] to upload commits from the local branch to the specified remote branch.

36
Q

What is a Git merge commit?

A

A Git merge commit combines the changes from different branches into one unified history and has two parent commits.

37
Q

What is the purpose of the git add command?

A

git add stages changes in the working directory for the next commit.

38
Q

How do you resolve a merge conflict in Git?

A

Edit the conflicting files to resolve conflicts marked by «««<, =======, and&raquo_space;»»>, then use git add and git commit to finalize the merge.

39
Q

What does the git status command show?

A

git status displays the current state of the working directory and staging area, including tracked and untracked files, and changes ready to be committed.

40
Q

How can you prevent a file from being tracked by Git?

A

Add the file path or pattern to the .gitignore file.

41
Q
A
42
Q

What does the command git fetch do?

A

git fetch imports commits from a remote repository to the local repository without merging them into the current branch.

43
Q

How do you create a branch in Git?

A

Use the command git branch [branch-name] to create a new branch.

43
Q

What is the difference between git pull and git fetch?

A

git pull fetches and merges changes from a remote repository into the current branch, while git fetch only retrieves changes without merging.

44
Q

What does the git commit -m “[message]” command do?

A

It commits the staged changes to the repository with the provided commit message.

45
Q

How can you list all the branches in a Git repository?

A

Use the command git branch to list local branches or git branch -a to list both local and remote branches.

46
Q
A
46
Q

How can you switch to a different branch in Git?

A

Use the command git checkout [branch-name] to switch to a different branch.

47
Q
A
48
Q
A
48
Q
A
49
Q
A
50
Q
A
51
Q
A
52
Q
A