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 -ldisplays detailed file information.
- Example:
- cd: Change directory.
- Example:
cd /home/user/documentsnavigates to the “documents” directory.
- Example:
- pwd: Print the current working directory.
- Example:
pwdshows the current directory path.
- Example:
- mkdir: Create a new directory.
- Example:
mkdir new_foldercreates a directory named “new_folder”.
- Example:
- cp: Copy files and directories.
- Example:
cp file.txt destination_foldercopies “file.txt” to the “destination_folder”.
- Example:
Networking
- ping: Test network connectivity to a specific IP address.
- Example:
ping 8.8.8.8checks connectivity to the Google DNS server.
- Example:
- ifconfig: Display network interface information.
- Example:
ifconfigshows network interface details.
- Example:
- ssh: Securely connect to a remote machine.
- Example:
ssh username@remote_hostinitiates an SSH connection.
- Example:
- netstat: Display network statistics.
- Example:
netstat -tulnshows listening ports.
- Example:
- curl: Transfer data from or to a server.
- Example:
curl example.comretrieves data from the specified URL.
- Example:
Processes
- ps: Display information about active processes.
- Example:
ps auxshows all running processes.
- Example:
- kill: Terminate processes by ID or name.
- Example:
kill PIDterminates a process using its process ID.
- Example:
- top: Display real-time system information and processes.
- Example:
topshows system statistics and running processes.
- Example:
- killall: Terminate processes by name.
- Example:
killall process_namestops all processes with the given name.
- Example:
- nice: Run a command with modified scheduling priority.
- Example:
nice -n 10 commandruns a command with lower priority.
- Example:
System Info
- uname: Display system information.
- Example:
uname -ashows kernel information.
- Example:
- uptime: Show system uptime and load averages.
- Example:
uptimedisplays system uptime.
- Example:
- free: Display system memory usage.
- Example:
free -mshows memory statistics in MB.
- Example:
- df: Show disk space usage.
- Example:
df -hdisplays disk space in a human-readable format.
- Example:
- lscpu: Display CPU information.
- Example:
lscpushows detailed CPU information.
- Example:
Permissions
- chmod: Change file permissions.
- Example:
chmod 755 file.txtgrants read, write, and execute permissions to the file owner.
- Example:
- chown: Change file owner.
- Example:
chown user:group file.txtchanges the file’s owner and group.
- Example:
- chgrp: Change group ownership of files.
- Example:
chgrp new_group file.txtchanges the file’s group.
- Example:
- ls -l: List files with detailed permissions.
- Example:
ls -l file.txtdisplays file permissions.
- Example:
Other Commands
- grep: Search for specific patterns in files.
- Example:
grep "search_term" file.txtsearches for “search_term” in the file.
- Example:
- tar: Create or extract tar archives.
- Example:
tar -cvf archive.tar directorycreates a tar archive.
- Example:
- find: Search for files and directories.
- Example:
find / -name file.txtsearches for “file.txt” in the root directory.
- Example:
- man: Access the manual pages for commands.
- Example:
man command_namedisplays 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.
Want to Listen to This Guide While Working?
Try Speechify — the AI voice reader that helps DevOps engineers consume technical documentation while working in the terminal.