Useful Linux Commands
Srijan Kumar

Srijan Kumar @srijan-xi

About: Tech Enthusiast | AI & Cybersecurity | Developer

Location:
Punjab
Joined:
Nov 24, 2023

Useful Linux Commands

Publish Date: Mar 31
0 0

Linux is a powerful operating system widely used for servers, desktops, and embedded systems. Mastering Linux commands can significantly enhance your productivity and efficiency. This article presents a curated list of useful Linux commands categorized by their purpose, making it easier for you to find what you need.

File and Directory Management

Basic Commands

ls: Lists files and directories in the current directory.

pwd: Displays the current working directory.

cd [directory]: Changes to the specified directory. Use cd .. to go up one level.

mkdir [directory_name]: Creates a new directory with the specified name.

rmdir [directory_name]: Removes an empty directory.

rm [file_name]: Deletes the specified file (use with caution).

cp [source] [destination]: Copies files or directories from source to destination.

mv [source] [destination]: Moves or renames files and directories.

touch [file_name]: Creates an empty file or updates the timestamp of an existing file.
Enter fullscreen mode Exit fullscreen mode

User and Permission Management

User Management
whoami: Displays the username of the currently logged-in user.

who: Shows a list of logged-in users along with their login times.

su [username]: Switches to another user account (requires password).

sudo [command]: Executes commands with superuser privileges, allowing limited administrative tasks.

Permission Management
passwd [username]: Changes the password for the specified user.

chown [owner]:[group] [file_name]: Changes the ownership of a file or directory.

chmod [permissions] [file_name]: Modifies file permissions (e.g., chmod 755 file.txt).
Enter fullscreen mode Exit fullscreen mode

System Monitoring and Management
Monitoring system performance is vital for maintaining optimal operation. Here are some useful commands:

Process Management
ps aux: Displays detailed information about all running processes.

top: Provides a real-time view of system resource usage, including CPU and memory consumption.

kill [PID] / killall [process_name]: Terminates processes by their process ID or name.

Disk Usage
df -h: Displays disk space usage of all mounted file systems in a human-readable format.

du -sh [directory_name]: Shows the total disk usage of a specified directory.
Enter fullscreen mode Exit fullscreen mode

Networking
Networking commands are essential for troubleshooting connectivity issues and managing network configurations. Here are some important commands:

Network Diagnostics
ping [hostname/IP_address]: Tests network connectivity with a specified host.

traceroute [hostname/IP_address]: Traces the route packets take to reach a host, showing each hop along the way.

**dig [domain_name]: Queries DNS servers for domain information, providing details about IP addresses associated with domains.
Enter fullscreen mode Exit fullscreen mode

`Miscellaneous Commands
Here are additional commands that can enhance your command-line experience:

General Commands
echo "text": Prints text or variables to the terminal or redirects output to a file (e.g., echo "Hello World" > hello.txt)

**clear: Clears the terminal screen for better visibility.

**history: Displays previously executed commands in the terminal, allowing you to recall them easily.

Alias/Unalias Commands

Alias Example: alias ll='ls -la': Creates a shortcut for frequently used commands.

Unalias Example: unalias ll: Removes an alias.`

Comments 0 total

    Add comment