If you’re getting started with Linux and looking for the best way to learn Basic Linux Commands with live examples, this is going to be the best article for you. Nowadays, when every second or third person has their own website, Learning Linux Commands has somewhere become a necessary task for us.
PuTTY, is nothing but software like a command prompt to execute Linux commands. It’s an open-source, entirely free windows software that you can easily install from their official website. It supports several network protocols such as SSH, SCP, Telnet, rLogin, Etc. The right way to pronounce PuTTYis ‘Patti’, and it has no official meaning.
PuTTY is just software to execute Linux Commands using a variety of protocols which doesn’t mean that you cannot execute PuTTY commands in your Command Terminal. However, there might be some limitations of command, as PuTTY is basically used to establish a secure connection between two computers using various secure protocols such as SSH and SFTP.
If you have the knowledge of basic Linux Commands, you can skip the first heading of this post and directly jump to the advanced Linux commands. If not, follow the below tutorial to learn basic Linux Commands. In this article, we’re gonna walk you through the complete list of the most popular and most used Linux commands that every beginner should see before getting into the Linux industry. So, without wasting a time, let’s dive right in!!
Linux Basic Commands
Below, I’m mentioning the list of all the basic Linux commands that would be enough to get into the Linux industry. Open your command terminal, or log into the PuTTY or any other SSH-client software if you’re a Web Hosting user.
4. mkdir & rmdir
11. nano & vi
20 Basic Linux Commands with Live Example
Following are the top 20 basic Linux Commands with Live Examples that would definitely help you start your Linux journey.
pwd: Once you open the terminal, the first command you should use is PWD. The PWD Command is used to display your current working directory.
ls: The ls command in Linux will help you to list all the content present inside your current working directory. You can also list all the hidden files in PWD with the ls -a command.
cd: The cd command in Linux is used to browse through the directory. It’s like the handle of your bike. You can go anywhere you want on your server using the cd command. Suppose you opened a Linux terminal and executed the first pwd command. It’ll show you where you are. Now, you entered the ls command to list all the directories. Now you want to move inside another directory to see what’s in it. There you can use the cd DirectoryNamecommand to browse into the directory.
mkdir/rmdir: The mkdir command in Linux is used to create directory/directories, whereas the rmdir is used to remove a directory. However, you can only remove empty directories using the rmdir command. Use the rm command to delete a directory filled with content.
rm: The rm -r command in Linux is used to remove directories containing files. If you want to delete any duplicate or unused directory from your server, simply type the rm -r DirectoryNamecommand and hit enter. Other than this, you can use the rm -rf command to forcefully delete the directory without asking any further questions. It’s like you’re entirely sure to delete that directory and don’t want any kind of confirmation.
touch: You just learned to create and remove directories in Linux. But what about the files? Well, you can use the touch command to create files. Although, you can use the same rm -rf command to remove files.
find: If the list of files and directories in your server is high, you’ll struggle to find a specific file. Luckily, Linux has provided us a command by which you can easily find any specific file or directory located in your current working directory. Type the find filename or find DirName command and hit enter. (Change filename and DirName with your custom file/directory name).
cp: The cp command in Linux is used to copy files/directories from one directory to another. Simply type cp FileNameusr/subdir/destination or typecp DirName DestinationDir.(Again, do not forget to type your own path instead of the dummy path).
mv: The mv command is used to simply rename files. Type mv filename.exe NewName.execommand, and hit the enter button to rename a file.
cat: This command is used to view the contents of a file. Simply type cat filename.extensionand hit the Enter button. However, you can only view the contents but not modify them. If you want to modify the contents of a file, then you can use the vi or nanocommand.
vi & nano: Both of the commands are used to modify the contents of a file. You can either type vi filename.php or nano filename.phpto view the contents of a file and type i to start editing the file.
df: This command will display the available & used disk space of every partition in your system. You can simply type the df and hit enter to see the result.
du: The du command can be used to track files and directories that are consuming a high amount of disk space on your server’s hard disk.
zip/unzip: To compress a file or files into a zip format, use the zip command. Whereas, you can use the unzip command to extract the zip files. Type the syntax zip filename.zip file1.php file2.php
uname: The uname command is used to display the information about the operating system your server using. You can use the uname -a command to display most of the server information such as operating system, kernel release date, hostname, processor type, version, etc.
tar: You can use the tar command to create compressed or uncompressed Archive files and also maintain and modify them. Simply hit the
Use the tar -cvf filename.tar Dir1 Dir2 Di3command and hit the enter button to compress all the directories into a tar file.
Also, usethe tar -xvf filename.tarcommand to untar/extract.
chmod: The chmod command is used to change the files/directories permissions. This command is quite sensitive. So, I’ll recommend not to use this command if you don’t have any knowledge about Linux Permissions. However, to change the permissions of a file or directory, you can use the chmod permission filename.php command. See the below image to get a clear understanding.
ping: This command is used to troubleshoot the connectivity and reachability of the domain or server. It’s usually the first diagnostic step most users take when the website or server doesn’t respond.
top: If you want to display a real-time view of all the processes running, type the top command and hit enter.
exit: The exit command is used to close and exit from the terminal.
Other Popular Linux Tips & Tricks
Here are some useful Linux shortcut keys that you should know to easy finish every task.
You can type clearand hit enter to clear the terminal window if it’s filled with commands.
If you’re editing a file using the vi command and struggling to save the file and exit from the editing section, press Esc from your keyboard, then type :wq!command, and hit the enter button to Save the file and Exit from the editing window.
You can press ( ↑ )theupper arrow button to reveal all the recent commands you’ve executed previously.
If you’re not able to reboot or power off your desktop, you can use sudo halt and sudo reboot command to power off or reboot your computer.
You can press Ctrl + Cfrom your keyboard to stop any in between. Other than this, the Ctrl + Z command is used to forcefully stop the command execution. This command could be helpful to stop several commands, and the ping command is one of them.
In some cases, you can also type qto stop the running command. For instance, you can stop the top command by pressing q from your keyboard.
The history command is used to display the history of commands you recently executed. you can typehistory 10to display 10 recent commands. The history command can display a maximum of 100 recent commands.
I hope this article helps you, if it doesn’t, you can simply hit the comment section and mention your queries. I would love to hear from you guys. And, if this helps you anyhow, Share this post with your friends & follow us on Facebook&Twitterto stay updated with any other articles.