Essential Linux Commands for absolute beginners

zia kayanizia kayani
5 min read

๐–๐ก๐š๐ญ ๐ข๐ฌ ๐ฅ๐ข๐ง๐ฎ๐ฑ ?

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:

  1. ๐๐š๐ฏ๐ข๐ ๐š๐ญ๐ข๐ง๐  ๐ญ๐ก๐ž ๐…๐ข๐ฅ๐ž ๐’๐ฒ๐ฌ๐ญ๐ž๐ฆ

    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.

  2. ๐…๐ข๐ฅ๐ž ๐Œ๐š๐ง๐š๐ ๐ž๐ฆ๐ž๐ง๐ญ

    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.

  3. ๐”๐ฌ๐ž๐ซ ๐Œ๐š๐ง๐š๐ ๐ž๐ฆ๐ž๐ง๐ญ

    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

  4. ๐…๐ข๐ฅ๐ž ๐๐ž๐ซ๐ฆ๐ข๐ฌ๐ฌ๐ข๐จ๐ง๐ฌ ๐š๐ง๐ ๐Ž๐ฐ๐ง๐ž๐ซ๐ฌ๐ก๐ข๐ฉ

    Controlling access to files is essential for security.

    Changing File Ownership

    โœ… chown โ€“> Changes the file owner.

    โœ… sudo chown -R โ€“> Recursively changes ownership.

  5. 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.

  6. ๐๐ž๐ญ๐ฐ๐จ๐ซ๐ค๐ข๐ง๐  ๐‚๐จ๐ฆ๐ฆ๐š๐ง๐๐ฌ

    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

  7. ๐ƒ๐ข๐ฌ๐ค ๐š๐ง๐ ๐๐ซ๐จ๐œ๐ž๐ฌ๐ฌ ๐Œ๐š๐ง๐š๐ ๐ž๐ฆ๐ž๐ง๐ญ

    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.

  8. ๐๐š๐œ๐ค๐š๐ ๐ž ๐Œ๐š๐ง๐š๐ ๐ž๐ฆ๐ž๐ง๐ญ

    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.

  9. ๐”๐ง๐๐ž๐ซ๐ฌ๐ญ๐š๐ง๐๐ข๐ง๐  ๐ฌ๐ฎ ๐ฏ๐ฌ. ๐ฌ๐ฎ๐๐จ

    โœ… 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 :

๐ก๐ญ๐ญ๐ฉ๐ฌ://๐ฐ๐ฐ๐ฐ.๐ฅ๐ข๐ง๐ค๐ž๐๐ข๐ง.๐œ๐จ๐ฆ/๐ข๐ง/๐ณ๐ข๐š-๐ค๐š๐ฒ๐š๐ง๐ข-/

๐ก๐ญ๐ญ๐ฉ๐ฌ://๐ฐ๐ฐ๐ฐ.๐ข๐ง๐ฌ๐ญ๐š๐ ๐ซ๐š๐ฆ.๐œ๐จ๐ฆ/๐ณ๐ข๐š.๐ค๐š๐ฒ๐š๐ง๐ข.๐ฑ/

๐ก๐ญ๐ญ๐ฉ๐ฌ://๐ฐ๐ฐ๐ฐ.๐ฑ.๐œ๐จ๐ฆ/๐ณ๐ข๐š๐ค๐š๐ฒ๐š๐ง๐ข๐ฑ/

๐ก๐ญ๐ญ๐ฉ๐ฌ://๐ฐ๐ฐ๐ฐ.๐Ÿ๐š๐œ๐ž๐›๐จ๐จ๐ค.๐œ๐จ๐ฆ/๐ณ๐ข๐š.๐ค๐š๐ฒ๐š๐ง๐ข.๐ฑ/

1
Subscribe to my newsletter

Read articles from zia kayani directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

zia kayani
zia kayani