Basic commands in Unix
In this blog I am going to discuss some basic commands in Unix. Before going to the commands let us understand the structure of UNIX system.
Structure of the UNIX system
The core of Unix is called kernel. It controls and manages everything in the system.This is the section that performs all hardware access. In the above figure we can see that on top of the hardware, kernel is present.
Above kernel lies the shell. The shell acts as an interface between the user and the kernel. This is where we write our commands. The shell accepts and interprets commands through a command line interface known as terminal.
The layer of Application lies above the shell where we have GUI applications like file explorer, dbms, etc.
As a software developer, one must be well versed with the commands that is required to perform various operations in the system.
Let us look at some basic commands :
man
- prints the working manual of the command passed as the argumentclear
- clears the terminal screenexit
- exits the terminal windowecho
- displays the string passed to the command.
Now let us look at some commands used for file manipulation :
touch
- creates a filehead
- displays the first 10 lines of a filetail
- displays the last 10 lines of a filecat
- displays the output from more than one file simultaneouslyecho
- (we have seen this in the set of basic commands) here the command helps to append content to the end of the file.nano
- opens the nano text editorgrep
- searches for a string in the given filerm
- deletes a file
Finally let us look at some commands for working with folders :
mkdir
- creates a folderpwd
- gives us the path of the current folderls
- lists the content of the current foldercd
- used to navigate to a specified foldermv
- renames the folder(file as well)rmdir
- deletes a folder
As I conclude, let me discuss one more command
rm -r
: used to delete a folder
Why to use "rm -r" if we can use "rmdir"?
rmdir deletes a folder only when it is empty, whereas rm -r deletes the folder along with sub folders and files from the specified folder.
For the above command r is a flag or option that tells to recursively delete from the specified folder. There are many other flags as well with various commands.
That's it for this blog!