Some basic terminal commands which you need or which is better to know as a good engineer.
-
pwd
: pwd means path working directory. If you type and press enter in the terminal then it will shows your current directory path. -
ls
: this command shows a list of all the files available in your current directory. -
ls -lha
: Extended version of ls. It will do the same as ls but it will show other information with the list like file file size, create date, permission etc. -
cat
: You can use this command to show the content of a file. For example, suppose in your working directory there is a file named test.txt. Now we want to see the content of this file. Then we will writecat test.txt
. -
man
: This command is very helpfull to know the details of a command. For example we don't know whatcat
command does. So we want to know that. In that case we can writeman cat
. It is actually manual. -
cd
: When we want to change the directory we will use this command. Suppose we have a directory which name is test in our current working directory. Now we want to go to this directory. In that case we can writecd test
. Even you can specify file path here likecd filePath
-
cd ...
orcd ../..
: To move two directory up -
cd -
: It will move to the last path -
~
: It will move you to the home directory -
df -h
: It shows the free disk space -
du -sh
: It shows the disk usage of your current direcotry -
du -sh *
: It displays the disk usage for every file and folder in that location -
arrow up or arrow down to show the last commands
-
mkdir
- To use this command you can create a new directory in your current directory. To do that writemkdir directoryName
. For examplemkdir test
. It will create a new directory with name test in your current directory. To check that writels
. You will see your new test directory in that list. -
touch
- To create a new file we will use this command. For example we want to create a test file named test.txt. So we will writetouch test.txt
. It will create the file with that name. To test that writels
. You will see the test.txt file in this list -
echo
: Use to print line. For exampleecho "Hello World
-
>
: We can write line with this command. For example in the file test.txt we want to add a line Hello World. Then we can do that like thisecho "Hello World" > test.txt
. Now to check the content of the file writecat test.txt
. You will see our newly added line. But one important thing is if you do run the same command with different line it will overwrites the previous line. Something like replace string. -
>>
: It will end line at the end of the file. Something like append. Similar format than previous. As it is adding line at the end of the file so it will not overwrites previous lines. -
nano
: Nano is one of the text editors. We can open a file like thisnano test.txt
and edit the content on the fly. -
cp
: This command is used to copy file. We need to provide two parameter as well. One is source and another is destination. For example in our current directory we have a file name test.txt. Now we want to copy this file with a different name. So we ca write like thiscp test.txt testcp.txt
. Now if you runls
then you will see a new file with name testcp.txt. -
mv
: To move a file from one place to another we can use this command. Suppose we have a file named test.txt in our current directory and we have a directory named testdirectory in our current directory. Now we want to move this test.txtt file inside the testdirectory. To do that we can use the mv command like thismv test.txt testdirectory/test.txt
. So that means we need to provide source and destination likecp
command. -
zip
: To zip a folder we can use this command. Suppose we want to zip testdirectory folder to testdirectory. To do that we will writezip -r testdirectory.zip testdirectory
. Here we need to provide the destination first. -
unzip
: To unzip a zip file we can use this command. We need to pass the zip file like thisunzip testdirectory.zip
ctrl + A
- It will move the cursor to startctrl + E
- Move the cursor to end