Published on

Basic Terminal Commands: kill, ping, uname, and passwd

Authors
  • avatar
    Name
    Hieu Cao
    Twitter

Introduction

Linux provides a wide range of commands for managing processes, diagnosing network issues, gathering system information, and managing user accounts. This article introduces four fundamental commands—kill, ping, uname, and passwd—with practical examples to help you get started.


The kill Command: Managing Processes

The kill command is used to terminate processes by sending specific signals.

Syntax

kill [signal] PID

Common Use Cases

  1. List running processes

    ps aux
    
    • Use this to find the process ID (PID).
  2. Terminate a process

    kill 1234
    
    • Sends the default SIGTERM signal to terminate the process with PID 1234.
  3. Forcefully terminate a process

    kill -9 1234
    
    • Sends the SIGKILL signal to forcefully stop the process.

The ping Command: Network Diagnostics

The ping command checks the reachability of a network host and measures round-trip time.

Syntax

ping [options] destination

Common Use Cases

  1. Ping a website

    ping google.com
    
    • Sends ICMP packets to check connectivity with google.com.
  2. Set the number of packets

    ping -c 5 google.com
    
    • Sends exactly 5 ICMP packets.
  3. Adjust packet size

    ping -s 64 google.com
    
    • Sends packets of size 64 bytes.

The uname Command: System Information

The uname command displays system information such as the operating system, kernel version, and machine hardware.

Syntax

uname [options]

Common Use Cases

  1. Display basic system information

    uname
    
    • Shows the kernel name.
  2. Show detailed system information

    uname -a
    
    • Displays all available information, including kernel version, hostname, and architecture.
  3. Check the system architecture

    uname -m
    
    • Outputs the machine hardware name (e.g., x86_64).

The passwd Command: Password Management

The passwd command allows users to change their passwords or administrators to manage passwords for other users.

Syntax

passwd [options] [username]

Common Use Cases

  1. Change your own password

    passwd
    
    • Prompts you to enter and confirm a new password.
  2. Change another user’s password (as root)

    sudo passwd username
    
    • Allows an administrator to update the password for username.
  3. Lock or unlock a user account

    • Lock an account:
      sudo passwd -l username
      
    • Unlock an account:
      sudo passwd -u username
      

Practical Example

Combine these commands in a workflow:

  1. Kill an unresponsive process

    ps aux | grep app
    kill -9 5678
    
  2. Ping a server to check network connectivity

    ping -c 4 example.com
    
  3. View system details

    uname -a
    
  4. Update your password

    passwd
    

Conclusion

The kill, ping, uname, and passwd commands are essential for process management, network diagnostics, system identification, and user security. Regular practice with these commands will enhance your efficiency and confidence in navigating the Linux terminal.