Linux Commands Cheatsheet for Beginners

Salman Dabbakuti
Jun 17 · 6 min read
A photo by pixabay at pexels


Linux is a open source operating system based on linux kernel. Since it is free and open-source, that means any developer can simply change anything in Linux and redistribute it ! Thats why There are several Linux Distributions like Ubuntu, Redhat, Linux mint, Fedora, Debian, Kali linux etc..

Linux is fast, secure, and free. About 90% of the internet is powered by Linux. it is mainly used in servers. over 94.2% of supercomputers are Linux based. Most of the viruses in the world affect on Windows, but not on Linux. about 80% of the smartphones in the world and even Android is also made from the Linux kernel.

Basically, Linux has a CLI (command line interface). its an absolute tradition to learn some of these Commands. In this tutorial, we are going to cover the basic commands that we use most regularly.

  1. pwd

To know which directory you are in, you can use the “pwd” command

Usage of pwd command

2. ls, ls -a, ls -l

To list all the files available in current directory you can use ls. if you wanted to see hidden files, you can use ls -a. if you wanted to list all files with permission details, date created and size, you can use ls -l

Usage of ls commands

3. cd, cd /, cd -, cd ..

If you are in home directory and wanted to go to sub directory in home, you can use cd command along with the name of sub directory. like, if you wanted to go to downloads directory, then use cd downloads.

Use cd alone to enter into home directory. use cd / to enter into root directory. to navigate to the previous directory, use cd -

If you wanted go up one directory level, you can use cd ..

Usage of cd commands

4.mkdir, rmdir, rm

You can create new directory or folder in exisisting directory with mkdir followed by folder name. for example mkdir test creates a folder with name test in current directory.

Usage of mkdir command

If you wanted to delete an empty directory, you can use rmdir followed by directory name. for example, rmdir test deletes test directory from current directory. please note that, rmdir can only deletes empty directories.

Usage of rmdir command and prompt on non empty directories

If you wanted to delete files and non-empty folders, you can use rm

rm sample.txt deletes a file sample.txt in current directory.

Usage of rm command

If you wanted to delete whole folder containing files, use rm -rf <folder name>

Usage of rm for deleting entire folder

5. touch, cat, nano

You can create file(it could be anything from .txt to .py) using touch command followed by filename. for example touch sample.txt creates a file sample.txt

Usage of touch command

You can also create file with cat command as follows

cat >sample.txt it creates a new file sample.txt and you can add contents to it right from the command line and press ctrl+D to save and exit from editor.

Usage of cat command

cat can also be used for viewing contents of the file. for example, if you wanted to see what text contents are stored in sample.txt, you can simply use cat sample.txt

If you wanted to edit file, you can use pre installed code editor nano in linux with a command nano follwed by file name. like nano sample.txt . it will open your file in code editor. point your cursor to editing point (with navigation arrows only) in file and after editing press ctrl+x and click on save prompt.

Usage of nano editor
Prompt on exit

6. cp, mv

cp and mv commands are used for copying and moving files and folders from one directory to other respectively.

These commands will take two arguments as paths . first argument is path of copying or moving file and second one is to which directory to copy or move file.

For example, if you wanted to copy or move a file photo.jpg in current directory to downloads directory which is a sub directory of current directory.

cp photo.jpg downloads //copies to downloads directorymv photo.jpg downloads //moves to the downloads directory
Usage of cp command
Usage of mv command

If you wanted to copy all the files from a directory to another directory, you can use -r flag along with cp as follows. you must provide root privileges for some write protected folders.

cp -r ~</copying folder path> ~</path to copy>
cp -r </copying folder path> </path to copy> //if you are dealing with root directories
Usage of cp for copying files in current directory

If you wanted to copy all files in current directory to other directory, you can use cp command as

cp -r * </path to copy>cp * </path to copy> //omits sub directories
Usage of cp command to copy files and folders in current directory

If you wanted to move only files from particular directory(not entire folder), you can use /* flags along with mv command as

mv <folderpath or name/*> ~</path to move>
Usage of mv command to mv files in the directory
Result of mv command above

If you wanted to copy or move whole folder and files in it to other directory, then you can use

cp -r <copying folder path> <path to copy>mv <moving folder path> <path to move>
Usage of cp for copying whole folder
Usage of mv command to move folders

mv command is also used for renaming files and folders. if you wanted to rename file sample.txt to new.txt, you can use

mv sample.txt new.txtmv Documents Mydocuments // Renaming folders
Usage of mv for Renaming files

7. locate

locate command is used for searching files in entire machine. for example, if you wanted to search for file, you can use

Usage of locate command

It will list out all the files that are named with

8. ifconfig

This command is used for viewing network configuration info. Like ip addresses, mac addresses, link speed of connected network etc

9. clear

This command is used for clearing terminal if it is filled up.


The Must-Read Publication for Aspiring Developers & DevOps Enthusiasts

Salman Dabbakuti

Written by

Curious about Decentralized future. Working on Blockchain Technologies.



The Must-Read Publication for Aspiring Developers & DevOps Enthusiasts