Photo by Markus Spiske on Unsplash
Linux Commands for Beginners
This article about Useful Linux Commands for Beginners. Here we learn commands by doing practical. Linux is widely used in the IT area. So let's start
Table of contents
Linux:
Linux is an open-source operating system. Linux is discovered by Linus Torvalds. The main component of the Linux Operating System is the ‘Linux Kernel’. In computers, many processes are running simultaneously. Each process requires hardware resources such as Storage space, Memory, Processor time, etc. To manage hardware resources, a middle layer is required. This middle layer is known as ‘Kernel’.
The kernel has 4 jobs to do:
Process Management
Memory Management
System calls and Security
Device Driver
Most important features of Linux OS:
Open Source
Security
Light Weight Infrastructure
End-to-end encryption
Multi Programming
Portable
Command Line Interface
Few Commands in Linux
‘echo’ command:
‘echo’ command is used to display content that will be specified after this command.
‘man’ command:
This command will help you to understand all other commands. Yes, you read it right. Suppose, you don’t know about the xyz command in Linux. Just type man ‘xyz’ [note: xyz may be any commands].
It will give description about the command.
output:
You can use the ‘man’ command to see all the different parameters you can use to show information in a customizable manner.
‘pwd’ command:
'pwd' command is very handy. If you feel you are lost in the huge branch of the file system, just ping pwd it will print the current folder’s path.
‘ls’ command:
ls command helps to jot down a list of files that are present in the current directory.
Suppose you want to show a file's list that are present another folder from current directory. use ls 'folder_name'.
‘cd’ command:
cd stands for change directory. If you want to go from one folder to another, you use cd command. cd command is frequently used daily. You can either specify entire path of a folder or a folder which is present in current directory.
Note: If you want to go back to the previous directory, you will use ‘cd ..’
‘mkdir’ command:
‘mkdir’ is used to create folder or directory.
‘rmdir’ command:
‘rmdir’ is used to delete folder or directory.
Note: when you use rmdir command, make sure the directory you're trying to delete, it must be empty
‘mv’ command:
‘mv’ stands for move. If you want to move one file to another directory, you can use mv command.
Note: There are other features of mv command as well, we will discuss later.
Command: ‘mv file_name directory_name’
‘cp’ command:
Using ‘cp’ command, you can copy a file.
For copying a folder and its content, you have to use ‘-r’ to recursively copy all files of a folder.
Command: ‘cp file_name new_file_name’
‘touch’ command:
‘touch’ command is used to create a blank file.
‘cat’ command:
‘cat’ command simply prints the contents of a file in the terminal. You can print more than one file by specifying the name of the existing file. With ‘cat’ command, you can use ‘>’ [i.e redirection operator], to concatenate the content of multiple files to a new file.
‘wc’ command:
To get information of a file we use ‘wc’ command.
Command: ‘wc file_name’
It will print no. of line, no. of total words and bytes of the file.
Note:
wc -l 1.txt => It will print total lines of the 1.txt file.
wc -w 1.txt => It will print total words of the 1.txt file.
wc -c 1.txt => It will print bytes of the 1.txt file.
‘find’ command:
‘find’ command is used to find folder or file with a particular match pattern.
Suppose, we want to find the files that have extension of exactly two words.
Note: this ‘find’ command is very powerful. We will discuss it later in another tutorial in details.
‘sort’ command:
‘sort’ command is used to sort the content of a file.
Note: it is case-sensitive.
Note: content.txt file is sorted first according to the capital letter and then small letter as it is case sensitive.
To ignore case sensitivity, we will use ‘-f’ in the argument
To ignore case sensitivity, we will use ‘-f’ in the argument
‘vi’ command:
Actually, vi editor which is present all Linux os. Using vi editor, you can create file and insert content into the file. It also helps to update existing file.
To create and insert text into file, follow steps:
- use command ‘vi file_name’ [If it is present, it will open, otherwise it will create and then open it]
- type ‘i’ to insert any text.
- after writing, press Esc key and type ‘:wq’ to save and exit
Now check using the cat command:
If you find this helpful, share this content on your social. Thanks for reading.
Connect with me
LinkedIn - Suraj Maity
Twitter - Suraj Maity