Basics linux or unix commands a beginner should start with
Why to learn or use these commands
- It’s much more comfortable and faster
- It's much more flexible and efficient then graphical environment
- Working With Text Files is Easier
- You Can Probably Type Faster Than You Click
So lets focus on some basic commands which you should start with. These are the commands with which you may be working daily and you will be too used to of it that you will hardly use gui again
Where to use
- Linux or Mac users can use these commands on terminal. It is just an interface to the Shell and to the other command line programs that run.
- There is built-in command shell, but that is based on the MS-DOS command line and not on UNIX. Windows users can install git bash or wsl.
Basic Commands
1. pwd
- pwd stands for print working directory
- It gives us the absolute path, which means the path that starts from the root(base).
Like here i am in projects directory it gives the path of this directory
2. ls
ls stands for a list and it lists the contents of a directory
Here
ls
shows all files inside projectsNote You can use
ls -a
to see the hidden files
3. cd
- cd stands for Change Directory
cd <Directory>
: It changes current directory to desired directory
cd ..
: To go back to the parent directory.
cd
: To go back to the home directory
- If there is directory named Hello World we can't use
cd Hello World
it will consider World as different thing so either used" "
or\
like this"cd Hello World"
- or
cd Hello\ World
4. mkdir
mkdir
stands for make directorymkdir <name>
is used to make new directory or folder
5. rmdir
rmdir
stands for remove directoryrmdir <name>
can only be used to delete an empty directory
6. rm
rm
stands for removeIt is used to delete the folder and the files
By default rm does not delete directory
Using
rm -r
It delete the directory (r in -r stands for recursively)
7. cp
cp
stands for copycp Src_file Dest_file
It copies the content source file to destination file
8. mv
mv
stands for movemv Src_file Dest_file
It moves the content source file to destination file- If the destination file does not exist it automatically creates one
9. touch
touch <filename>
It is used to create a file without any content.- The file created using touch command is empty.
10. cat
cat
stands for concatenatecat <filename>
It is used to display content of file
11. echo
echo <argument>
It is is used to display line of text/string that are passed as an argument .echo <String> >> dest_file
It is also used to move some data, usually text into a file