Basic commands of Linux

Today I Learned: Exploring the Basics of Linux Commands

Introduction

Linux is a powerful and versatile operating system known for its robust command-line interface. For newcomers, it might seem daunting, but with a willingness to learn, you can quickly master the basics of Linux commands. In this blog post, we'll embark on a journey of discovery and share what "Today I Learned" about the essential Linux commands that form the foundation of working with this operating system.

The Command Line: A World of Possibilities

The command line is where Linux truly comes to life. It's a text-based interface that allows you to interact with the system by typing commands. By learning a few basic commands, you gain the power to navigate the file system, manipulate files and directories, and manage processes.

Navigating the File System

  1. pwd (Print Working Directory): This command tells you the directory you're currently in. It's your GPS in the Linux file system.

  2. ls (List): The ls command lists the files and directories in the current location. Adding options like -l or -a provides more details or displays hidden files, respectively.

  3. cd (Change Directory): Use cd followed by a directory name to navigate to a different location. For example, cd Documents takes you into the "Documents" directory.

File and Directory Operations

  1. touch: Create an empty file. For instance, touch newfile.txt creates a new text file named "newfile.txt."

  2. mkdir (Make Directory): This command lets you create a new directory. For example, mkdir myfolder will create a directory named "myfolder."

  3. rm (Remove): Use rm to delete files and directories. Be cautious with this command, as it's irreversible. For directories, use rm -r.

File Content Manipulation

  1. cat (Concatenate): cat is for viewing and concatenating file contents. For example, cat file.txt displays the contents of "file.txt."

  2. Text Editors: Linux offers powerful text editors like nano or vim for creating and editing files. For instance, nano filename.txt opens "filename.txt" in the Nano text editor.

Managing Permissions

  1. chmod (Change Mode): This command helps you modify file permissions. For example, chmod +x script.sh makes "script.sh" executable.

  2. chown (Change Owner): You can change the ownership of files and directories with this command. For example, chown user:group file.txt changes the owner and group of "file.txt."

Searching and Finding

  1. grep (Global Regular Expression Print): grep searches for text within files. For instance, grep "searchterm" file.txt searches "file.txt" for "searchterm."

  2. find: The find command locates files and directories based on various criteria. For example, find /path -name filename searches for files with the specified name in the given path.

Wrapping Up

Learning Linux commands may seem intimidating at first, but with patience and practice, you'll find yourself becoming more proficient and confident in using the command line. These basic commands are just the tip of the iceberg; Linux offers a vast array of commands for almost any task you can think of.

"Today I Learned" about the basic Linux commands, and you too can embark on this journey of exploration. With the right commands at your fingertips, you'll discover the incredible capabilities of the Linux command-line interface and unleash your full potential in the Linux world. Happy learning!

TASKS 1 :

  1. Check your present working directory.

  2. List all the files or directories including hidden files.

  3. Create a nested directory A/B/C/D/E

TASK 2 :

  1. To view what's written in a file.

  2. To change the access permissions of files.

  3. To check which commands you have run till now.

  4. To remove a directory/ Folder.

  5. To create a fruits.txt file and to view the content.

  6. Add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.

  7. To Show only top three fruits from the file.

  8. To Show only bottom three fruits from the file.

  9. To create another file Colors.txt and to view the content.

  10. Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey.

  11. To find the difference between fruits.txt and Colors.txt file.