Linux commands serve as powerful tools for navigating the operating system, managing processes, and retrieving vital system information. Here’s a breakdown of essential commands categorized by function:
Files & Navigation
- ls: List files and directories in the current directory.
- Example:
ls -l
displays detailed file information.
- Example:
- cd: Change directory.
- Example:
cd /home/user/documents
navigates to the “documents” directory.
- Example:
- pwd: Print the current working directory.
- Example:
pwd
shows the current directory path.
- Example:
- mkdir: Create a new directory.
- Example:
mkdir new_folder
creates a directory named “new_folder”.
- Example:
- cp: Copy files and directories.
- Example:
cp file.txt destination_folder
copies “file.txt” to the “destination_folder”.
- Example:
Networking
- ping: Test network connectivity to a specific IP address.
- Example:
ping 8.8.8.8
checks connectivity to the Google DNS server.
- Example:
- ifconfig: Display network interface information.
- Example:
ifconfig
shows network interface details.
- Example:
- ssh: Securely connect to a remote machine.
- Example:
ssh username@remote_host
initiates an SSH connection.
- Example:
- netstat: Display network statistics.
- Example:
netstat -tuln
shows listening ports.
- Example:
- curl: Transfer data from or to a server.
- Example:
curl example.com
retrieves data from the specified URL.
- Example:
Processes
- ps: Display information about active processes.
- Example:
ps aux
shows all running processes.
- Example:
- kill: Terminate processes by ID or name.
- Example:
kill PID
terminates a process using its process ID.
- Example:
- top: Display real-time system information and processes.
- Example:
top
shows system statistics and running processes.
- Example:
- killall: Terminate processes by name.
- Example:
killall process_name
stops all processes with the given name.
- Example:
- nice: Run a command with modified scheduling priority.
- Example:
nice -n 10 command
runs a command with lower priority.
- Example:
System Info
- uname: Display system information.
- Example:
uname -a
shows kernel information.
- Example:
- uptime: Show system uptime and load averages.
- Example:
uptime
displays system uptime.
- Example:
- free: Display system memory usage.
- Example:
free -m
shows memory statistics in MB.
- Example:
- df: Show disk space usage.
- Example:
df -h
displays disk space in a human-readable format.
- Example:
- lscpu: Display CPU information.
- Example:
lscpu
shows detailed CPU information.
- Example:
Permissions
- chmod: Change file permissions.
- Example:
chmod 755 file.txt
grants read, write, and execute permissions to the file owner.
- Example:
- chown: Change file owner.
- Example:
chown user:group file.txt
changes the file’s owner and group.
- Example:
- chgrp: Change group ownership of files.
- Example:
chgrp new_group file.txt
changes the file’s group.
- Example:
- ls -l: List files with detailed permissions.
- Example:
ls -l file.txt
displays file permissions.
- Example:
Other Commands
- grep: Search for specific patterns in files.
- Example:
grep "search_term" file.txt
searches for “search_term” in the file.
- Example:
- tar: Create or extract tar archives.
- Example:
tar -cvf archive.tar directory
creates a tar archive.
- Example:
- find: Search for files and directories.
- Example:
find / -name file.txt
searches for “file.txt” in the root directory.
- Example:
- man: Access the manual pages for commands.
- Example:
man command_name
displays the manual for the specified command.
- Example:
- echo: Display text on the terminal.
- Example:
echo "Hello, Linux!"
prints the specified text.
- Example:
Understanding and utilizing these fundamental Linux commands can significantly enhance your efficiency and productivity within the Linux environment.