Outcome 2 Study Questions Flashcards

(48 cards)

1
Q

What command would you use to determine the absolute path of the current directory you are in?

A

pwd – Prints the absolute path of the current directory.

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

List the command to display all files and directories inside /bin in long format.

A

ls -l /bin – Lists all files in /bin with details.

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

How would you find out where the ls command is located on the system?

A

which ls or whereis ls – Shows the location of the ls command.

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

Write the command to display the kernel version of the current Linux system.

A

uname -r – Displays the Linux kernel version.

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

What does the following command do?

ls /dev | grep tty

A

ls /dev | grep tty – Lists all device files containing “tty” in their name.

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

Which command allows you to view a paginated list of files within the /etc directory?

A

ls -l /etc | less

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

Issue the command to create the following directory structure in one line:

/home/user/labs/test1/test2/test3

A

mkdir -p /home/user/labs/test1/test2/test3

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

How do you create an empty file called testfile.txt in your current directory?

A

touch testfile.txt

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

Write the command to copy testfile.txt from your home directory to /var/tmp/.

A

cp ~/testfile.txt /var/tmp/

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

How would you rename testfile.txt to logfile.log?

A

mv testfile.txt logfile.log

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

What command would you use to delete a non-empty directory called old_projects?

A

rm -rf old_projects

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

Write the command to move logfile.log to a directory called logs.

A

mv logfile.log logs/

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

What are the default file permissions for a newly created file in Linux?

A

rw-r–r– (644)

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

Issue the command to modify the permissions of script.sh to be executable only by the owner.

A

chmod 700 script.sh

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

Write the octal equivalent of rwxr-x— file permission.

A

750

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

Change ownership of project.doc to the user john and group developers.

A

chown john:developers project.doc

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

How do you recursively change the permissions of all files inside a directory called docs to 644?

A

chmod -R 644 docs/

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

What command would you use to view detailed permission information of a file named config.conf?

A

ls -l config.conf

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

Which command allows you to view the last 10 lines of a file called error.log in real-time?

A

tail -f error.log

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

Write the command to search for all occurrences of the word “error” inside the file system.log.

A

grep “error” system.log

21
Q

How would you display only the first 5 lines of a file called data.csv?

A

head -5 data.csv

22
Q

Find all .txt files within /var/logs/ that contain the word “critical”.

A

grep -rl “critical” /var/logs/*.txt

23
Q

Using grep, write the command to search for lines that do NOT contain the word “debug” in logfile.txt.

A

grep -v “debug” logfile.txt

24
Q

What does the following command do?

ls /etc | grep -E ‘^p’

A

Lists all files and directories in /etc that start with the letter “p”.

25
Write a command that redirects the output of ls -l to a file called directory_list.txt.
ls -l > directory_list.txt
26
Modify the above command to append the output instead of overwriting it.
ls -l >> directory_list.txt
27
How would you display the contents of directory_list.txt while also sending the output to another file called backup_list.txt?
cat directory_list.txt | tee backup_list.txt
28
Which command will count the number of lines in a file called report.txt?
wc -l report.txt
29
How do you remove duplicate lines from a file called names.txt?
sort names.txt | uniq > unique_names.txt
30
Write the command to merge two files (file1.txt and file2.txt) and save the result to combined.txt
cat file1.txt file2.txt > combined.txt
31
What command lists all running processes on the system?
ps -e
32
Which command displays real-time system resource usage (CPU, memory, etc.)?
top or htop
33
Issue the command to find and terminate a process with the name myservice.
pkill myservice
34
What is the difference between kill -9 and kill -15?
kill -9 forcefully terminates a process, while kill -15 allows the process to gracefully shut down.
35
How would you run a command in the background?
command &
36
What command would bring a suspended job back to the foreground?
fg
37
Write the command to create a tar archive of the backup directory.
tar -cf backup.tar backup/
38
Modify the previous command to compress the tar file using gzip.
tar -czf backup.tar.gz backup/ If you already have backup.tar and want to compress it → Use **gzip backup.tar** If you are creating a compressed archive from a directory → Use **tar -czf backup.tar.gz backup/**
39
tar -xzf backup.tar.gz -C /tmp/restore/
If you only want to decompress without extracting → Use **gunzip backup.tar.gz**. If you want to extract everything at once; Use **tar -xzf backup.tar.gz -C /tmp/restore/ **(recommended).
40
What command would you use to view the contents of backup.tar.gz without extracting it?
tar -tf backup.tar.gz
41
How do you extract only a specific file from backup.tar.gz?
tar -xzf backup.tar.gz path/to/file
42
Write a command to display all hidden files in the current directory.
ls -la
43
How do you create a symbolic link to a file named data.db?
ln -s data.db data_link
44
Issue a command that finds all .log files modified in the last 7 days.
find /path/to/search -name "*.log" -mtime -7
45
What does the find command with -maxdepth 1 option do?
Limits the search to only one level below the current directory.
46
How do you schedule a job using cron to run every Monday at 3 AM?
crontab -e and add: 0 3 * * 1 /path/to/script.sh
47
What is the difference between > and >> when redirecting output?
> overwrites a file, while >> appends to a file.
48