Linux Shell Commands - Part 1


Hello Everyone, In this post I will be discussing the Shell commands, So starting with basic, lets see how to open applications and write a text file from the console.



To open up an application, you need to type the name of the application,

Ex:
root@bt:~# gedit

This will open up the Text Editor, there are other text editors as well, like Kate, Geany, To install them
you need to type the package manager name, like

apt-get install <name> (For Ubuntu, backtrack)

For RHEL, CentOS, yum install <name>

While opening up an application simply typing the name of the application, will lock the terminal, and untill you close the application, you cannot work in the same terminal. Hence To Overcome this, you can use the '&' symbol to make the process run as background.

Ex:
root@bt:~# gedit&

This time, the editor will open and terminal will not be locked. But this opens an untitled gedit.

To open an editor with name, you need to type the name, like below:

Ex:
root@bt:~# gedit computerkorner.txt&

This will open up the gedit text editor, with name computerkorner, and since we appended the '&' symbol, we can also use the terminal.

To Quickly use a comment line in Shell you have to start with '#' symbol, which means, anything following the # symbol is to be ignored and not to be interpreted as command or anything.

Ex:
root@bt:~# # This is a comment Line, foo spam blah blah, lets see what happens if i start without a '#' symbol

root@bt:~# This is a comment Line, foo spam blah blah, lets see what happens if i start without a '#' symbol

This: command not found

root@bt:~#

Sometimes, to quickly write a few lines to a text editor. you can directly use the console to write and save with the 'cat' command and redirection symbol.

Ex:
root@bt:~# cat > ckorner.txt

Hi this is just to show the usage of 'cat' command

I will use ctrl+Z to exit

^Z
[2]+  Stopped                 cat > ckorner.txt
root@bt:~#

root@bt:~# # To quickly view a text file from terminal, you can use the same 'cat' command without redirection
root@bt:~# cat ckorner.txt


Hi this is just to show the usage of 'cat' command

I will use ctrl+Z to exit
root@bt:~#
root@bt
:~
# cd Ckorner/

root@bt
:~/Ckorner
# #Okay so far we have seen some basic usage of 'cat' command, lets see what more can we do
root@bt:~/Ckorner# cat > file1.txt

This is file number 1 created

^Z
[3]+  Stopped                 cat > file1.txt
root@bt:~/Ckorner# cat > file2.txt

This is File Number 2 created

^Z
[4]+  Stopped                 cat > file2.txt
root@bt:~/Ckorner# # Now lets see how can we dump the contents of both files to Konsole as well as to a new file
root@bt:~/Ckorner# # Next command shows dumping the contents of both files to another file
root@bt:~/Ckorner# cat file1.txt file2.txt > newfile3.txt
root@bt:~/Ckorner# cat newfile3.txt

This is file number 1 created


This is File Number 2 created
root@bt:~/Ckorner# # Next Command shows dumping to STDOUT
root@bt:~/Ckorner# cat file1.txt file2.txt

This is file number 1 created


This is File Number 2 created
root@bt:~/Ckorner# cat file1.txt

This is file number 1 created
root@bt:~/Ckorner# cat file2.txt

This is File Number 2 created

root@bt:~/Ckorner# # To check more about the 'cat' command you can type 'man cat', which will open up the manual for the cat command.

Thats All for this post, will be posting more fun stuff, Hope you liked it, stay tuned.

Thanks.

Feel Free To Leave A Comment
If Our Article has Helped You, Support Us By Making A Small Contribution, Thank You!


0 comments: