The Ultimate Guide To Essential Linux Commands For Beginners

A Comprehensive Guide to Linux Development

The Ultimate Guide To Essential Linux Commands For Beginners

Linux is a powerful and widely used operating system that serves as the foundation for many applications, servers, and development environments. Whether you’re new to Linux or an aspiring Linux developer, having a good grasp of essential Linux commands is crucial. In this guide, we’ll explore a list of general Linux commands and networking Linux commands, providing examples and code snippets from basic to advanced levels. By mastering these commands, you’ll gain the confidence to navigate the Linux ecosystem and accelerate your journey in Linux development.

Windows Vs Linux

In order to start with Linux, we need to have a strong hold on the usage of Linux Commands which are the Superpowers () to withhold the strength of Linux. (Basics are the foundation for any Operating System).

If you are a Windows user, here are the steps to install Linux in your Windows machine to unleash the power of Linux.
To set up a Linux environment on your Windows machine, you can utilize a virtualization tool like Oracle VM VirtualBox or the Windows Subsystem for Linux (WSL) feature. Here are the steps to install and set up Linux for basic Linux development and Linux networking development using both methods:
Note: I Use method 2

Method 1: VirtualBox

  1. Download and install Oracle VM VirtualBox from the official website (https://www.virtualbox.org/).

  2. Choose a Linux distribution to install as a virtual machine, such as Ubuntu, CentOS, or Fedora. Download the ISO file for your chosen distribution.

  3. Open VirtualBox and click on “New” to create a new virtual machine.

  4. Give your virtual machine a name and select the Linux distribution and version you downloaded.

  5. Allocate memory (RAM) to the virtual machine. It is recommended to allocate at least 1GB for a basic Linux environment.

  6. Create a virtual hard disk for the virtual machine. Select “Create a virtual hard disk now” and choose the file type and size for the disk.

  7. Once the virtual machine is created, select it from the VirtualBox Manager and click on “Settings”.

  8. In the settings, configure the network adapter to suit your networking requirements, such as NAT or Bridged Adapter.

  9. Start the virtual machine and follow the installation wizard to install the Linux distribution you selected.

  10. Once the installation is complete, you will have a Linux environment running on your Windows machine using VirtualBox. Install additional packages and tools as needed for Linux development and networking.

Method 2: Windows Subsystem for Linux (WSL)

  1. Enable WSL on your Windows machine by following Microsoft’s official documentation: https://docs.microsoft.com/en-us/windows/wsl/install-win10.

  2. Open the Microsoft Store on your Windows machine and search for the Linux distribution you want to install, such as Ubuntu, Debian, or Kali Linux. Choose the desired distribution and click “Install”.

  3. Once the installation is complete, launch the Linux distribution from the Start menu.

  4. Set up a username and password for the Linux environment.

  5. Update the package repositories by running the command sudo apt update.

  6. Install additional packages and tools as needed for Linux development and networking using the package manager for your chosen Linux distribution (e.g., apt for Debian-based distributions).

  7. You can access your Windows files within the Linux environment by navigating to the /mnt directory.

Basic Linux Commands :

  1.  ls : 
     Lists all files and directories in the present working directory.
    
  2.  ls -R : Lists files in sub-directories as well.
    
  3.  ls -a : Lists hidden files as well.
    
  4.  ls -al : 
     Lists files and directories with detailed information 
     like permissions, size, owner, etc.
    
  5.  cd or cd ~ : Navigate to HOME directory.
    
  6.  cd .. : Move one level up.
    
  7.  cd dir_Name : To change to a particular directory.
    
  8.  cd / : Move to the root directory.
    
  9.  cat > filename : Create a new file.
    
  10. cat filename : Displays the file content.
    
  11. cat file1 file2 > file3 : 
    Joins two files (file1, file2) and stores the output 
    in a new file (file3).
    
  12. mv file “new file path” : Moves the files to the new location.
    
  13. mv filename new_file_name : Renames the file to a new filename.
    
  14. ***sudo : 
    Allows regular users to run programs with the 
    security privileges of the superuser or root.
    
  15. rm filename : Removes a file.
    
  16. mv : Renames a directory.
    
  17. mkdir directoryname : Creates a new directory in the present 
    working directory or a at the specified path.
    
  18. rmdir : Deletes a directory.
    
  19. grep : Search for patterns in files.
    
  20. chmod : Change file permissions.
    

Bonus :

man : Gives help information on a command.

history: Gives a list of all past commands typed in the current terminal session.

clear: Clears the terminal.

The above are the commands which any Linux user needs to know in-order to use the Linux machine and to unlock its full potential using command-line .It also helps the user/developer to increase their velocity/productivity.

Linux user who is new to Linux networking, there are several important networking commands that you should learn. These commands will help you troubleshoot network issues, manage network configurations, and interact with network services. Here is a list of essential Linux networking commands for beginners with examples.

Linux Networking

ifconfig : Display or configure network interfaces.

ifconfig

ping : Send ICMP Echo Request to a network host to check connectivity.

ping google.com

netstat : Display network statistics and active connections.

netstat -a

nslookup : Query DNS servers for DNS-related information.

nslookup google.com

wget : Download files from the web.

wget example.com/file.txt

ssh : Secure shell remote login.

ssh username@hostname

scp : Securely copy files between hosts.

scp file.txt username@hostname:/path/to/destination

curl : Transfer data to or from a server.

curl example.com/api/data

ip : Show or manipulate routing, devices, policy routing, and tunnels.

ip addr show

traceroute : Print the route packets take to a network host.

traceroute google.com

iptables : Configure firewall rules.

iptables -A INPUT -p tcp --dport 80 -j ACCEPT

route : Show or manipulate the IP routing table.

route -n

ifup / ifdown : Enable or disable a network interface.

sudo ifup eth0 (or) sudo ifdown eth0

dig : Query DNS servers for DNS-related information.

dig google.com

host : DNS lookup utility.

host google.com

iwconfig : Configure wireless network interface parameters.

iwconfig wlan0

ss : Socket statistics.

ss -tuln

nmcli : Command-line tool for controlling NetworkManager.

nmcli connection show

mtr : Network diagnostic tool that combines ping and traceroute.

mtr google.com

Importance of the the above Networking linux commands :

  1. Troubleshooting: Networking commands help you diagnose and troubleshoot network-related issues. You can check connectivity, test network services, and identify misconfigurations.

  2. Network Configuration: Linux networking commands allow you to configure network interfaces, set IP addresses, manage routes, and manipulate firewall rules. This is crucial for setting up and managing network connections.

  3. Server Management: As a developer, you might need to remotely access servers via SSH, transfer files securely using SCP, or interact with network services using tools like curl or wget.

  4. Automation and Scripting: Understanding Linux networking commands enables you to automate network-related tasks, write scripts, and build tools that interact with network services and devices.

By learning and mastering these Linux networking commands, you’ll have the foundation to effectively manage network configurations, troubleshoot issues, and interact with network services, ultimately enhancing your abilities as a Linux developer.

Conclusion :

Mastering Linux commands is an essential skill for any Linux developer. In this blog, I’ve covered a list of general Linux commands and networking Linux commands, providing examples and code snippets to help beginners understand and practice these commands. By familiarizing yourself with these commands and exploring the recommended resources, you’ll gain confidence in navigating Linux environments and take your Linux development skills to the next level. So, start exploring the vast Linux ecosystem and unlock its full potential for your development journey.

Note :

I would like to thank Mr. Mohith Kota (GATE AIR 377 ECE 2023) for asking me to write a blogpost on Linux which also helped me in revising me mu Linux concepts and have hands-on once again in Linux . Hope this helps you Mohith and let me know how you feel about this blog.

Did you find this article valuable?

Support Komal Vardhan Lolugu by becoming a sponsor. Any amount is appreciated!