0% found this document useful (0 votes)
1 views

CommandLine

Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

CommandLine

Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

-----------------------------Command Line

Terminal---------------------------------------------------------------------------
--------
___________________________________________________________________________________
__________________________________________________

1)To check the parent directory of the terminal:


-> use the (pwd) command which gives output-home/aary
->pwd

2)To create the new blank file :


-> use the (touch) command which creates the new file with given name
->touch myfilename.txt

3)To change the directory from paraent directory:


-> use the (cd) command followed by the (cygdrive) and path
-> cd /cygdrive/e

4)To change the directory back to the home directory:


->use the (cd) command with the(~)
-> cd ~ or cd $HOME or cd ..

5)To list the files from any directory including home:


->Use the (ls ~) command so all the files in the given directory will be shown to
you
->ls ~ or ls -l ~

6)To copy the file into another folder:


-> use the (cp) command with fileName and type and destination.
-> cp myfilename.txt myfoldername
-> cp myfilename.txt ../folder1/folder2

7)To copy the entire folder:


-> use the (cp) command with (-r) with <source> <destination>
-> cp -r /cygdrive/F/Books/Academics/cpp/ ../python

8)To move the file into another folder:


-> use the (mv) command with the destination
-> mv myfilename.txt myfoldername
-> mv myfilename.txt ../foldername1/foldername2 //which means move the file from
current destination to the previous folder1 and then into folder2

9)To write the output to the console screen:


-> use the (echo) command with "TEXT TO DISPLAY"
-> echo "Aary"

10)To create the another folder/directory:


-> First go to the desire destination by changing the path. Then use (mkdir)
command Foldername to create the folder.
-> mkdir folderName/mkdir "Second Semester"/mkdir second\semester

11)To open the file in the desire application:


-> use the (open) command with (-a) with <application name> <fileName>//not
accessable in cygwin
-> also use cygstart fileName.txt but it will open in the defaullt application.
-> open -a <application name> <fileName>//not useful OR cygstart fileName.txt
-> Most effective is cygstart <application name> <fileName> / start excel
fileName.csv
12)To read the content from the given file:
-> use the (cat) command.
-> cat fileName.txt

13)To write the text in to the file from terminal:


-> use the "Text you want to add in the file" >fileName.txt

14)To return the lines having certain lines:


-> use (grep) <text_to_find> fileName.txt

15)SHORTCUTS FOR THE COMMANDS:


A)Acsessing Command Line Histroy :using the up and down arrows.
B)To move to the fisrt and last of the commands : CRT+A and CRT+E
C)To entirly delete the command : CRT+U
D)To clear the previous outputs : CRT+L
E)Move to previous word : CRT+B
F)Brows previous command : CRT+P
G)Pastes the text in buffer : CRT+Y
H)To go back to previous destination and desire directory : (cd ..)
//for previous destination

(cd ../directoryname) //for specific destination


I)To go inside the directory : cd folder1/

-----------------------------------------------------------------------------------
------------------------------------

16)Date and Calender Command:


-> use (date -u) for current date & use (date --date="10 days ago") for any other
days date.
-> use (cal) for opening calender in shell.

You might also like