Basic Commands

Basic Commands

Here is a comprehensive list of basic commands for Red Hat Enterprise Linux (RHEL), covering various aspects such as file management, system information, user management, process management, network management, and package management.

File and Directory Management

  • ls: List directory contents.
  • cd [directory]: Change the current directory.
  • pwd: Print the current working directory.
  • mkdir [directory]: Create a new directory.
  • rmdir [directory]: Remove an empty directory.
  • rm [file]: Remove a file.
  • cp [source] [destination]: Copy files or directories.
  • mv [source] [destination]: Move or rename files or directories.
  • touch [file]: Create an empty file or update the timestamp of an existing file.
  • cat [file]: Display the contents of a file.
  • more [file]: View the contents of a file one screen at a time.
  • less [file]: View the contents of a file with navigation features.
  • head [file]: Display the first lines of a file.
  • tail [file]: Display the last lines of a file.
  • find [path] -name [filename]: Search for files in a directory hierarchy.
  • du -sh [directory]: Show the disk usage of a directory.
  • df -h: Display free disk space.
  • chmod [permissions] [file]: Change the file permissions.
  • chown [user]:[group] [file]: Change file ownership.

System Information

  • uname -a: Display system information.
  • hostname: Show or set the system’s hostname.
  • top: Display and manage system processes.
  • ps aux: Show the current running processes.
  • free -h: Display memory usage.
  • uptime: Show how long the system has been running.
  • dmesg: Print kernel ring buffer messages.
  • lshw: List hardware configuration.
  • lscpu: Display CPU architecture information.
  • lsblk: List information about block devices.
  • lsusb: List USB devices.
  • lspci: List PCI devices.

User Management

  • useradd [username]: Create a new user.
  • userdel [username]: Delete a user.
  • usermod [options] [username]: Modify a user account.
  • passwd [username]: Change a user’s password.
  • groupadd [groupname]: Create a new group.
  • groupdel [groupname]: Delete a group.
  • groups [username]: Show the groups a user is part of.
  • who: Show who is logged in.
  • whoami: Display the current logged-in username.
  • id [username]: Display user and group IDs.

Process Management

  • ps aux: List all running processes.
  • top: Display real-time system information and process monitoring.
  • htop: Interactive process viewer (if installed).
  • kill [PID]: Terminate a process by its PID.
  • killall [processname]: Terminate all processes with a specific name.
  • pkill [processname]: Send a signal to a process based on its name.

Network Management

  • ifconfig: Configure a network interface (deprecated, use ip).
  • ip addr: Show IP addresses and network interfaces.
  • ping [hostname or IP]: Send ICMP ECHO_REQUEST packets to network hosts.
  • traceroute [hostname or IP]: Print the route packets take to a network host.
  • netstat -tuln: Display listening ports and their status.
  • ss -tuln: Display listening sockets.
  • nslookup [hostname]: Query Internet name servers interactively.
  • dig [domain]: DNS lookup.
  • wget [url]: Download files from the web.
  • curl [url]: Transfer data from or to a server.

Package Management (YUM/DNF)

  • yum update: Update all packages to the latest version.
  • yum install [package]: Install a package.
  • yum remove [package]: Remove a package.
  • yum search [package]: Search for a package.
  • yum info [package]: Display package information.
  • yum list installed: List installed packages.
  • yum clean all: Clear the package cache.
  • dnf update: Update all packages (DNF is the next-generation package manager).
  • dnf install [package]: Install a package.
  • dnf remove [package]: Remove a package.
  • dnf search [package]: Search for a package.
  • dnf info [package]: Display package information.
  • dnf list installed: List installed packages.
  • dnf clean all: Clear the package cache.

System Monitoring and Logs

  • journalctl: Query and display messages from the journal.
  • tail -f /var/log/messages: Monitor system log file in real-time.
  • tail -f /var/log/syslog: Monitor syslog file in real-time.
  • vmstat: Report virtual memory statistics.
  • iostat: Report CPU and input/output statistics.

File Compression and Archiving

  • tar -cvf [archive.tar] [directory or files]: Create an archive.
  • tar -xvf [archive.tar]: Extract an archive.
  • gzip [file]: Compress a file using gzip.
  • gunzip [file.gz]: Decompress a gzip file.
  • zip [archive.zip] [file]: Create a zip archive.
  • unzip [archive.zip]: Extract a zip archive.

Miscellaneous

  • echo [text]: Display a line of text.
  • date: Display or set the system date and time.
  • cal: Display a calendar.
  • man [command]: Display the manual for a command.
  • alias [name]='[command]': Create an alias for a command.
  • history: Display the command history.
  • clear: Clear the terminal screen.

These commands should cover the basic tasks you’ll encounter while using Red Hat Enterprise Linux.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *