Basic and Commonly used command in Unix.
Hello Everyone ,
In Previous Blog I have discussed about the basic concept of Unix Operating System .Today I will provide a summary of some of the common basic and advanced Unix commands along with the commonly used syntax for those commands.In next blog i will come up with some Advance command in Unix. Before starting command please see my previous blog of Unix as below for your understanding:
https://dheeraj60.blogspot.com/2020/08/basic-concept-of-unix-operating-system.html
Logging into Unix System: Once you login to the system, it will show a login prompt for the user to enter their username and password. If the user enters a valid username and password, then the system will log in the user and start a login session. After this, the user can open a terminal that runs a shell program and able to write commands.
Logging out of Unix : When the user want to end their session, they can terminate their session by logging out of the terminal or the system by using exit command.
Commonly used command in Unix :
Note : I am using putty tool to access Unix server
ls - Lists all the names of files in a particular Unix directory. If you type the ls command with no parameters or qualifiers, the command displays the files listed in your current working directory.
ls –lrt - This command will show you all the files in Unix with timestamp and also you can see the permission of file .
Below is the output in Putty for ls and ls –ltr command , I used this command in root dirctory.
ls –alrt - This command is use to show the hidden files as well in the current directories .
Below is the output in Putty.
cal 9 2019
Below is the output in putty terminal
Date command : date command show you the current date also we can show it in different format . if I want to show date in dd/mm/yy format then command will be :
date +%d/%m/%y
Below is the output in putty terminal.
banner: Prints a large banner on the standard output . Suppose I want to display Diksha oracle Training Centre through banner command then we use
$ banner Diksha Oracle Training Centre
who command: Displays the list of users currently logged in server.
Below is the output of who command in putty as of now 4 user is active.
whoami: This command will displays the user id of the currently logged in user.
$ whoami
Below is the output in putty terminal it will show you the currently logged in user only .
$ mkdir DOTC
DOTC directory will be created after this command . See the output in putty terminal.
Now we will create one file by using cat command in DOTC directory
cat command : cat command is use to see the file content and also Concatenate files and print to stdout.
Below is the command :
$ cd DOTC
$ cat > dheeraj
Welcome to Diksha oracle training Centre
To see the file we use below command
$ cat dheeraj
Note : cd command we use to go in another directory and if we want to back in before directory we use cd .. command.
Below is the output of cat command in Unix Putty terminal .
cp: cp command is mainly used to copy files in other directory . suppose I want to copy dheeraj file to /home/u255474504 from DOTC directory then we use below command .
$ cp dheeraj /home/u255474504
Below is the output in putty terminal as dheeraj file will be available in home directory.
mv command in unix : mv command is mainly used to move the file from one directory to another directory. The basic difference between mv and cp command is cp command keep the file in both directory whereas mv command basically remove files from base location and put it in another directory.
Below is the command issued in DOTC directory.
$ mv dheeraj /home/u255474504
After this command dheeraj file is moved to /home/u255474504 directory and in DOTC directory you will not able to see dheeraj file .
mv command in unix : mv command is mainly used to move the file from one directory to another directory. The basic difference between mv and cp command is cp command keep the file in both directory whereas mv command basically remove files from base location and put it in another directory.
Below is the command issued in DOTC directory.
$ mv dheeraj /home/u255474504
After this command dheeraj file is moved to /home/u255474504 directory and in DOTC directory you will not able to see dheeraj file .
Below is the output in putty terminal. See it carefully to understand.
rm: rm command use to remove files and directories
$ rm dheeraj
rmdir: rmdir used to remove a directory
$ rmdir DOTC – here it’s not worked so I use below command
$ rm –rf DOTC – rf means recursively and forcefully
I am using both the command in terminal and see the output below carefully .
Here file and directory dheeraj and DOTC both removed from the system.
Pwd : pwd command is basically use to see in which directory you are . to use this simply type pwd in command prompt.
$pwd
Output of above command is as below :
In Unix so many commands is there . In next blog I will come up with several useful command like grep , sed , find , vi editor , cronjob, process (ps command) etc . Also will come up with basic shell script so that you can able to write some shell scripts .
Please go through this blog carefully and try to practice this command as much as you can , so that in next blog I will come up with some advance command and basic shell scripts so it’s easy for you to understand . For any questions let me know .
Thanks.
Useful command for beginners !
ReplyDeleteThank you !
DeleteWell done Dheeraj
ReplyDeleteThank you Madhuraj !
Delete