Linux Commands


Linux is a versatile and powerful operating system, and it provides a wide range of commands for managing and interacting with the system. Here are some commonly used Linux commands that can be helpful for various tasks:

  1. File and Directory Operations:

    • ls: List files and directories in the current directory.
    • pwd: Print the current working directory.
    • cd <directory>: Change the current directory.
    • mkdir <directory>: Create a new directory.
    • touch <file>: Create an empty file.
    • cp <source> <destination>: Copy files or directories.
    • mv <source> <destination>: Move or rename files or directories.
    • rm <file>: Remove files.
    • rmdir <directory>: Remove empty directories.
    • chmod <permissions> <file>: Change file permissions.
    • chown <user>:<group> <file>: Change file ownership.
  2. File Viewing and Editing:

    • cat <file>: Display the contents of a file.
    • more <file> or less <file>: View file contents page by page.
    • nano <file> or vim <file>: Open a text editor to edit a file.
  3. Searching for Files and Text:

    • find <directory> -name <filename>: Search for files by name.
    • grep <pattern> <file>: Search for text patterns in files.
    • locate <filename>: Quickly find files by name (requires an updated database).
  4. Process Management:

    • ps: List running processes.
    • top or htop: Monitor system processes and resource usage.
    • kill <PID>: Terminate a process by its Process ID.
    • killall <process-name>: Terminate all processes with a given name.
  5. System Information:

    • uname -a: Display system information, including the kernel version.
    • df -h: Show disk space usage.
    • free -h: Display memory usage.
    • lscpu or nproc: Get CPU information.
    • lsblk: List block devices and their information.
  6. Package Management:

    • apt-get or apt (Debian/Ubuntu):
      • sudo apt-get update: Update package lists.
      • sudo apt-get install <package>: Install a package.
      • sudo apt-get remove <package>: Remove a package.
    • yum (Red Hat/CentOS):
      • sudo yum update: Update packages.
      • sudo yum install <package>: Install a package.
      • sudo yum remove <package>: Remove a package.
  7. User and Permissions:

    • whoami: Display the current user.
    • passwd: Change the user password.
    • useradd and userdel: Create and delete users.
    • usermod: Modify user attributes.
    • sudo: Execute commands with superuser privileges.
    • su <username>: Switch to another user.
  8. Networking:

    • ifconfig or ip addr: Display network interface information.
    • ping <host>: Send ICMP echo requests to test network connectivity.
    • netstat or ss: Display network statistics and connections.
    • ssh <user>@<host>: Connect to a remote host using SSH.
    • scp <file> <user>@<host>:<destination>: Securely copy files between hosts.
  9. Compression and Archiving:

    • tar: Archive files and directories.
    • gzip or gunzip: Compress and decompress files.
    • zip and unzip: Create and extract ZIP archives.
  10. System Logs:

    • dmesg: Display kernel messages.
    • journalctl: View system logs using systemd's journal.

These are just a few of the many Linux commands available. Linux offers a rich set of tools and commands for system administration, development, and day-to-day tasks, so it's worth exploring the man pages and documentation for specific commands to learn more about their options and capabilities.

Here are some useful Linux commands:

General purpose commands:

  • pwd: Prints the working directory.
  • cd: Changes the working directory.
  • ls: Lists the contents of the current directory.
  • cat: Displays the contents of a file.
  • mkdir: Creates a new directory.
  • rmdir: Removes a directory.
  • touch: Creates a new empty file.
  • rm: Removes a file.
  • cp: Copies a file or directory.
  • mv: Moves or renames a file or directory.
  • find: Finds files and directories based on criteria.
  • grep: Searches for text in files.
  • sudo: Executes a command with root privileges.

File and directory management commands:

  • chmod: Changes the permissions of a file or directory.
  • chown: Changes the ownership of a file or directory.
  • chgrp: Changes the group of a file or directory.
  • tar: Creates and extracts archives.
  • zip: Creates and extracts ZIP archives.
  • unzip: Extracts ZIP archives.

Networking commands:

  • ping: Tests the connection to another host.
  • ifconfig: Displays information about network interfaces.
  • netstat: Displays information about network connections.
  • traceroute: Traces the path to another host.
  • ssh: Connects to another host using SSH.

System administration commands:

  • top: Displays information about running processes.
  • ps: Lists running processes.
  • kill: Kills a running process.
  • systemctl: Controls system services.
  • apt: Installs, updates, and removes software packages (Debian/Ubuntu).
  • yum: Installs, updates, and removes software packages (CentOS/RHEL).

These are just a few of the many useful Linux commands. For more information, please see the Linux man pages or the Linux documentation.

Here are some examples of how to use Linux commands:

  • To list the contents of the current directory:
ls
  • To create a new directory called my-dir:
mkdir my-dir
  • To change the working directory to my-dir:
cd my-dir
  • To copy a file called myfile.txt to the my-dir directory:
cp myfile.txt my-dir
  • To remove the my-dir directory:
rmdir my-dir
  • To find all files with the .txt extension:
find . -name "*.txt"
  • To search for the word "hello" in all files in the current directory:
grep -r "hello" .
  • To ping the Google server:
ping google.com
  • To connect to the remote host 192.168.1.100 using SSH:
ssh user@192.168.1.100
  • To view information about all running processes:
top
  • To kill the process with the ID 1234:
kill 1234

Linux is a powerful operating system with a wide range of commands available. By learning the basic Linux commands, you can start to use Linux to manage your files, system, and network more effectively.


Linux and Unix commands are used to interact with the operating system and perform various tasks. There are hundreds of different Linux and Unix commands, but some of the most common include:

  • ls: Lists the contents of a directory.
  • cd: Changes the current working directory.
  • mkdir: Creates a new directory.
  • rmdir: Removes a directory.
  • cp: Copies a file or directory.
  • mv: Moves a file or directory.
  • rm: Removes a file or directory.
  • cat: Displays the contents of a file.
  • grep: Searches for a pattern in a file.
  • sudo: Executes a command with superuser privileges.
  • apt-get: Installs and removes software packages.
  • yum: Installs and removes software packages on Red Hat-based systems.
  • ps: Lists running processes.
  • kill: Terminates a running process.
  • man: Displays the manual page for a command.

These are just a few of the many Linux and Unix commands that are available. For a more comprehensive list of commands, please consult the manual pages.



To learn more about a specific command, you can use the man command. For example, to learn more about the ls command, you would type the following command:

man ls

This will display the manual page for the ls command, which will explain how to use the command and its various options.

You can also learn more about Linux and Unix commands by reading tutorials and books on the subject. There are many resources available online and in libraries.

Once you have learned the basics of Linux and Unix commands, you will be able to perform a wide variety of tasks on your system. This includes tasks such as managing files and directories, installing and removing software, and managing running processes.


Enroll Now

  • Networking
  • Linux Tutorial