linux Flashcards

1
Q

What command displays the current working directory?

A

The command pwd displays the current working directory.

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

How do you list all files, including hidden files, in a directory?

A

The ls -a command lists all files, including hidden ones.

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

How can you view the contents of a file one screen at a time?

A

Use the less or more command to view file contents one screen at a time.

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

What command is used to change file permissions?

A

The chmod command changes file permissions.

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

How do you change ownership of a file in Linux?

A

Use the chown command to change file ownership.

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

How can you check the permissions of a file?

A

The ls -l command displays the file permissions in detail.

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

What is the difference between su and sudo?

A

su switches to another user, often root, requiring that user’s password. sudo runs a command with root privileges using the current user’s password.

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

How do you display the first few lines of a file?

A

The head command displays the first few lines of a file.

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

How do you search for a specific text string in files?

A

Use the grep command to search for a text string in files.

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

What command would you use to display active processes?

A

The ps command displays active processes, or top for an interactive view of running processes.

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

What is the purpose of the kill command?

A

The kill command is used to terminate a process by its PID (Process ID).

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

How can you view system memory usage?

A

Use the free command or top to view system memory usage.

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

What is the difference between hard and soft links?

A

A hard link points directly to the file’s data on disk, while a soft link (symbolic link) is a reference to another file’s path.

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

What command shows the disk usage of a directory and its contents?

A

The du command shows the disk usage of a directory and its contents.

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

How do you display the IP address of the machine?

A

Use the ip addr or ifconfig command to display the IP address.

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

What is the purpose of the /etc/hosts file?

A

The /etc/hosts file maps hostnames to IP addresses for local name resolution.

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

What command is used to download files from the internet?

A

The wget or curl command is used to download files from the internet.

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

What is the cron daemon used for?

A

The cron daemon is used to schedule recurring tasks at specified intervals.

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

How do you display the last 10 lines of a log file?

A

The tail command shows the last 10 lines of a file, or tail -f for real-time updates.

20
Q

How do you check the status of all services on a Linux system?

A

Use systemctl list-units --type=service to check the status of all services.

21
Q

What is virtualization?

A

Virtualization is the process of creating virtual instances of computer resources, such as servers, storage, and networks.

22
Q

What is the difference between a virtual machine and a container?

A

A virtual machine is a full operating system environment running on a hypervisor, while a container shares the host OS kernel and runs in isolated processes.

23
Q

What is a hypervisor?

A

A hypervisor is software that allows multiple virtual machines to run on a single physical host, with each VM isolated from others.

24
Q

How do Type 1 and Type 2 hypervisors differ?

A

Type 1 hypervisors run directly on hardware (bare-metal), while Type 2 hypervisors run on top of an existing operating system.

25
Q

What are some popular hypervisors used in the industry?

A

Popular hypervisors include VMware ESXi, Microsoft Hyper-V, and open-source solutions like KVM and Xen.

26
Q

What are the advantages of using containers over VMs?

A

Containers are lightweight, have lower overhead, and start faster than VMs since they share the host OS kernel.

27
Q

What is Docker, and why is it important in DevOps?

A

Docker is a platform for developing, shipping, and running applications in containers, making it easier to ensure consistency across development, testing, and production environments.

28
Q

How can you create a Docker container?

A

Use the docker run command with an image name to create and start a container, for example, docker run ubuntu.

29
Q

How do you list all running Docker containers?

A

The docker ps command lists all running containers.

30
Q

What is a Docker image?

A

A Docker image is a lightweight, standalone, executable package that includes everything needed to run a piece of software, including code, runtime, libraries, and system tools.

31
Q

What command allows you to access the shell of a running Docker container?

A

The docker exec -it <container_name> /bin/bash command allows you to access the shell of a running container.

32
Q

How can you view resource usage by processes in real-time?

A

The top command shows real-time resource usage, including CPU, memory, and processes.

33
Q

How do you find the process ID (PID) of a specific process?

A

Use the ps aux | grep <process_name> command to find the PID of a process.

34
Q

What is the purpose of SSH?

A

SSH (Secure Shell) is a protocol for securely logging into and managing remote servers.

35
Q

How do you connect to a remote server using SSH?

A

Use the command ssh user@host to connect to a remote server.

36
Q

How can you copy files between two servers securely?

A

Use the scp (secure copy) command to transfer files between servers.

37
Q

What is a firewall, and how is it used in Linux?

A

A firewall controls incoming and outgoing network traffic based on security rules. In Linux, iptables or firewalld is used to configure firewall rules.

38
Q

How do you check which ports are listening on a server?

A

Use the netstat -tuln or ss -tuln command to see which ports are listening.

39
Q

How can you view system logs in Linux?

A

System logs are stored in the /var/log directory. You can use tail, less, or cat to view them.

40
Q

What is the purpose of environment variables in Linux?

A

Environment variables store information that can be used by applications and scripts to configure settings and paths.

41
Q

How can you view the value of an environment variable?

A

Use the echo $VARIABLE_NAME command to view an environment variable’s value.

42
Q

How do you add a directory to the PATH environment variable?

A

Use export PATH=$PATH:/new/directory/path to add a directory to PATH.

43
Q

What is sed used for?

A

sed is a stream editor used to perform basic text transformations and replacements in files or streams.

44
Q

What is awk used for?

A

awk is a powerful text-processing tool for data extraction and reporting in structured text files.

45
Q

How do you monitor network traffic in Linux?

A

Use tools like tcpdump or netstat to monitor network traffic.