5 Most Useful Linux Commands for Beginners — Part 2
In this series of “Most Useful Linux Commands For Beginners”, today we’ll explore 5 more commands that are good to have under your belt. If you haven’t read Part 1 of this series, you can access it from here: 5 Most Useful Linux Commands For Beginners.
1. mv
mv
stands for the move. It is used to mv files or folders from one place to another inside the disk. It works similar to cut -> paste
operation in windows.
Usage
mv [SOURCE] [DESTINATION]
where bothsource
can be a file or whole directory whereasdestination
is directory path where the source should be moved.
2. cp
cp
stands for the copy command. It is used to copy files or whole folder from one place to another. It works similar to copy -> paste
operation.
Usage
cp [SOURCE] [DESTINATION]
will copy source file to destination folder.cp -r [SOURCE] [DESTINATION]
will copy all the files and folders present insidesource
todestination
folder recursively ( -r flag stands for recursive ).
3. less
As we discussed in our previous post, we can use cat
command to quickly view contents of a file, but if there’s a lot of content in the file then it would be very painful to read the printed content in the terminal.
Thus in that case we use less
command to check the content. less
offers paginated view to easily navigate within the file.
Note : Press
q
to quit
Usage
less [FILE]
will open a paginated view of the file.
4. mkdir
mkdir
stands for make directory. As the name suggests, it is used to make an empty directory
Usage
mkdir [DIR_NAME]
will create an empty directory of given name.
5. rmdir
rmdir
stands for remove directory. It is used to remove an empty directory. The catch here is it will throw an error if you try to remove a directory with files or folders present inside. It can only remove an empty directory.
Note : If you want to remove a directory with files/folders inside it, you should use
rm
command with-r flag
.
Usage
rmdir [DIR_NAME]
will remove given directory if it’s empty.rm -r [DIR_NAME]
will remove given directory ( Be careful with this command as this operation is not reversible )
That’s all folks. I hope you enjoyed and learned something new today. Will meet you in my next blog. Till then, bye.