Basic commands of Linux
Today I Learned: Exploring the Basics of Linux Commands
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
pwd(Print Working Directory): This command tells you the directory you're currently in. It's your GPS in the Linux file system.
lscommand lists the files and directories in the current location. Adding options like
-aprovides more details or displays hidden files, respectively.
cd(Change Directory): Use
cdfollowed by a directory name to navigate to a different location. For example,
cd Documentstakes you into the "Documents" directory.
File and Directory Operations
touch: Create an empty file. For instance,
touch newfile.txtcreates a new text file named "newfile.txt."
mkdir(Make Directory): This command lets you create a new directory. For example,
mkdir myfolderwill create a directory named "myfolder."
rmto delete files and directories. Be cautious with this command, as it's irreversible. For directories, use
File Content Manipulation
catis for viewing and concatenating file contents. For example,
cat file.txtdisplays the contents of "file.txt."
Text Editors: Linux offers powerful text editors like
vimfor creating and editing files. For instance,
nano filename.txtopens "filename.txt" in the Nano text editor.
chown(Change Owner): You can change the ownership of files and directories with this command. For example,
chown user:group file.txtchanges the owner and group of "file.txt."
Searching and Finding
grep(Global Regular Expression Print):
grepsearches for text within files. For instance,
grep "searchterm" file.txtsearches "file.txt" for "searchterm."
findcommand locates files and directories based on various criteria. For example,
find /path -name filenamesearches for files with the specified name in the given path.
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 :
Check your present working directory.
List all the files or directories including hidden files.
Create a nested directory A/B/C/D/E
TASK 2 :
To view what's written in a file.
To change the access permissions of files.
To check which commands you have run till now.
To remove a directory/ Folder.
To create a fruits.txt file and to view the content.
Add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.
To Show only top three fruits from the file.
To Show only bottom three fruits from the file.
To create another file Colors.txt and to view the content.
Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey.
To find the difference between fruits.txt and Colors.txt file.