MEHDI.
RETURN_TO_INDEX

Linux Commands Every Developer Should Know by Heart

4 min read
#DevOps#Linux#Terminal#Productivity

Introduction

As a developer, I have found that having a solid grasp of Linux commands is essential for efficient workflow and troubleshooting. In this article, I will cover the most important Linux commands that every developer should know by heart.

File Navigation

File navigation is a fundamental aspect of working with Linux. The following commands are used to navigate the file system:

  • pwd: prints the current working directory
  • cd: changes the current working directory
  • cd ~: takes you to your home directory
  • cd ..: moves up one directory level
  • cd -: switches between the last two directories you were in

For example, to create a new directory and navigate into it, you can use the following command:

mkdir new_dir && cd new_dir

Text Processing

Text processing is a crucial aspect of working with Linux. The following commands are used to process text:

  • grep: searches for a pattern in a file or input
  • awk: processes and transforms text
  • sed: streams editor for filtering and transforming text

For example, to search for a specific word in a file, you can use the following command:

grep 'word' file.txt

To print the first column of a CSV file, you can use the following command:

awk -F, '{print $1}' file.csv

Process Management

Process management is essential for monitoring and controlling running processes. The following commands are used to manage processes:

  • ps: displays information about running processes
  • kill: sends a signal to a process to terminate it
  • killall: sends a signal to all processes with a given name
  • bg: runs a process in the background
  • fg: brings a background process to the foreground

For example, to kill a process with a specific ID, you can use the following command:

kill 1234

Networking Basics

Networking basics are essential for configuring and troubleshooting network connections. The following commands are used to configure and troubleshoot network connections:

  • ifconfig: displays information about network interfaces
  • ip addr: displays information about network interfaces
  • ping: tests network connectivity
  • ssh: connects to a remote server

For example, to ping a website, you can use the following command:

ping google.com

SSH

SSH (Secure Shell) is a protocol used to connect to remote servers securely. The following commands are used to connect to remote servers:

  • ssh: connects to a remote server
  • scp: copies files over a secure connection
  • ssh-keygen: generates a pair of SSH keys

For example, to connect to a remote server, you can use the following command:

ssh user@remote_server

Practical One-Liners

Here are some practical one-liners that you can use in your daily work:

  • find . -name '*.txt' -exec grep 'word' {} ;: searches for a word in all text files in the current directory and its subdirectories
  • du -sh *: displays the size of all files and directories in the current directory
  • history | grep 'command': searches for a command in your command history

Practical Takeaways

In conclusion, mastering Linux commands is essential for any developer. By memorizing the commands outlined in this article, you can improve your workflow and troubleshooting skills. Some key takeaways include:

  • Use grep and awk to process text
  • Use ps and kill to manage processes
  • Use ifconfig and ip addr to configure network interfaces
  • Use ssh to connect to remote servers securely
  • Use practical one-liners to automate tasks and improve your productivity