![]() |
Linux Basic Commands For Beginners by KnowldgeBro |
Linux is an open source kernel designed and developed by Linus Torvalds in year 1991. There are many organisation started using Linux kernel and developed their own operating system as free or commercial licences. All the distribution that underlying implementation is Linux kernel has almost similar commands.
In this post today we are going discuss some of the commands that a system administrator using day to day in their corporate life. This basic commands are not only for the person who is working as Linux administration, it is also for the students who are preparing for interview to get in to Linux administration. So without wasting our too much time on background let's get started and see the magic of some commands here with brief explanation and real time example.
In the first section of basic commands we will catch up with How To Create file using Commands in Linux it is purely for beginners.
Creating a file in Linux
CAT COMMAND
Cat is a Linux command that is used to create ,append and display contents of a file on terminal.
Cat command to create a file with some content.
# cat > filename.txt
Hello world, welcome to knowldgebro.blogspot.com
ctrl+d(to save the file content and close the file)
Hello world, welcome to knowldgebro.blogspot.com
ctrl+d(to save the file content and close the file)
Display the content of filename.txt using cat Command.
#cat filename.txt
Hello world, welcome to knowldgebro.blogspot.com
#cat filename.txt
Hello world, welcome to knowldgebro.blogspot.com
How to append or add data to the existing file using cat command.
# cat >> filename.txt
Welcome to Linux Basic commands tutorial.
Ctrl+d
# cat >> filename.txt
Welcome to Linux Basic commands tutorial.
Ctrl+d
To display the all content of filename.txt file use the cat command separate with file name for example
# cat filename.txt
Hello world, welcome to knowldgebro.blogspot.com
Welcome to Linux Basic commands tutorial
# cat filename.txt
Hello world, welcome to knowldgebro.blogspot.com
Welcome to Linux Basic commands tutorial
CTRL+D
Essential : There is a hack for the cat command, some people might say, we can not create multiple files with cat command merely it is indeed possible but, not recommended in industry. So let's check out this hack just to get some extra knowledge.
# cat >file1 > file2 > file3
Welcome to the Linux Basic commands tutorial.
Note: In this hack we have written some content in the file but, the content will be not save in all the three files. look, the beauty of this command is when we create multiple files with cat then our cursor will be there in the last file i.e f3 and this is the reason whatever content we will write, redeemed in the last file or in our case f3 file.
TOUCH COMMAND:
Touch command is specially designed to create empty file as well as multiple file at single shot. The touch command takes variable arguments and able to create more that thousands of file in a single command without using any script. Touch command is not used to write or append data into file. once you created a file using Touch then, we can use some editor to write data into the file likewise VI, VIM, CAT, NANO and more.
Lets have some example with Touch command.
# touch f1
Note: This command will create a single file containing ZERO bytes of data.
#touch f1 f2 f3
Note: This command will create three file labeled with f1, f2 and f3 and the file size will be ZERO bytes each.
Now my obligation is to create one thousand of file in single command, OK it's not a big deal with TOUCH command.
# touch f1{2...1000}
This command will create one thousand file and each file size will having zero bytes in memory.
VI and VIM Command
Now we will look at some most significant tools for creating files and and adding, updating, modification data to a file. merely we will not discuss much about VI, VIM in this post, we will just see the creation command of a file.
How to Create a File using VI command.
# vi filename.txt
Note: It will open an stream editor where we can write, edit and modify the previous content.
How to Create a File using VIM command.
# vim filename.txt
Note: It will open an stream editor where we can write, edit and modify the previous content. There are some sort of difference in VI and VIM editor that we will discuss in abstracted post.
HISTORY COMMAND
As we know, whatever command we are executing is going to store somewhere. And now we want to see that how many command we have executed to the terminal. To come up with this difficulty, we have a command called HISTORY. History command is used to list all the executed command over the terminal.
# history
It will list all the executed command. if you cant to play with history the i will recommend you to go with manual page of HISTORY and learn some customization.
OK geeks, That's all for this post. Thanks for reaching out to this post. I am your geeky sunny.
Notice: Hi readers we are planning publish your content to our BLOG. If you have something interesting about technology and you want to share please mail your content with your details my email id is www.sunny.gov@gmail.com and helps us to make a large community.
good post
ReplyDelete