BASIC COMMANDS OF LINUX :
1. $logname : It displays the current user name.
2. $pwd : It displays the current working directory.
3. $clear : It clear the screen.
4. $exit : To logout from the current user.
5. $date : It displays system date & time.
Sat Mar 4 04:40:10 IST 2005
6. $Who am i : It displays the current user name, terminal number, date and time at which you logged into the system.
tecno ty01 mar 4 09:30
7. $Who : To display the information about all the users who have logged into the system currently. i.e. each user login name, terminal number, date and time that the person logged in.
loginname terminal name date time
tecno1 tty01 mar 4 09:30
tecno2 tty03 mar 4 10:30
tecno2 tty06 mar 4 10:40
8. $finger : It displays complete information about all the users who are logged in.
9. $cal : It displays previous month, current month and next month calender.
10. $cal year : It display the given year calender.
e.g:- $cal 2005 = It takes year from 1 to 9999
11. $cal month year : It display the given month calender only.
$cal 3 2005 enter
12. #init : To change system run levels.
1. #init 0 : To shut down the system.
2. #init 1 : To bring the system to single user mode.
3. #init 2 : To bring the system to multi user mode with no resource shared.
4. #init 3 : To bring the system multi user mode with source shared.
5. #init 6 : Halt and reboot the system to default run level.
13. $ banner "tecno" : It prints a message in large letters.
--------------------------------------------------------------------------------------------------------------------------
CREATING FILES :
There are two commands to create files : touch and cat
1. $ Touch filename : It creates zero byte file size.
Eg :- $ touch sample
Touch does not allow you to store anything in a file. It is used to create several empty files quickly.
Eg :- $ touch file1 file2 file3 file4 file5
2. $ Cat command
Syntax
1. $ cat > filename
e.g : $ cat > sample
-------------------
---------------------
------------------------
ctrl + d ( To clase a file)
2. $ cat >> sample (To oppened data to the file)
-------------------------
---------------------------
--------------------------------
Ctrl + d
3. $ cat file1 file2 file3 > file4
This would create file4 contains contents of file1 followed by file2 and followed by that of file3.
It concatenates file1, file2, and file3 contents and redirects to file4. If file4 already contains something it woud be over written.
3. $ cat < filename or $ cat file name
Eg :- $ cat sample It displays sample file contents.
Eg :- $cat file1 file2 file3
It displays file1 contents followed by file2 then followed by file3
--------------------------------------------------------------------------------------------------------------------------
REMOVING FILES :- 1. rm command : To remove the given file.
Syntax
$rm filename
$rm sample : It removes sample file.
$rm -i filename : It asks confirmation before deleting the file.
$rm -i sample
remove sample? y - It removes sample file.
n - It won't remove
$ rm file1 file2 file3 : It removes three files.
$ rm* : It removes all files in current directory.
--------------------------------------------------------------------------------------------------------------------------
CREATING DIRECTORY :-
1. mkdir Command :-
To make directory
Syntax :
$ mkdir directory name
Eg :- mkdir devops
2. Creating multiple directories
$mkdir dir1 dir2 dir3 ..................dirn
--------------------------------------------------------------------------------------------------------------------------
Change directory :
Syntax:
$cd directory name
$cd techin
$pwd
/usr/tecno/techin
$cd .. : To change into parent directory.
$cd\ : To change to root directory.
--------------------------------------------------------------------------------------------------------------------------
Remove Directory :
1. $rmdir directoryname : To delete a directory but directory should be empty.
2. $rm -r directoryname : It removes all files and sub directories, sub directory files including directory.
--------------------------------------------------------------------------------------------------------------------------
Copy a file:-
$cp file1 file2 : This will copy the contents of file1 into a file2. If file2 is already existed it overwrites.
$cp -i file1 file2 : If file2 is already existed then it asks the confirmation.
Eg :- cp -i sample1 sample2
overwrite sample2?
--------------------------------------------------------------------------------------------------------------------------
Rename a file :
1. $mv old filename new filename : To rename the file.
--------------------------------------------------------------------------------------------------------------------------
Comparision of files :
1. $cmp file1 file2 : It compares file1 and file2. If both file contents are same number output if files are different then it displays line number and number and character location.
--------------------------------------------------------------------------------------------------------------------------
1. $logname : It displays the current user name.
2. $pwd : It displays the current working directory.
3. $clear : It clear the screen.
4. $exit : To logout from the current user.
5. $date : It displays system date & time.
Sat Mar 4 04:40:10 IST 2005
6. $Who am i : It displays the current user name, terminal number, date and time at which you logged into the system.
tecno ty01 mar 4 09:30
7. $Who : To display the information about all the users who have logged into the system currently. i.e. each user login name, terminal number, date and time that the person logged in.
loginname terminal name date time
tecno1 tty01 mar 4 09:30
tecno2 tty03 mar 4 10:30
tecno2 tty06 mar 4 10:40
8. $finger : It displays complete information about all the users who are logged in.
9. $cal : It displays previous month, current month and next month calender.
10. $cal year : It display the given year calender.
e.g:- $cal 2005 = It takes year from 1 to 9999
11. $cal month year : It display the given month calender only.
$cal 3 2005 enter
12. #init : To change system run levels.
1. #init 0 : To shut down the system.
2. #init 1 : To bring the system to single user mode.
3. #init 2 : To bring the system to multi user mode with no resource shared.
4. #init 3 : To bring the system multi user mode with source shared.
5. #init 6 : Halt and reboot the system to default run level.
13. $ banner "tecno" : It prints a message in large letters.
--------------------------------------------------------------------------------------------------------------------------
CREATING FILES :
There are two commands to create files : touch and cat
1. $ Touch filename : It creates zero byte file size.
Eg :- $ touch sample
Touch does not allow you to store anything in a file. It is used to create several empty files quickly.
Eg :- $ touch file1 file2 file3 file4 file5
2. $ Cat command
Syntax
1. $ cat > filename
e.g : $ cat > sample
-------------------
---------------------
------------------------
ctrl + d ( To clase a file)
2. $ cat >> sample (To oppened data to the file)
-------------------------
---------------------------
--------------------------------
Ctrl + d
3. $ cat file1 file2 file3 > file4
This would create file4 contains contents of file1 followed by file2 and followed by that of file3.
It concatenates file1, file2, and file3 contents and redirects to file4. If file4 already contains something it woud be over written.
3. $ cat < filename or $ cat file name
Eg :- $ cat sample It displays sample file contents.
Eg :- $cat file1 file2 file3
It displays file1 contents followed by file2 then followed by file3
--------------------------------------------------------------------------------------------------------------------------
REMOVING FILES :- 1. rm command : To remove the given file.
Syntax
$rm filename
$rm sample : It removes sample file.
$rm -i filename : It asks confirmation before deleting the file.
$rm -i sample
remove sample? y - It removes sample file.
n - It won't remove
$ rm file1 file2 file3 : It removes three files.
$ rm* : It removes all files in current directory.
--------------------------------------------------------------------------------------------------------------------------
CREATING DIRECTORY :-
1. mkdir Command :-
To make directory
Syntax :
$ mkdir directory name
Eg :- mkdir devops
2. Creating multiple directories
$mkdir dir1 dir2 dir3 ..................dirn
--------------------------------------------------------------------------------------------------------------------------
Change directory :
Syntax:
$cd directory name
$cd techin
$pwd
/usr/tecno/techin
$cd .. : To change into parent directory.
$cd\ : To change to root directory.
--------------------------------------------------------------------------------------------------------------------------
Remove Directory :
1. $rmdir directoryname : To delete a directory but directory should be empty.
2. $rm -r directoryname : It removes all files and sub directories, sub directory files including directory.
--------------------------------------------------------------------------------------------------------------------------
Copy a file:-
$cp file1 file2 : This will copy the contents of file1 into a file2. If file2 is already existed it overwrites.
$cp -i file1 file2 : If file2 is already existed then it asks the confirmation.
Eg :- cp -i sample1 sample2
overwrite sample2?
--------------------------------------------------------------------------------------------------------------------------
Rename a file :
1. $mv old filename new filename : To rename the file.
--------------------------------------------------------------------------------------------------------------------------
Comparision of files :
1. $cmp file1 file2 : It compares file1 and file2. If both file contents are same number output if files are different then it displays line number and number and character location.
--------------------------------------------------------------------------------------------------------------------------
No comments:
Post a Comment