Questions and Answers
What command is used to create an empty file?
touch filename.txt
Which command can create a file and write a line of text to it?
echo "Hello, World!" > filename.txt
What command is used to display the content of a file?
cat filename.txt
Which command would you use to append text to an existing file?
Signup and view all the answers
The command mkdir
is used to create a _____.
Signup and view all the answers
The rmdir
command can remove a non-empty directory.
Signup and view all the answers
What command is used to remove a directory and its contents recursively?
Signup and view all the answers
What does the chmod
command do?
Signup and view all the answers
What permission corresponds to read-only access for others?
Signup and view all the answers
What command would you use to add a new user to the system?
Signup and view all the answers
Which file contains basic information about all user accounts?
Signup and view all the answers
What is the purpose of the tar
command?
Signup and view all the answers
What does the 'grep' command do?
Signup and view all the answers
A ______ links to another file by storing the path to it.
Signup and view all the answers
What is a key characteristic of hard links?
Signup and view all the answers
What command would you use to view the status of a service?
Signup and view all the answers
What is the primary purpose of virtualization?
Signup and view all the answers
What is the loopback interface used for?
Signup and view all the answers
What is the loopback IP address?
Signup and view all the answers
What does LAN stand for?
Signup and view all the answers
What does WAN stand for?
Signup and view all the answers
What is the function of a Network Interface Card (NIC)?
Signup and view all the answers
At which layer of the OSI model do switches operate?
Signup and view all the answers
At which layer of the OSI model do routers operate?
Signup and view all the answers
What does NAT stand for and what is its purpose?
Signup and view all the answers
What is the purpose of a subnet mask?
Signup and view all the answers
What is a static IP address?
Signup and view all the answers
What is a dynamic IP address?
Signup and view all the answers
What is the configuration file for network interfaces in Debian/Ubuntu?
Signup and view all the answers
What command is used to obtain an IP address from a DHCP server?
Signup and view all the answers
What does DHCP stand for?
Signup and view all the answers
What does DNS stand for?
Signup and view all the answers
What is the primary function of a firewall?
Signup and view all the answers
What is a VPN?
Signup and view all the answers
The IP address format of IPv4 consists of _______ bits.
Signup and view all the answers
A unique hardware address used within LANs is known as a _______.
Signup and view all the answers
Which command can be used to show details of a specific connection?
Signup and view all the answers
Study Notes
File Management in Unix-like Systems
- Use
touch filename.txt
to create an empty file. -
echo "Hello, World!" > filename.txt
creates a file and writes content. -
cat > filename.txt
allows creation and input of text to a file. - Edit files with
vi filename.txt
for a powerful text editor. - Append text to files using
echo "Additional text" >> filename.txt
. - Merge file content with
cat anotherfile.txt >> filename.txt
.
Reading Files
- Display file content using
cat filename.txt
. - Use
more filename.txt
andless filename.txt
for paginated reading. - View the beginning of files with
head filename.txt
. - Check the end of files using
tail filename.txt
.
Directory Management
- Create a directory with
mkdir directory_name
. - Create nested directories using
mkdir -p parent_directory/child_directory
. - Remove empty directories with
rmdir directory_name
. - Use
rm -r directory_name
for recursive directory removal. - Force deletion with
rm -rf directory_name
.
File Operations
- Copy files with
cp source_file destination_file
. - Copy multiple files into a directory using
cp file1 file2 destination_directory/
. - Recursively copy directories using
cp -r source_directory destination_directory
. - Move or rename files with
mv source_file destination_directory/
ormv old_filename new_filename
.
File and Directory Permissions
- Permissions display as
-rwxr-xr--
, indicating file type and permissions for owner, group, and others. -
r
= read,w
= write,x
= execute. - Change permissions using
chmod
with symbolic (+
,-
,=
) and numeric methods (e.g.,chmod 755 filename
). - Set default file permissions based on
umask
, which subtracts from default values (666 for files, 777 for directories).
User Management
- Add a user with
sudo useradd username
and set password usingsudo passwd username
. - Use
sudo usermod -aG groupname username
for additional group permissions. - Remove a user with
sudo userdel username
orsudo userdel -r username
to delete their home directory.
Log Files
-
/var/log/syslog
records system activity and security events. -
/var/log/auth.log
contains authentication logs for login attempts and account changes. -
/var/log/kern.log
logs kernel messages for system diagnostics.
Search and Process Management
- Use
grep
andegrep
for text searching; egrep supports extended regex. - Common
grep
flags include-i
(ignore case),-r
(recursive),-c
(count lines), and context options (-A
,-B
,-C
). - Manage processes with
systemctl
(start, stop, enable, disable services). - Use
kill PID
orpkill process_name
to terminate processes.
Virtualization
- Virtualization creates multiple VMs on a single machine for better resource utilization.
- Types include Type 1 (bare metal hypervisor) and Type 2 (hosted hypervisor).
- VMware ESXi is a Type 1 hypervisor for hardware resource management.
- vSphere combines ESXi and vCenter for centralized management of VMs.
Networking Basics
- NIC (Network Interface Card) enables device network connectivity.
- LAN (Local Area Network) connects devices within a limited area while WAN (Wide Area Network) spans larger geographic areas.
- Routers forward packets between networks, while switches connect multiple devices within a LAN.
- NAT translates private IP addresses for public internet access and adds security.
IP Addressing
- IPv4 uses 32-bit addresses, while IPv6 uses 128 bits for a larger address space.### IPv6 and IP Addressing
- IPv6 utilizes 128-bit IP addresses, providing a virtually unlimited address space.
- A MAC address is a unique hardware identifier for network interface cards, specifically used within local area networks (LANs).
- The subnet mask divides an IP address into network and host portions, helping to identify the network segment.
- The default gateway is the router's IP address that forwards local network traffic to other networks, including the internet.
Static vs. Dynamic IP Addresses
- Static IP addresses remain fixed and are manually assigned, preferred for devices needing consistent access like servers and printers.
- Dynamic IP addresses are automatically assigned by DHCP servers and can change, suitable for devices such as computers and smartphones that connect and disconnect often.
Network Configuration Files
-
/etc/network/interfaces
is used in Debian/Ubuntu for network interface configuration. -
/etc/sysconfig/network-scripts/ifcfg-*
is for configuring interfaces in Red Hat/CentOS systems. -
/etc/nsswitch.conf
defines the lookup order for hostname resolution and user information. -
/etc/hosts
maps hostnames to IP addresses for local name resolution. -
/etc/resolv.conf
specifies DNS servers for resolving domain names.
Network Configuration Tools
-
ifconfig
is a deprecated tool for network interface configuration. -
ip
is the modern command used for managing IP addresses and interfaces. -
nmcli
andnmtui
manage NetworkManager through command line and text-based interfaces. -
dhclient
is a DHCP client tool to receive IP address configurations.
NetworkManager
- A Linux system service aimed at simplifying network management, supporting various connection types and adapting to network changes.
- Features include dynamic configuration, connection persistence, automatic IP assignment, and an API for user integrations.
- It monitors network connectivity and supports security measures such as VPN management.
Network Services
- DHCP assigns IP addresses and other network settings automatically to connected devices.
- DNS converts user-friendly domain names into IP addresses.
- SSH provides a secure protocol for remote machine access.
Routing Concepts
- The routing table determines packet paths, modified with
route
orip route
commands. - Static routing involves manually defined paths, while dynamic routing adjusts automatically through protocols like OSPF and BGP.
Network Diagnostic Tools
-
ping
checks connectivity by sending ICMP echo requests. -
traceroute
traces paths packets take to a destination. -
ip route
displays current routing table information. -
ethtool
configures settings for network interface cards.
Host and VM Information Commands
- Use
ifconfig
,ip addr show
, ormcli
to find IP addresses. - Network mask/prefix can also be viewed with
ifconfig
andip addr show
. - Determine the gateway with
route -n
andnetstat -nr
. - DNS details can be accessed via
nslookup
anddig
.
Firewalls
-
iptables
is a user-space program to configure packet filter rules for Linux kernel firewalls. -
firewalld
offers dynamic management of firewall settings via a D-Bus interface.
Virtual Networking
- A bridge connects multiple network interfaces at the data link layer.
- VLANs create separate broadcast domains on the same physical network.
- VPNs establish secure, encrypted connections over potentially insecure networks.
Basic Network Commands
- Show all connections:
nmcli con show
- Get details of a specific connection:
nmcli con show <connection_name>
- Activate or deactivate a connection:
nmcli con up <connection_name>
,nmcli con down <connection_name>
- Modify or clone connections using
nmcli connection modify <connection_name>
andnmcli connection clone <source_connection_name>
. - Delete a connection:
nmcli connection delete <connection_name>
.
Creating a New Connection
- Create an Ethernet connection with
nmcli connection add con-name <name> type ethernet ifname <interface> ipv4.addresses <address> ipv4.dns <dns> ipv4.gateway <gateway> ipv4.method manual connection.autoconnect yes
. - Example:
nmcli connection add con-name ens171 type ethernet ifname ens192 ipv4.addresses 10.10.60.156/18 ipv4.dns 1.1.1.1 ipv4.gateway 10.10.60.1 ipv4.method manual connection.autoconnect yes
.
Packet Management
- Handles software packages for installation, updating, and removal.
- For Red Hat-based systems, use
sudo dnf upgrade
to update the package list oryum
/dnf
commands for installation and removal. - Search installed packages with
yum list installed
ordnf list installed
.
LDAP Overview
- LDAP is a protocol for accessing and managing directory services and is essential for centralized user management.
- Key concepts include directory services, entries and attributes, distinguished names (DN), schemas, and core operations like Bind, Search, and Compare.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
This quiz covers the essential commands for creating, modifying, and managing files in a Unix-like operating system, such as Linux. Learn how to use commands like touch, echo, and cat effectively to handle files and text. Perfect for beginners looking to enhance their skills in file management.