unix command

pwd-present work directory
Ls-list of file. Cd change directory
Who-how many user is logged in
Whoami-directly who user is logged in
Man-manully online mannual information about commant
Who --count ---> No of user logged in
Who -b -->last time when system was logged in
cal-calender
cal -j-->julian calender
Cal -3 last 3 moth calender
Cal -m-->current month calender
cal -y---> current year command
Date +%a
Date +%A--.date in full form
Date +%b
Date +%B-->month in fulform
Date +%F-2016-08-23
Date +%y-year

How to create a file
Cat > NareshTech  ///promt allow to enter data enter data” hello word”
Note:$ user propmpt
       # admin prompt
See what ever is written in file

Cat NareshTech   or cat < NareshTech

Display data in numbered format
Cat -n NareshTech

Append in specific file
Cat >> NareshTech//will give prompt to append

Output of only non blank line:
Cat -b NareshTech



Touch ,mv,cp
Touch -->to create empty file
Touch file1 file2 file3 //3 file has been created

If u want to append something in file 1 use
Cat >> file1
Note to details of file-->  FILE *
Ls -l→ display file with details
touch  -m file1 //modificATION time
         -a file1 // access time
To modify access time use
touch -d ‘6 May 2016 20:32’ file1
Note stat file → give complete information about file

Mkdir dir1/dir2   //mkdir dir1 dir2
Note → current default location cd ~
           Current director cd -
rmdir→ remove directory empty directory // rm → to delete file in directory and Non empty directory
rm -i file2→ remove current file y/n   //i means iteractive
rm -v file2→ //message --removed file2   // v means verbose
rm -R dir1-->to delete complete directory

Mv linux unix→ rename linux to unix   // move cammand means mv
Mv -v unix /home/redhat/Hello/Linux-->inside hello i m moving unix and editing file with the name of  Linux -------here -v tell verbose means details of operation done
Mv -v /home/redhat/NareshTechnology/Unix   /home/redhat/NareshTechnology/Linux -->editing has been also done with complete directory information…..if u not pass new file name in updated directory move will be done by same name as previous file name

Cp→ copy //it by default work with file
Cp perl shell
Cp java javascript         ---------------// cp: ommiting directory ‘java’ here java and javascript are directory
Cp -r java javascript // r is recursive now copy of directory will done easily

U can also copy with details
Cp -v perl   /home/NareshTech/java -
--------//its same line mv command except here copy will done not move


Ls -l ---> long listing with details
Ls -t-->it display as based on time based// upaded first from start//time
Ls -rt->it display last updated first//time in reverse
Ls -s -->will  details file size wize

Ls ? -->display file having single charecter file name
Ls ??-->display having 2 character as file name
Ls ???--> 3 cahrecter
Rmdir ?--> simple character deleted
Rmdir ??-->double character file name deleted
Cat ? it display all file having single character file name
Cat ?? it display all file name having double character file name

Ls *a→ display all file ending with a
Rm *--> delete all file from current directory
Rm -r *--> it removes all file and subdirectory from current directory
Rmdir *-->it will remove all empty directory from current directory
Ls [abcd]* display all file or directory started with a or b or c or d  //Ls [a,b,c,d]*
Rm [a,b,c,d]* → remove director file started with a or b or c or d….it will work for rmdir alsowhich work on empty file
Ls [a-d]* display ALL File started with a or b or c or d

…………………………………………………………………..
-rw-rw-r--
-”  →
rw-”-->owner//who created file “u for owner”
rw-”-->group/user  ...in which project collection are using “g for group”
“r--”-->for other  //”o for other”
Note:” a” for all

Chmod u+w,o-rwx -->adding write permission to owner and no permission to other
Ls-l  //long listing the file
-rw-rw----
assign execulatble permission
Chmod u=x Myfile //assingning executable permission
Chmod o=rwx Myfile//assining read write extecute prmission to other
Chmod a-rwx myfile //remove all permission fr0m all(owner ,group,other)
Note:
Rw- rw- r--
110 110 100   -------------------------->binary representation
6      6 4          --->simily for 0-7 digit
0 means no permission
Example:
Chomod 064 nacre  //no permission to owner ,rw permision to group and r permission to other
Ls -l
- --- rw- r-- 1 redhat 19 sep 21 13:52 nacre

1>Script:  //to save all which is written on terminal before “exit ” command
o/p:
Script started . file is typeScript //here filename which is defaut is typescript

Display script file ----> cat script//it will show all operation perform b/w script command and exit command
-->save all written operation on terminal session in between script and exit command
Script sraju//here sraju file will create
Note:script -a sraju→ Now script will on and append  all written text on terminal

2>bc //base convervion/// for calculator for mainlu c laguage it calculate till 11 permission ...here is one more command which is dc for unlimited pecision
3>
Uniq:print uniquness immediate after line
cat>cources
Unix
Unix
Linex
Linex
Unix
Js
Unix
Js
//uniq courses
Unix
Linex
Unix
Js
Unix
Js
Option:
Uniq -d courses
Unix
Linex
Uniq -c courses
2 Unix
2 Linex
1 Unix
1 Js
1 Unix
1 Js
-->uniq --count  couses
//display with count like -c option
4>logname:currently logged in username
5>users:current logged in user
6>which cat//tells cat command is available where
Which ls
//o/p:/bin/ls
Which  c++
/usr/bin/c++
7> whereis cat          //it tells various path where cat is available like “-m” for mannual path “-s” for static path
8>factor  //print prime factor of a number
Example:
Factor 4
2 2
9>echo To print like printf
Example
Echo helloworld
o/p:helloworld
$a=120;
$b=130;
$echo $a + $b
o/p: 120 + 130
$echo $[a+b];
o/p:250
$echo {a..d}
a b c d
$echo {a..z}//print a to z
$echo {A..Z}//print A to Z
$echo {A..z} //print A to Z and a to z
$echo {0..5}//print 0 to 5
$echo “hello, world !”//o/p error for this we have to write $echo “hello, world”! //bcz “!” has different meaning
$echo “welcome to echo in unix” >small
$cat small
o/p:welcome to echo in unix
$echo “welcome to echo in unix” >>small   // it will append text in small file
$echo “hello\nworld”
Output:hello\nworld
$echo -e “hello\nworld”
hello
World
$echo -e “Hello\n\tWorld”
Hello
     World
------------------
$cat >file1//it will give screen to write and  those line will finally store in file1 after ctrl +d
$cat <file1 // similar to “cat file1” it will shows content of file1  
$cat < file1 > file2 //its just like copy ..copying content of file1 to file2

---------
$wc -l file1//count no of line in file1  “l for line “//wc means word count ….this command  is similar to
$cat file1 | wc -l //0/p:2
$cat file |wc -l >line //this command will store o/p “2” in “line” file
$cat line
o/p:2
--....
$who --count //count no of user logged in
2
$who --count | wc -l >users1//$who --count will  be for o/p in numbered format
$cat users
2
$ls
Line unix user user1
$ls | wc -w
4
$ls | wc -w >file1 //here 5 will store in file 1 bcz fil1 is creating and remaining 4 file so 1+4=5
$cal file //o/p:5







Comments

Popular posts from this blog

bit manipulation