Command-Line Essential Shortcuts Every Developer should know.
shortcuts to improve development speed
Hey Everyone 👋, I am pavan working as a software engineer. I am going to share some command-line shortcuts which every developer can use every day to fasten their development time 😃.
ℹ️ Windows users can use the git bash terminal to take advantage of these shortcuts which comes directly when we install git.
Navigation
pwd
Prints the current working directory
ls
lists the contents of the current working directory
we can pass options to this command for further results,
ls -l
lists the contents of the current working directory in the list format and ls -la
will list the contents of the contents of the current working directory in the list format along with the hidden files.
up arrow ↑/down arrow ↓
move to previous and new commands
ctrl + u
clear the current line. This is very useful when we entered the wrong command and we have to remove the complete command instead of clicking the backspace multiple times we can use this command to clear the line at one shot.
ctrl + a
Move the cursor to the starting of the line.
ctrl + e
Move the cursor to the ending of the line.
ctrl+left arrow←/ right arrow→
Move the cursor between words. This is very handy outside of the terminal also when we are in any kind of editor and want to move between the words then we can use this shortcut.
cd (folder name)
To move to the specified folder.
Creating folders
mkdir (folder name)
To create the folder in the current directory with the specified folder name.
mkdir "(folder name)"
To create the folder having multiple words in the folder name. if we create using the above shortcut it will create two separate folders as we have space between them. we can also use \ to escape the space between words. (e.g mkdir folder\ name)
mkdir (folder name) (folder name) (folder name)
To create multiple folders in the same command in the current working directory.
Creating & opening Files
touch (filename + extension)
To create the file with type
eg: touch reaserch-paper.txt , touch findings.csv
start (filename)
To open the file supported application
eg: start reaserch-paper.txt (it will open notepad)
cat (filename)
To view the contents of the file inside the terminal
eg: cat index.html
Copying (or) Moving files/folders
cp (filename) (destination path)
copy file from one path to another path
eg: cp biology-finding.txt ../final-papers
it will create the same biology-finding.txt file inside the final-papers folder
mv (filename) (destination path)
move files from one path to another path. This is useful when we accidentally create a file and you want to move that file into a different folder
eg: mv biology-finding.txt ../biology
it will move the bilogy-finding.txt file from the current folder to biology folder specified
in the destination path
Rename files
mv (source file name) (destination filename)
Rename file names
eg: mv biology-findings.txt biology-reaserch-findings.txt
it will rename the file name from biology-findings.txt to biology-reaserch-findings.txt
SUMMARY:
pwd
stands for "print working directory." Terminal will tell you which folder you're currently in.cd
stands for "change directory." Pass it the name of another folder, and the terminal will move you to that folder.ls
stands for "list." Running this command will show the contents of your current folder.mkdir
stands for "make directory." Running this command, plus the name of your desired new folder, will create a new folder.touch
plus the name of your desired new file, will create a new file.mv
stands for move. Running this command, plus the name of the content you want to move, plus the location where you want to move it, will move the content.cp
stands forcopy
. Running this command, plus the name of the content you want to copy, plus the location where you want to move it, will copy the content to another location.- Several shortcuts allow you to be more nimble on the command line, like ctrl + e, ctrl + a etc.
Reference:
This was my learnings from the course by openclassrooms. They provide quality courses for free do check out for many more courses. OpenClassRooms
p.s This was my first article please let me know if anything I can improve. That will be helpful 🥰