Linux-Bundle Flashcards
Get help with Linux commands
-
man <command>
- Shows the manual for a command. -
<command> --help
or<command> -h
- Displays usage and options for a command. -
info <command>
- Provides detailed information about a command. -
whatis <command>
- Gives a brief description of a command. -
apropos <search-term>
- Searches for commands related to a term. -
type <command>
- Indicates if a command is built-in or external.
How to check Linux Version?
Use the command lsb_release -a
or cat /etc/os-release
to check the Linux version.
How do I see my command history on Linux?
How do I run a specific command from my command history?
To see your command history on Linux, type history
in the terminal.
To run a specific command from your history, use !
followed by the command number from the history list. For example, !42
will run the 42nd command in your history.
What is the package manager used in Red Hat Enterprise Linux for installing and managing software?
Red Hat-based Systems (e.g., CentOS, Fedora)
yum list - List all available packages yum install <package-name> - Install a package yum update - Update all installed packages yum remove <package-name> - Remove a package
- RPM (Red Hat Package Manager): Fundamental package management tool in all versions of Red Hat Enterprise Linux.
- YUM (Yellowdog Updater Modified): Primary package manager for Red Hat Enterprise Linux 7 and earlier versions, serving as a front-end to RPM.
- DNF (Dandified YUM): Enhanced package manager used in Red Hat Enterprise Linux 8 and later, acting as a more efficient front-end to RPM.
What is the package manager used in ubuntu Linux for installing and managing software?
Ubuntu (Debian-based Systems)
apt list - List all available packages apt install <package-name> - Install a package apt update - Update all installed packages apt remove <package-name> - Remove a package
- APT (Advanced Package Tool): The primary and most commonly used package manager in Ubuntu, handling .deb packages and repositories.
-
DPKG: The low-level tool that
apt
relies on to manage .deb packages. It handles package installation, removal, and information. - Snap: A newer package management system developed by Canonical, the company behind Ubuntu. It’s used to install and manage Snap packages, which are self-contained and work across different Linux distributions.
-
Software Center: A user-friendly graphical interface for managing software, which internally uses
apt
or Snap depending on the type of package. -
Synaptic Package Manager: A graphical package management program for
apt
. It provides a GUI for theapt-get
command line utility. - GDebi: A simple tool to install .deb files, which also resolves and installs their dependencies.
-
Aptitude: Another front-end for
apt
, available as a command-line tool and offering a text-based interface.
How do I identify built-in and external commands in Linux, Redhat, and Ubuntu?
To identify built-in and external commands in Linux, Redhat, and Ubuntu, you can use the following commands:
type <command_name></command_name>
or,
which <command_name></command_name>
How do I download a package from online in Linux?
There are two ways to download a package from online in Linux:
Using the wget command Using the curl command
The wget command is a command-line utility that can be used to download files from the internet. To download a package using wget, you can use the following command:
wget <URL></URL>
The curl command is another command-line utility that can be used to download files from the internet. To download a package using curl, you can use the following command:
curl -o <path> <URL></URL></path>
For example, to download the vim package from the Ubuntu repositories and save it to the /tmp directory, you would use the following command:
curl -o /tmp/vim https://packages.ubuntu.com/impish/vim
What are the advantages of using wget or curl to download packages?
What are the disadvantages of using wget or curl to download packages?
There are several advantages to using wget or curl to download packages:
-They are both very reliable and can download files even if there are network errors.
-They can download files from any website, not just from repositories.
-They can download files in parallel, which can speed up the download process.
-They can resume downloads if they are interrupted by a network error.
There are a few disadvantages to using wget or curl to download packages:
-They can be more difficult to use than graphical package managers.
-They do not provide any feedback on the download progress.
-They cannot install packages automatically.
Check local and public ip address?
You can use the ip addr show command to display all of the network interfaces on your system, along with their IP addresses. To find your local IP address, look for the IP address that is assigned to the interface that you are using to connect to your local network.
To find your public IP address, you can use the curl ifconfig.me command.
Use cases for curl ?
Testing APIs: curl is often used to test and interact with APIs. You can make HTTP requests to different endpoints, inspect response headers and data, and verify API behavior.
Automating Tasks: curl can be utilized in shell scripts or automation workflows to perform various tasks, such as downloading files, fetching data from web services, or interacting with remote systems. Debugging Network Issues: When troubleshooting network-related problems, curl can be used to check connectivity, test DNS resolution, verify SSL certificates, and examine HTTP response codes. Uploading Files: curl enables you to upload files to remote servers using protocols like FTP, SCP, or HTTP. This is useful for automating file transfers or deploying files to a web server. Downloading Files: You can download files from the web using curl, allowing you to retrieve specific resources or automate file downloads in scripts or scheduled tasks. Scraping Web Content: curl can be combined with other tools like grep, awk, or sed to scrape web content or extract specific data from HTML pages. This can be useful for web scraping or data extraction tasks. Testing Website Availability: By making HTTP requests to a website using curl, you can monitor its availability and response times. This can be done periodically as part of a monitoring system. Authentication and Authorization: curl supports various authentication mechanisms, such as Basic, Digest, or OAuth. It can be used to test and verify authentication flows or interact with protected resources. Simulating User Interaction: With curl, you can simulate user interactions by submitting form data, sending cookies, or handling sessions. This can be useful for testing web applications or replicating user behavior. Integration with Other Tools: curl can be integrated with other command-line tools and utilities, allowing you to pipe data between commands or combine its functionality with other Linux tools for complex tasks.
How to check all listening port on linux server?
Using netstat
The netstat command is a powerful tool that can be used to display information about network connections. To list all listening ports, use the following command:
netstat -an | grep LISTEN
Using ss
The ss command is a newer alternative to netstat. It offers a number of advantages over netstat, including the ability to display more detailed information about network connections. To list all listening ports, use the following command:
ss -an | grep LISTEN
Using nmap
The nmap command is a network scanner that can be used to scan a system for open ports. To list all listening ports, use the following command:
nmap -v -sT localhost
Telnet network protocol
The telnet command is a network protocol that allows you to connect to a remote computer and interact with it as if you were sitting at the keyboard. It uses port 23 to establish a connection, and provides a way to manage remote systems using the CLI.
telnet [options] hostname [port]
telnet 192.168.1.122 80
USE CASES
Troubleshooting network problems: Telnet can be used to connect to a remote computer and check for connectivity issues. For example, you could use telnet to check if a particular port is open, or to see if a remote server is responding to requests.
Administering servers: Telnet can be used to administer remote servers, such as configuring settings, installing software, and troubleshooting problems.
Transferring files: Telnet can be used to transfer files between two computers. For example, you could use telnet to copy a file from a remote server to your local machine, or to upload a file from your local machine to a remote server.
Testing web applications: Telnet can be used to test web applications by connecting to the application’s port and interacting with it as a user. This can be useful for checking for errors, or for testing the application’s functionality.
You can use the service or systemctl command to check the status of a service on Linux.
service <service_name> status
systemctl status <service_name></service_name></service_name>
For More Info Use; man service or man systemctl
Services
service <name> status --- To check the status of the servic</name>
service - This controls the starting and stopping of services
chkconfig - This controls which services are set to start on boot
#service <name> start ---To start the service
#service <name> stop --- To stop a service
#service <name> reload --- To reload the service #service <name> restart To restart the service</name></name></name></name>
#chkconfig <service> on --- To make the service available after restart #chkconfig <service> off --- To make the service unavailable after restart</service></service>
What is demon in LINUX?
In Linux, a daemon is a program that runs in the background, without any user interaction. Daemons are typically used to provide services to other programs or users, such as serving web pages, managing network traffic, or providing file storage.
Some common examples of daemons include:
Apache: A web server daemon that serves web pages to users. Samba: A file server daemon that allows users to share files and printers across a network. MySQL: A database server daemon that stores and retrieves data. SSH: A secure shell daemon that allows users to log in to remote systems securely.
Daemons are an essential part of the Linux operating system. They provide a wide range of services that make it possible for users to do their work and enjoy the benefits of a networked computer.
Here are some additional details about daemons:
Daemons typically have a name that ends with the letter "d". For example, the Apache web server daemon is called "httpd". Daemons run in the background, without any user interaction. This means that they do not have a user interface, and they cannot be controlled by the user. Daemons are typically started by the init system. The init system is a program that is responsible for starting and stopping all of the programs on the system. Daemons are typically written in a programming language such as C or Python. Daemons are often designed to be very efficient, so that they can use as few resources as possible.
what does chkconfig do?
Chkconfig is a command-line utility that allows you to manage the startup and shutdown of services on Linux systems. It can be used to enable, disable, start, stop, and restart services. Chkconfig also allows you to specify the runlevel in which a service should start or stop.
chkconfig [options] service [on|off|start|stop|restart]
Example:
chkconfig httpd on 2345
chkconfig smb stop
chkconfig mysql restart
Chkconfig is a powerful tool that can be used to manage the startup and shutdown of services on Linux systems. It is a valuable tool for system administrators who need to control how services are started and stopped on their systems.
Here are some additional things to keep in mind when using chkconfig:
You must be root to use chkconfig. Chkconfig only works with services that are configured to start or stop at boot. Chkconfig does not work with services that are started or stopped manually. If you make a change to the startup configuration of a service with chkconfig, you may need to restart the service for the change to take effect.