5 Most Useful Linux Commands for Beginners — Part 2

Ankit Vashisht
3 min readNov 7, 2021

--

Photo by Arian Darvishi on Unsplash

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 -> pasteoperation in windows.

Usage

  • mv [SOURCE] [DESTINATION] where both source can be a file or whole directory whereas destination is directory path where the source should be moved.
mv

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 inside source to destination folder recursively ( -r flag stands for recursive ).
cp

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.
less

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.
mkdir

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.

rmdir throwing error when directory is not empty

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 )
rm -r

--

--