# Must-Know Linux Commands

# **Introduction**

Linux is the backbone of modern development and operations. Whether you're managing servers, working with containers, or automating tasks, these fundamental commands will supercharge your terminal workflow. Let’s dive into the most critical commands every tech professional should master!

---

### **1\. View Detailed File/Folder Info**

```bash
ls -l
ls -ltr
```

*(Add* `-h` for human-readable sizes)

---

### **2\. Search for a Word in a File**

```bash
grep "term" filename
```

*(Use* `-r` for recursive directory searches)

---

### **3\. Delete Directory & Contents**

```bash
rm -rf directory_name
```

---

### **4\. Delete a File**

```bash
rm filename
```

---

### **5\. Create a File**

```bash
touch newfile.txt
```

---

### **6\. Navigate Directories**

```bash
cd /path/to/directory
```

---

### **9\. Move/Rename Directories**

```bash
mv old_dir new_dir
```

---

### **10\. Move Files**

```bash
mv file.txt /target//
```

---

11. ### Check previous used commands
    

ctrl + r (each time you press r you get your previous used command)

---

12. ### Update/Upgrade System
    

```bash
sudo apt update #update the package list to ensure latest information on available packages
sudo apt upgrade #upgrade all installed packages to their latest versions
```

13. ### Refresh package list
    

```bash
sudo apt-get update
```

### **When Should You Use** `sudo apt-get update`?

* **Before Installing New Software**:  
    Always run `sudo apt-get update` before installing new software to ensure you're installing the latest version available.
    
* **Before Upgrading Installed Packages**:  
    Run it before using `sudo apt-get upgrade` or `sudo apt-get dist-upgrade` to ensure your system knows about the latest updates.
    
* **After Adding New Repositories**:  
    If you add a new repository to your system, run this command to refresh the package list and include packages from the new repository.
    

13. ## Install .deb package
    

```bash
sudo apt install ./package-name.deb #./ is mendetory
```

13. ## Extract .tar Package
    

```bash
tar -xf filename.tar
tar -xf filename.tar -C /path/to/directory # to the specific directory
```

14. ## Install all available .deb packages in directory
    

```bash
sudo dpkg -i *.deb # user where all of your .deb package 
sudo apt-get install -f # use if any dependency problem occured
```

Let me know if you'd like to expand any section or add specific use cases! 🐧
