Guide to Linux and Why You Should Switch to It

Guide to Linux and Why You Should Switch to It

Β·

7 min read

Hello Everyone πŸ‘‹ !
I switched to Linux only a year ago, and my productivity has skyrocketed. You should too if you haven't already.
I used Windows for more than 2 years when I was exploring tech, and it became necessary for me to switch to Linux to set up cloud-native projects for open-source contributions, and the results have been amazing.

Why should you switch to linux ?

- Literally just one command to install and delete applications. (No setup menu and no menu which asks for survey after you uninstall a project :p)
- Extremely powerful terminal. (you can even erase entire system with it) - One command to upgrade stuff (No continuous reboots)
- Extremely Fast because less bloat - Widely recognized commands which you can find getting utilized in various Open-source projects, youtube tutorials

Linux has been the primary choice for DevOps/SysAdmins because it is the most widely adopted OS, being mainstream in server environments, scripting, automation, and reliable integration with cloud-native environments and containerization such as Kubernetes and Docker.

Linux is the fundamental skill to master before diving deep into more complex technologies like Kubernetes. It is also very helpful for software engineering tasks. Linux provides much better ease and clarity while performing tests and running load-intensive computations. You can easily kill processes, restart applications and services, and change file content simply via the terminal.

I personally use Ubuntu as my primary choice of Linux distro, and you can choose based on your preference. There are many other popular choices such as β†’

  • CentOS

  • Kali Linux

  • Linux Mint

  • Arch linux

Few notes β†’
- Learn Vim and nano editors. it enables ability to change file content through command line and saves a lot of time - Understand wildcards in linux. it is basically asterik (*) which can be used to represent any value with same it’s same prefix or suffix Usage examples :

  • ls * β†’ List all files and directories in the current directory.

  • ls *.txt β†’ List all files ending with .txt.

  • rm hello* β†’ Remove all files starting with hello. let it be hello.txt, hello.zip or hello.cpp

Navigating Directories Through Command Line β†’

There are times when you need to enter a subdirectory or move out of it. Here's how to do it:

  • A single dot (.) represents the current directory in Linux.

    • cd . β†’ Stays in the same directory.
  • Double dots (..) represent one level up from the current directory.

    • cd .. β†’ Moves one directory up.

    • cd ../.. β†’ Moves two directories up.

  • ../ is used to move out of a directory while staying in the command.

    • ls ../ β†’ Lists files in the parent directory.

    • mv file.txt ../ β†’ Moves file.txt to the parent directory.

  • Tilde (~) represents the home directory of the current user.

    • cd ~ β†’ Moves directly to the home directory.

    • cd ~/Documents β†’ Moves to the Documents folder inside the home directory.

  • Hyphen (-) represents the previous directory you were in.

    • cd - β†’ Switches back to the last directory you visited.

Note - You can directly change paths if you provide the absolute path. For example β†’
you are in /usr/bin/ path and you want to jump to $USER directory which is present inside /home directory, you can simply do a cd /home/$USER to reach there. you can also run any script directly like this and much more.

Important note : To understand anything in depth, please always refer to Official documentation/Man pages. They are always the best source of information and each command have a lot of options/flags which you can find in the official documentation.

1. File & Directory Management

These commands help navigate, create, move, and delete files or directories.

  1. ls – List files and directories
    Usage: ls [options] [directory]

    • ls -l β†’ Long format (detailed list)

    • ls -a β†’ Show hidden files

    • ls -lh β†’ Human-readable file sizes

  2. pwd – Print current working directory
    Usage: pwd

    • Shows the full absolute path of the current directory
  3. cd – Change directory
    Usage: cd [directory]

    • cd /home/user/Documents β†’ Move to Documents

    • cd .. β†’ Move one level up

  4. mkdir – Create a new directory
    Usage: mkdir [directory_name]

    • mkdir new_folder β†’ Creates new_folder
  5. rmdir – Remove an empty directory
    Usage: rmdir [directory_name]

    • rmdir old_folder β†’ Deletes old_folder if empty
  6. rm – Remove files and directories
    Usage: rm [options] [file/directory]

    • rm file.txt β†’ Deletes file.txt

    • rm -r folder/ β†’ Deletes folder and its contents

    • rm -rf folder/ β†’ Force delete without confirmation

  7. cp – Copy files and directories
    Usage: cp [options] [source] [destination]

    • cp file.txt /home/user/ β†’ Copy file.txt to /home/user/

    • cp -r folder1 folder2 β†’ Copy folder1 and all its contents to folder2

  8. mv – Move or rename files and directories
    Usage: mv [source] [destination]

    • mv file.txt /home/user/ β†’ Move file.txt to /home/user/

    • mv oldname.txt newname.txt β†’ Rename a file

  9. find – Search for files and directories. You can find many flags in documentation
    Usage: find [directory] -name [filename]

    • find /home -name file.txt β†’ Search for file.txt in /home

    • find /home -type f -name file.txt β†’ File specified Search for file.txt in /home

  10. file - The file command in Linux is used to determine the type of a file.

    Usage: file [options] [filename]

    • file document.txt β†’ This tells us that document.txt is a plain text file

    • file * β†’ Identify the type of all files in a directory

2. File Operations

Used for reading, editing, comparing, and managing files.

  1. touch – Create an empty file
    Usage: touch [filename]

    • touch newfile.txt β†’ Creates newfile.txt
  2. cat – Display the content of a file
    Usage: cat [filename]

    • cat file.txt β†’ Show content of file.txt
  3. more – View file content page by page
    Usage: more [filename]

    • Use SPACE to scroll down
  4. less – Scroll through a file (better than more)
    Usage: less [filename]

    • Use arrow keys to navigate
  5. head – Show first few lines of a file
    Usage: head -n [number] [filename]

    • head -5 file.txt β†’ Show first 5 lines
  6. tail – Show last few lines of a file
    Usage: tail -n [number] [filename]

    • tail -10 file.txt β†’ Show last 10 lines
  7. nano – Edit a file in a simple text editor
    Usage: nano [filename]

    • Use CTRL + X to exit
  8. vi / vim – Advanced text editor
    Usage: vi [filename]

    • Press i to enter insert mode

    • Press ESC, type :wq to save and exit

  9. grep – Search for a pattern inside a file
    Usage: grep [pattern] [filename]

    • grep "error" logfile.txt β†’ Find "error" in logfile.txt
  10. diff – Compare two files
    Usage: diff [file1] [file2]

    • diff file1.txt file2.txt β†’ Show differences

3. File Permissions & Ownership

Manage read, write, and execute permissions.

  1. chmod – Change file permissions
    Usage: chmod [permissions] [file]

    • chmod 755 script.sh β†’ Set executable permissions
  2. chown – Change file ownership
    Usage: chown [user]:[group] [file]

    • chown user1 file.txt β†’ Change owner to user1
  3. chgrp – Change group ownership
    Usage: chgrp [group] [file]

    • chgrp staff file.txt β†’ Assign file to staff group

4. Process Management

Monitor and control running processes.

  1. ps – Show active processes
    Usage: ps aux

    • Lists all running processes
  2. top – Real-time process monitoring
    Usage: top

    • Displays real-time system stats
  3. htop – Interactive process viewer
    Usage: htop (Requires installation)

    • More advanced than top
  4. kill – Terminate a process
    Usage: kill [PID]

    • kill 1234 β†’ Kill process with PID 1234
  5. pkill – Kill process by name
    Usage: pkill [process_name]

    • pkill firefox β†’ Kill all Firefox processes

5. Networking Commands

Manage network settings and connections.

  1. ip a – Show IP addresses

  2. ping – Test network connectivity
    Usage: ping [website]

  3. netstat -tulnp – Show open ports

  4. curl – Transfer data from a URL
    Usage: curl [flags] [URL]

  5. wget – Download files
    Usage: wget [URL]

6. System Monitoring & Information

View system details and performance.

  1. free -h – Show ram usage

  2. whoami – Display current user

  3. uname -a – Show system information

  4. df -h – Show disk usage

  5. du [options] [directory] – Show directory size

7. Package Management

Install, update, and remove software.

  1. apt install [package] – Install a package (Debian/Ubuntu)

  2. yum install [package] – Install a package (RHEL/CentOS)

  3. zypper install [package] - Install a package (OpenSUSE)

That's it from my side. Please leave comments if you have any doubts, and I will answer them. Subscribe to my newsletter !

Connect with me on LinkedIn | GitHub.

Thanks for reading :)

Β