Introduction to Linux and It's Basic Commands.

Introduction to Linux and It's Basic Commands.

What is Linux?

Linux is a free and open-source operating system based on the Unix operating system. It was created by Linus Torvalds in 1991 and has since become one of the most widely used operating systems in the world. Linux is known for its stability, security, and flexibility, and it can run on a wide variety of hardware, from mobile devices to servers. Linux is also highly customizable, allowing users to modify and enhance the operating system to suit their specific needs. Linux distributions, such as Ubuntu, Fedora, and Debian, package the Linux kernel with various software packages to create a complete operating system.

Types of Linux Commands

There are many different types of commands used in Linux, but some of the most common ones include:

  1. System commands: These commands are used to manage the system resources and perform administrative tasks, such as starting or stopping services, managing users and groups, and configuring the network.

  2. File management commands: These commands are used to manipulate files and directories, such as creating, deleting, copying, moving, and renaming files and directories.

  3. Process management commands: These commands are used to manage running processes, such as starting, stopping, and monitoring processes.

  4. Text processing commands: These commands are used to manipulate and process text, such as searching for text within files, sorting and filtering text, and modifying text.

  5. Networking commands: These commands are used to manage network connections, such as checking network status, configuring network settings, and troubleshooting network issues.

  6. Package management commands: These commands are used to manage software packages, such as installing, updating, and removing software packages.

  7. Shell scripting commands: These commands are used to create and run shell scripts, which are programs written in the Linux shell language that automate tasks or perform complex operations.

These are just a few examples of the types of commands that can be used in Linux, and there are many more commands available depending on your specific needs.

Linux Commands

It is not possible to list all Linux commands as there are hundreds of them. However, here are some of the most commonly used Linux commands:

  1. cd: Change directory

  2. ls: List files and directories

  3. pwd: Print working directory

  4. mkdir: Make directory

  5. rm: Remove files and directories

  6. cp: Copy files and directories

  7. mv: Move or rename files and directories

  8. touch: Create a new empty file

  9. cat: Display file contents

  10. grep: Search for a pattern in a file

  11. less: Display file contents one screen at a time

  12. chmod: Change file permissions

  13. chown: Change file ownership

  14. ps: Display running processes

  15. top: Display system resource usage

  16. kill: Terminate a process

  17. ping: Check network connectivity

  18. ifconfig: Configure network interfaces

  19. netstat: Display network connections

  20. ssh: Secure shell remote access

System Commands

Here are some commonly used system commands in Linux:

  1. reboot: Restart the system

  2. shutdown: Shutdown or power off the system

  3. systemctl: Control the systemd system and service manager

  4. service: Control system services (init.d script)

  5. useradd: Add a new user to the system

  6. userdel: Delete a user from the system

  7. passwd: Change a user's password

  8. groupadd: Add a new group to the system

  9. groupdel: Delete a group from the system

  10. visudo: Edit the sudoers file to manage user privileges

  11. hostname: Display or change the hostname of the system

  12. ifconfig: Configure and display network interfaces

  13. netstat: Display network connections

  14. route: Display and modify the routing table

  15. iwconfig: Configure and display wireless network interfaces

  16. free: Display memory usage

  17. df: Display disk space usage

  18. du: Display disk usage of files and directories

  19. top: Display system resource usage

  20. ps: Display running processes

File Management Commands

Here are some commonly used file management commands in Linux:

  1. ls: List files and directories

  2. cd: Change directory

  3. pwd: Print working directory

  4. mkdir: Make directory

  5. rmdir: Remove directory (only if it's empty)

  6. rm: Remove files and directories

  7. cp: Copy files and directories

  8. mv: Move or rename files and directories

  9. touch: Create a new empty file

  10. cat: Display file contents

  11. head: Display the first few lines of a file

  12. tail: Display the last few lines of a file

  13. less: Display file contents one screen at a time

  14. diff: Compare two files

  15. file: Determine file type

  16. chmod: Change file permissions

  17. chown: Change file ownership

  18. ln: Create a link (hard or symbolic) to a file

  19. find: Search for files and directories

  20. grep: Search for a pattern in a file

Process management commands

Here are some commonly used process management commands in Linux:

  1. ps: Display information about running processes

  2. top: Display system resource usage and running processes

  3. kill: Send a signal to a process to terminate it

  4. killall: Terminate all processes with a given name

  5. nice: Set the priority of a process

  6. renice: Change the priority of a running process

  7. pgrep: Display the process ID of a process matching a name or pattern

  8. pkill: Send a signal to a process matching a name or pattern to terminate it

  9. uptime: Display how long the system has been running and the average system load

  10. htop: Interactive process viewer and system monitor

  11. systemctl: Control the systemd system and service manager

  12. service: Control system services (init.d script)

  13. jobs: Display background jobs and their status

  14. bg: Move a job to the background

  15. fg: Move a job to the foreground

Text processing commands

Here are some commonly used text processing commands in Linux:

  1. grep: Search for a pattern in a file or stream

  2. sed: Stream editor for modifying text

  3. awk: Pattern scanning and processing language

  4. cut: Extract columns or fields from a file

  5. paste: Merge lines from multiple files

  6. sort: Sort lines of text

  7. uniq: Find unique lines in a sorted file

  8. tr: Translate characters in a stream

  9. wc: Count the number of lines, words, and bytes in a file or stream

  10. head: Display the first few lines of a file or stream

  11. tail: Display the last few lines of a file or stream

  12. tee: Duplicate input to both a file and stdout

  13. comm: Compare two sorted files line by line

  14. diff: Compare two files line by line

  15. nl: Add line numbers to a file

Networking Commands

Here are some commonly used networking commands in Linux:

  1. ifconfig: Configure and display network interfaces

  2. ip: Configure and display IP addresses and routing

  3. ping: Test connectivity to a network host using ICMP echo requests

  4. traceroute: Display the path that packets take to reach a network host

  5. netstat: Display network connections and statistics

  6. ss: Display network sockets and statistics

  7. hostname: Display or change the hostname of the system

  8. dig: Query DNS servers for information about a domain name

  9. nslookup: Query DNS servers for information about a domain name (deprecated in favor of dig)

  10. route: Display and modify the routing table

  11. iptables: Configure and control the Linux firewall (netfilter)

  12. nmap: Network exploration and security auditing tool

  13. tcpdump: Capture and analyze network traffic

  14. ifup: Bring a network interface up

  15. ifdown: Bring a network interface down

Package Management Commands

Here are some commonly used package management commands in Linux:

  1. apt-get: Package manager for Debian and Ubuntu distributions

  2. yum: Package manager for Red Hat, CentOS, and Fedora distributions

  3. pacman: Package manager for Arch Linux distributions

  4. zypper: Package manager for SUSE Linux distributions

  5. dpkg: Low-level package management tool for Debian-based distributions

  6. rpm: Low-level package management tool for Red Hat-based distributions

  7. apt-cache: Search for packages and display package information for Debian and Ubuntu distributions

  8. yum search: Search for packages and display package information for Red Hat, CentOS, and Fedora distributions

  9. pacman -Ss: Search for packages and display package information for Arch Linux distributions

  10. zypper search: Search for packages and display package information for SUSE Linux distributions

  11. apt-add-repository: Add a repository to the sources list for Debian and Ubuntu distributions

  12. yum-config-manager: Manage repositories for Red Hat, CentOS, and Fedora distributions

  13. pacman -Syy: Update package databases for Arch Linux distributions

  14. zypper refresh: Refresh package repositories for SUSE Linux distributions

  15. apt-get upgrade: Upgrade packages for Debian and Ubuntu distributions

  16. yum update: Upgrade packages for Red Hat, CentOS, and Fedora distributions

  17. pacman -Syu: Upgrade packages for Arch Linux distributions

  18. zypper update: Upgrade packages for SUSE Linux distributions

Shell Scripting Commands

Shell scripting commands are used to write scripts that automate tasks in a Linux shell. Here are some commonly used shell scripting commands:

  1. echo: Display a message on the screen

  2. read: Read user input and assign it to a variable

  3. if: Conditionally execute commands

  4. for: Loop over a sequence of items and execute commands for each item

  5. while: Loop over a sequence of commands while a condition is true

  6. case: Conditionally execute commands based on a variable value

  7. function: Define and use functions

  8. export: Set environment variables for child processes

  9. cd: Change the current working directory

  10. pwd: Display the current working directory

  11. ls: List files and directories

  12. cp: Copy files and directories

  13. mv: Move or rename files and directories

  14. rm: Remove files and directories

  15. touch: Create an empty file or update the modification time of an existing file

  16. chmod: Change the permissions of a file or directory

  17. chown: Change the owner of a file or directory

  18. grep: Search for a pattern in a file or stream

  19. sed: Stream editor for modifying text

  20. awk: Pattern scanning and processing language

These are just some of the commands available in Linux, and there are many more depending on your needs and the installed software packages. You can use the man command followed by the name of the command to get more information on how to use it and what options are available.

Thank You for reading this blog.

In next blog we are going to study

Stay Connected

Happy Learning.