Table of contents
As we have discussed "What is Linux?" now it's time to understand some basic Linux commands. Linux commands can be used to perform basic and advanced tasks using some one or two words commands and you can perform different operations/tasks in literally no time. In this article, we will understand the implementation of some basic Linux commands that you must know before deep diving into Linux.
Here are some basic commands you need to know
whoami: This command is like asking the system, "Who's using you?" It tells you the name of the user currently working on the system.
Here webmaster is the user in this online Linux terminal
ls: Think of it as a way to peek inside a folder. When you use "ls," the system shows you the list of directories and files within a specific directory.
Here we are first checking the present working directory using pwd and then we checking what are the files and directories/folders inside our present working directory.
cd: It's your navigation tool. If you want to go to a specific directory, just use this command. If you're deep into various folders and want to quickly return to your "home" directory, type "cd ~."
pwd: Wondering where you are in the system? This command prints out your current location, telling you which directory you're currently working in.
Here I am using the same image as you can see, I used pwd before changing the directory to know what is my present working directory and after changing my directory, I again used pwd to check my current working directory.
mkdir: Need a new folder? This command creates a directory for you.
Here I used mkdir to create a folder/directory named Learning_devops and then used ls to check the folders list inside my present working directory.
touch: Similar to "mkdir," but for files. Use "touch" to create new files within a directory.
Here we checked our present working directory using pwd and then created a file name devops.txt in our present working directory using touch command.
rm: Ready to declutter? Use "rm" to remove files. If you want to delete a whole directory and its contents, type "rm -rf xyz," where "xyz" is the directory name.
Here we created 2 files named devops.txt and linux.txt and then removed linux.txt using the rm command.
rmdir: A command to remove empty directories. A simple way to keep your system organized.
Remember if your directory contains any file, then it will throw an error that it contains a particular file, and this particular directory can not be deleted.
cat: A quick way to peek inside a file. Just use "cat" followed by the filename to see its contents right in the terminal.
First, we used the echo command to write the message inside our file using this syntax: echo "type your message" | cat > filename
and then we used the cat command to view the content of the fileClear: Sometimes the terminal screen gets messy. Use "clear" to tidy things up.
ps: Curious about what's happening on your system? Use "ps" to check the active processes in the terminal.
echo: Want the system to say something? Use "echo" to print a message right in the terminal.
whereis: Trying to find something? Use "whereis" to know the location of a file or directory.
With these fundamental commands at your disposal, you're well on your way to becoming a Linux command-line pro. The beauty of these simple instructions lies in their ability to empower you with the agility and efficiency needed for effective Linux exploration. Let's dive into the details of each command and discover how they can enhance your Linux experience.