Linux Basic Commands

Linux Basic Commands :- Rules For Commands In LINUX
Linux Basic Commands
# Case Sensitive (Lower Case by default).
# Always use single space between objects (Commands, Options, Arguments).
# Always use - or - - before any option.

Example :-
[root@Localhost~]# cmd -a arg
[root@Localhost~]# cmd --for one word like help
[root@Localhost~]# cmd - -help

Press Ctrl + Alt + f1 is GUI Mode in RHEL6
Press Ctrl + Alt + f2 to f7 to command mode, CLI Mode.

Helping Shortcuts :-
Ctrl + B     -     Move the cursor back one character.
Ctrl + C     -     Cancel the running commands.
Ctrl + D     -     Lock out of screen.
Ctrl + F      -     Move the cursor forward.
Ctrl + H     -     Erase one character similar to back space.
Ctrl + P     -      Past previews line.
Ctrl + S     -      Stop all output on screen.
Ctrl + U    -      Erase complete Line.
Ctrl +W    -       Delete the last word type.
Ctrl + Z     -      Cancel current operation.
Ctrl + L     -      Clear Screen.

Directory Commands
#mkdir dir_name
creating directory.
#mkdir /media/fld
creating directory in /media folder.
#mkdir mac linux
creating multiple directory.
show where are you like pwd.
#cd \ or cd~
come to main directory.
#cd dir_name     
change directory.
#cd ..
back one step from working directory.
#cd ../..
back two step from working directory.
#cd -
go to last working directory.
print the name of current working dir.

File Commands
#touch file_name         
create a blank file.
#touch cent red suse
create multiple files at same time.
#touch linux{1..100}
create linux1 to linux100 names files.
#cat > file_name           
creates a files and for saving this file press (ctrl + D).
#cat file_name              
see the content of the file.
#cat >> file_name         
append the file.
#cat file1 >> file2        
copy file2 content into file1.
#cat file1>file2            
file2 content overwrite to file1.
#cat file1 file2 > file3  
file1 file2 content overwrite in file3.
#cat –n file_name
to see how many lines are written in that file.

Deleting Commands
#rm file_name
deletes a file.
#rm –I file_name
deletes file / folder in interactive mode (asking mode).
#rm –r dir_name
deletes directory in recursive mode.
#rm –f file_name
deletes files / folders forcefully.
#rm a*
delete all file which start letter a.
#rm –rf linux*
remove all files who start linux name.
#rm -rf /cent
remove directory.
#rmdir dir_name
to remove empty directory.

Help Commands
#whatis cmd
information of command
#man cmd
Information of command
#info cmd
information of command
#cmd –help
information of command
#which cmd
information of command
#cd /usr/share/doc
information of command

Rename And Move
#mv old_file  new_file.                                       
rename the file.
#mv filename  path
move the file.

Listing Commands
listing files / folder.
#Is –l or ll
long listing of files / folder with whole information.
#ls –a        
list all files/ folder hidden also.
#ls ?? or ls f?
a all files /folder name with 2 characters.
#ls m*       
files & directories started with letter m.
#ls – x
show in column.
#ls –I
show list with Pid (node) no.

Copy Commands
#cp source destination
copies files from source to destination (cp f1 f2).
#cp –i f1 dir_name
copies files from source to destination in asking mode.
#cp –i * destination
copies current working directory all data to  destination.
#cp –r dir_name1 dir_name2
copies directory from source to destination.
#cp f1 f2 f3 dir_name
copy all file to dir_name.

History Commands
see history of recent commands.
#history -c
clear history.

Date, Calendar, Calculator Commands
show system date.
show calendar or #cal 4 2015.
#cal -3
display 3 months.
#cal 2016
show the 2016 calendar.
#cal 2016|less
show the calendar and can scroll up and down.
a basic calculator.
#whoami or #w  
info which user is login.

File Viewing Commands
#head file1
view top lines of a file.
#head -5 file1
see top ten file contents.
#tail file1
view the bottom lines of a file.
#tail -5 file1
see bottom ten contents.
#less file1
to see a file page wise and can scroll up and down.
#more file1
all contents in screen then use space or enter key move contents.
#evince file11.pdf
to open pdf file.

File Shorting Commands
#sort file1
short file in  a-z format.
#sort –d file1
sort directory format.
#sort –r file1
sort file z-a format.

Word Count Commands
#wc file.txt
show the number of lines, words, characters.
#wc –l file1
number of lines.
#wc –w file1
number of words.
#wc –c file1
number of characters.
#look word
check word spelling.

Different, Common, Compare Commands
#diff file1 file2
difference between two file.
#comm file1 file2
find common these two file.
#cmp file1 file2
show different in these two file.

Finding Commands
#find / -name file1
search word in /.
#find –size 512K /
search a file that size is 512KB /.
#find – name *.html
find all html file in current location.

Grep Commands
#grep word file1
to find word in a file.
#grep -n ‘word’ file1
show line no in which that word.
#grep -w ‘word’|’yo’ file1
show and find two words.
#grep -r ‘word’ /dir/
find a word in directory.
#grep -i ‘some’ file1
show the all word who belong ‘some’ string.
#grep -c ‘you’ file1
show and count the words.
#grep -l ‘some’ *
show all files who have ‘some’ word.

Cut Commands
cut -c 1-4 file_name
show the words 1 to 4 in file.
cut -c 3 file_name
show 3rd word in file.
cut -c 3- file_name
show 3 to last line in file.
cut -c 3-4 file_name
show the words 3 to 4 in file.

Hard Disk Info Commands
#df –h partition
to check free space of a partition.
#du –h partition
to check how much partition is used.
to check the processing status.

Link Commands
#ln file_name link_file_name
create hard link like ln file1 link_file1.
#ln –s file_name link_file_name
create soft link.

Clear Screen Commands
clear the screen.
#tput clear
clear the screen.
#tput cup 3 6
cursor move (x)3 (y)6.

Daily Tech Update Check and Join Us : Facebook | Twitter | Google+ | Tumblr | Myspace | LinkedIn | Pinterest | Flickr | Instagram | YouTube | 

No comments:

Post a Comment