Essential Linux Commands for absolute beginners


๐๐ก๐๐ญ ๐ข๐ฌ ๐ฅ๐ข๐ง๐ฎ๐ฑ ?
Linux is a powerful open-source operating system known for its flexibility, security, and stability. It is widely used in servers, development environments, and personal computing. The Command Line Interface (CLI) plays a crucial role in Linux, offering greater control and automation over system tasks. Mastering Linux commands is essential for developers, system administrators, and IT professionals. Whether you are a beginner or an experienced user, learning Linux commands enhances productivity and efficiency. Linux is used in Cloud computing, Robotics, Cyber security tool, web servers and IOT etc etc.
๐๐ก๐ฒ ๐ฅ๐๐๐ซ๐ง ๐ฅ๐ข๐ง๐ฎ๐ฑ ๐๐จ๐ฆ๐ฆ๐๐ง๐๐ฌ ?
Learning Linux commands enhances efficiency, automation, and remote management compared to graphical interfaces. Mastering basic commands helps users troubleshoot issues, manage files, and execute tasks quickly.
๐ฐ๐ก๐๐ญ ๐ข๐ฌ ๐ญ๐๐ซ๐ฆ๐ข๐ง๐๐ฅ ?
A terminal is a command-line interface used to interact with the operating system. It runs a shell like Bash or Zsh, which interprets and executes user commands. The superuser (root) has elevated privileges, allowing system-wide changes. Using sudo grants temporary root access, so caution is essential to avoid unintended system modifications.
Here are the commands which you have to go through as a beginner:
๐๐๐ฏ๐ข๐ ๐๐ญ๐ข๐ง๐ ๐ญ๐ก๐ ๐ ๐ข๐ฅ๐ ๐๐ฒ๐ฌ๐ญ๐๐ฆ
Linux provides several commands to navigate and manipulate directories:
โ : ls -l -> Lists files in a directory with details.
โ : cd -> Changes the current directory.
โ : cd ~ -> Moves to the home directory.
โ : pwd -> Prints the current working directory.
โ : mkdir -> Creates a new directory.
โ : rmdir -> Removes an empty directory.
Advanced Directory Commands
โ : ls -lh -> Displays file sizes in a human-readable format.
โ : ls -lR -> Recursively lists all files and directories.
โ : mkdir -p ~/Documents/new-dir -> Creates a directory along with its parent directories.
๐ ๐ข๐ฅ๐ ๐๐๐ง๐๐ ๐๐ฆ๐๐ง๐ญ
Managing files efficiently is essential in Linux:
โ : touch -> Creates an empty file or updates its timestamp.
โ : rm -> Deletes a file.
โ : cp -> Copies a file.
โ : mv -> Moves or renames a file.
โ : cat -> Displays the file content.
โ : cat | more -> Displays file content page by page.
โ : head -10 -> Shows the first 10 lines of a file.
โ : tail -5 -> Shows the last 5 lines of a file.
Editing Files with vi
โ : vi โ> Opens a file in the Vi editor.
๐ : Press i to insert text.
๐ : Press ESC, then type :wq to save and exit.
๐ : Use :q! to quit without saving.
๐๐ฌ๐๐ซ ๐๐๐ง๐๐ ๐๐ฆ๐๐ง๐ญ
Managing users is crucial for system security and access control.
Adding and Managing Users
โ useradd -> Creates a new user.
โ useradd -m โ> Creates a user with a home directory.
โ passwd โ> Changes a userโs password.
Modifying and Deleting Users
โ usermod -L โ> Locks a user account.
โ usermod -U โ> Unlocks a user account.
โ userdel โ> Deletes a user.
โ userdel -r โ >Removes a user along with their home directory.
Switching Users
โ su โ> Switches to another user.
โ sudo -i โ> Switches to the root user.
User Groups
โ groupadd โ> Creates a new group.
โ usermod -G โ> Adds a user to a group.
โ groupdel โ> Deletes a group
๐ ๐ข๐ฅ๐ ๐๐๐ซ๐ฆ๐ข๐ฌ๐ฌ๐ข๐จ๐ง๐ฌ ๐๐ง๐ ๐๐ฐ๐ง๐๐ซ๐ฌ๐ก๐ข๐ฉ
Controlling access to files is essential for security.
Changing File Ownership
โ chown โ> Changes the file owner.
โ sudo chown -R โ> Recursively changes ownership.
Changing Group Ownership
โ chgrp โ> Changes the fileโs group.
โ sudo chgrp -R โ> Recursively changes group ownership.
Modifying Permissions Permissions in Linux are assigned as:
โ Read (4), Write (2), Execute (1)
Examples:
โ chmod u+x โ> Gives execute permission to the owner.
โ chmod g+x โ> Gives execute permission to the group.
โ chmod o+x โ> Gives execute permission to others.
โ chmod 755 โ> Sets full permissions for the owner and read/execute for others.
๐๐๐ญ๐ฐ๐จ๐ซ๐ค๐ข๐ง๐ ๐๐จ๐ฆ๐ฆ๐๐ง๐๐ฌ
Checking and managing network settings:
โ ip addr show / ifconfig โ> Displays network details.
โ ifconfig | grep inet โ> Shows the IP address.
โ ping google.com โ> Tests connectivity.
โ ip route โ> Displays the routing table.
โ sudo dhclient โ> Assigns a new IP addres
๐๐ข๐ฌ๐ค ๐๐ง๐ ๐๐ซ๐จ๐๐๐ฌ๐ฌ ๐๐๐ง๐๐ ๐๐ฆ๐๐ง๐ญ
Checking Disk Space
โ df -h โ> Shows disk space usage in human-readable format.
โ du -sh /var โ> Shows the size of the /var directory.
Unmounting Storage
โ umount /media/USBDRIVE โ> Unmounts a USB drive.
Managing Processes
โ ps โ> Displays running processes.
โ ps -e โ> Shows all processes.
โ top โ> Displays real-time process usage.
โ kill โ> Terminates a process by its ID.
๐๐๐๐ค๐๐ ๐ ๐๐๐ง๐๐ ๐๐ฆ๐๐ง๐ญ
Installing and removing software packages:
Debian-based Systems (Ubuntu, Debian)
โ dpkg -i <package.deb> โ> Installs a .deb package.
โ dpkg -r <package.deb> โ> Uninstalls a .deb package.
โ apt-get install โ> Installs a package.
โ apt-get remove โ>Removes a package.
Red Hat-based Systems (CentOS, Fedora)
โ rpm -i <package.rpm> โ> Installs an .rpm package.
โ rpm -e <package.rpm> โ> Uninstalls an .rpm package.
โ yum install โ> Installs a package using yum.
โ yum remove โ> Removes a package.
๐๐ง๐๐๐ซ๐ฌ๐ญ๐๐ง๐๐ข๐ง๐ ๐ฌ๐ฎ ๐ฏ๐ฌ. ๐ฌ๐ฎ๐๐จ
โ su โ> Switches users without ending the current session.
โ sudo โ> Executes a command as a different user (usually root).
โ sudo -i โ> Switches to the root user with a new session.
๐ ๐ข๐ง๐๐ฅ ๐๐ก๐จ๐ฎ๐ ๐ก๐ญ๐ฌ
Mastering Linux commands can significantly boost your efficiency in managing files, users, networks, and processes. Whether you're a beginner or an advanced user, having a solid grasp of these commands will help you navigate and control your system effectively.
If you found this article helpful plz consider to connect with me for more :
๐ก๐ญ๐ญ๐ฉ๐ฌ://๐ฐ๐ฐ๐ฐ.๐ฑ.๐๐จ๐ฆ/๐ณ๐ข๐๐ค๐๐ฒ๐๐ง๐ข๐ฑ/
Subscribe to my newsletter
Read articles from zia kayani directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
