linux Flashcards
What command displays the current working directory?
The command pwd
displays the current working directory.
How do you list all files, including hidden files, in a directory?
The ls -a
command lists all files, including hidden ones.
How can you view the contents of a file one screen at a time?
Use the less
or more
command to view file contents one screen at a time.
What command is used to change file permissions?
The chmod
command changes file permissions.
How do you change ownership of a file in Linux?
Use the chown
command to change file ownership.
How can you check the permissions of a file?
The ls -l
command displays the file permissions in detail.
What is the difference between su
and sudo
?
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 do you display the first few lines of a file?
The head
command displays the first few lines of a file.
How do you search for a specific text string in files?
Use the grep
command to search for a text string in files.
What command would you use to display active processes?
The ps
command displays active processes, or top
for an interactive view of running processes.
What is the purpose of the kill
command?
The kill
command is used to terminate a process by its PID (Process ID).
How can you view system memory usage?
Use the free
command or top
to view system memory usage.
What is the difference between hard and soft links?
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.
What command shows the disk usage of a directory and its contents?
The du
command shows the disk usage of a directory and its contents.
How do you display the IP address of the machine?
Use the ip addr
or ifconfig
command to display the IP address.
What is the purpose of the /etc/hosts
file?
The /etc/hosts
file maps hostnames to IP addresses for local name resolution.
What command is used to download files from the internet?
The wget
or curl
command is used to download files from the internet.
What is the cron
daemon used for?
The cron
daemon is used to schedule recurring tasks at specified intervals.
How do you display the last 10 lines of a log file?
The tail
command shows the last 10 lines of a file, or tail -f
for real-time updates.
How do you check the status of all services on a Linux system?
Use systemctl list-units --type=service
to check the status of all services.
What is virtualization?
Virtualization is the process of creating virtual instances of computer resources, such as servers, storage, and networks.
What is the difference between a virtual machine and a container?
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.
What is a hypervisor?
A hypervisor is software that allows multiple virtual machines to run on a single physical host, with each VM isolated from others.
How do Type 1 and Type 2 hypervisors differ?
Type 1 hypervisors run directly on hardware (bare-metal), while Type 2 hypervisors run on top of an existing operating system.
What are some popular hypervisors used in the industry?
Popular hypervisors include VMware ESXi, Microsoft Hyper-V, and open-source solutions like KVM and Xen.
What are the advantages of using containers over VMs?
Containers are lightweight, have lower overhead, and start faster than VMs since they share the host OS kernel.
What is Docker, and why is it important in DevOps?
Docker is a platform for developing, shipping, and running applications in containers, making it easier to ensure consistency across development, testing, and production environments.
How can you create a Docker container?
Use the docker run
command with an image name to create and start a container, for example, docker run ubuntu
.
How do you list all running Docker containers?
The docker ps
command lists all running containers.
What is a Docker image?
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.
What command allows you to access the shell of a running Docker container?
The docker exec -it <container_name> /bin/bash
command allows you to access the shell of a running container.
How can you view resource usage by processes in real-time?
The top
command shows real-time resource usage, including CPU, memory, and processes.
How do you find the process ID (PID) of a specific process?
Use the ps aux | grep <process_name>
command to find the PID of a process.
What is the purpose of SSH?
SSH (Secure Shell) is a protocol for securely logging into and managing remote servers.
How do you connect to a remote server using SSH?
Use the command ssh user@host
to connect to a remote server.
How can you copy files between two servers securely?
Use the scp
(secure copy) command to transfer files between servers.
What is a firewall, and how is it used in Linux?
A firewall controls incoming and outgoing network traffic based on security rules. In Linux, iptables
or firewalld
is used to configure firewall rules.
How do you check which ports are listening on a server?
Use the netstat -tuln
or ss -tuln
command to see which ports are listening.
How can you view system logs in Linux?
System logs are stored in the /var/log
directory. You can use tail
, less
, or cat
to view them.
What is the purpose of environment variables in Linux?
Environment variables store information that can be used by applications and scripts to configure settings and paths.
How can you view the value of an environment variable?
Use the echo $VARIABLE_NAME
command to view an environment variable’s value.
How do you add a directory to the PATH environment variable?
Use export PATH=$PATH:/new/directory/path
to add a directory to PATH.
What is sed
used for?
sed
is a stream editor used to perform basic text transformations and replacements in files or streams.
What is awk
used for?
awk
is a powerful text-processing tool for data extraction and reporting in structured text files.
How do you monitor network traffic in Linux?
Use tools like tcpdump
or netstat
to monitor network traffic.