Linux Commands with Examples for Beginners

In this article, you will learn some of the most used Linux commands with examples . If you are new to Linux or Ubuntu operating system then all these commands are very helpful for you.

Linux Commands with Examples

To start with following commands open the terminal (ctr + Alt + T) and start playing.

LS command – List all files and directories in Linux

ls command is used to list all files and directories in current directory.

If you want to check file type, modified date, owner of file and it’s permission, use -l switch with ls.

List hidden files using -a with ls.

PWD Command – Check Current Working Directory in Linux

pwd command is used to check current working directory.

/home/raj is my current directory, if i move to some other directory and then type pwd then it display other path.

CD Command – Change Current Directory in Linux

cd command is used to change current directory.

Move to Documents directory.

Move one level up. Now my current directory is Documents (/home/raj/Documents). Now i want to go one level up on /home/raj directory.

CP Command .

Linux File Permission Basics .

Touch Command – Create New Files in Linux

Creating new file is very simple in Linux using touch command. You have to specify only filename.

Now newfile is created, you can verify by typing ls command.

Touch Command – Complete Guide.

Create multiple files using touch command.

Created file1, file2 and file3.

Subscribe Our Tutorials

Get Latest Updates on Facebook

VI/VIM editor commands.

CP Command – Copy Files and Directories in Linux

cp (copy) command is used to copy files and directories from one location to another. In cp command you have to specify source and destination.

Copy contents of config.php to config.php.bak .

While copy directory -r switch is required. You cannot copy one directory to other by simply copy command.

# Wrong way of copying directory.

# Correct way of copying directory .

mkdir Command – How to Create Directory in Linux

mkdir command is used to create new directory.

Let’s create a new directory webapp.

If you want to check whether the directory is created or not type ls command.

MV Command – move (rename) files

mv command is used to move files and directories from one place to another in Linux. You can also rename files and directories using this command.

Move test.php file from Document directory to Desktop.

Rename dir1 to dir2.

FIND Command – Search files

find command search for files in a directory hierarchy.

Let’s say i have to find test.php file in Document directory.

Find file in current directory.

. (dot) represents current directory.

Find file by name ignoring case (case insensitive search) . In linux test.php and Test.php are two different files. If we want to ignore case then we need to use -i switch.

Find all files whose file extension is .php .

Similarly you can find all files whose extension is .txt , .doc, .pdf etc.


I tried my best to mentioned all the most used Linux commands. If you want to add any command please let us know through your comments.


About WebRewrite

I am technology lover who loves to keep updated with latest technology. My interest field is Web Development.
Tagged , , . Bookmark the permalink.

One Response to Linux Commands with Examples for Beginners

  1. Kumar Gaurav says:

    Thanks for clear and concise explanation. Can you explain grep command as well as it’s the most used command in linux.

Leave a Reply

Your email address will not be published. Required fields are marked *