---
description: Empower your tech skills with a solid grasp of Basics Linux/Unix Commands essential for navigating and controlling your open-source OS efficiently.
title: Basics Linux/Unix Commands with Examples &#038; Syntax (List)
image: https://www.guru99.com/images/must-know-linux-commands-top-image.png
---

[Skip to content](#main) 

File Management becomes easy if you know the right basic command in Linux.

Sometimes, commands are also referred as “programs” since whenever you run a command, it’s the corresponding program code, written for the command, which is being executed.

Let’s learn the must know Linux basic commands with examples:

Click [here](https://www.guru99.com/faq#faq1) if the video is not accessible   

## Listing files (ls)

If you want to see the list of files on your UNIX or Linux system, use the ‘**ls’** command.

It shows the files /directories in your current directory.

[](https://www.guru99.com/images/ls%281%29.png)

**Note:**

* Directories are denoted in blue color.
* Files are denoted in white.
* You will find similar color schemes in different flavors of Linux.

Suppose, your “Music” folder has following sub-directories and files.

[](https://www.guru99.com/images/sub-directory%281%29.png)

You can use **‘ls -R’ to shows all the files not only in directories but also subdirectories** 

[](https://www.guru99.com/images/ls-R%281%29.png)

NOTE: These Linux basics commands are case-sensitive. If you enter, “**ls – r**” you will get an error.

**‘ls -al’** gives detailed information of the files. The command provides information in a columnar format. The columns contain the following information:

| **1st Column** | File type and access permissions  |
| -------------- | --------------------------------- |
| **2nd Column** | \# of HardLinks to the File       |
| **3rd Column** | Owner and the creator of the file |
| **4th Column** | Group of the owner                |
| **5th Column** | File size in Bytes                |
| **6th Column** | Date and Time                     |
| **7th Column** | Directory or File name            |

### RELATED ARTICLES

* [ Linux Command Line Tutorial: Manipulate Terminal with CD Commands ](https://www.guru99.com/terminal-file-manager.html "Linux Command Line Tutorial: Manipulate Terminal with CD Commands")
* [ File Permissions in Linux / Unix: How to Read, Write & Change? ](https://www.guru99.com/file-permissions.html "File Permissions in Linux / Unix: How to Read, Write & Change?")
* [ Input Output Redirection in Linux/Unix Examples ](https://www.guru99.com/linux-redirection.html "Input Output Redirection in Linux/Unix Examples")
* [ Linux User Commands Tutorial: Administration & Management ](https://www.guru99.com/linux-admin.html "Linux User Commands Tutorial: Administration & Management")

Let’s see an example – 

[](https://www.guru99.com/images/ls-al%282%29.png)

## Listing Hidden Files

Hidden items in UNIX/Linux begin with –[](https://www.guru99.com/images/period%5Fsymbol%282%29.png)at the start, of the file or directory.

Any Directory/file starting with a ‘.’ will not be seen unless you request for it. To view hidden files, use the command.

ls -a

[](https://www.guru99.com/images/ls-a%282%29.png)

## Creating & Viewing Files

The ‘cat’ server command is used to display text files. It can also be used for copying, combining and creating new text files. Let’s see how it works.

To create a new file, use the command

1. cat > filename
2. Add content
3. Press ‘ctrl + d’ to return to command prompt.

[](https://www.guru99.com/images/cat%5Ffilename%281%29.png)

How to create and view files in Linux/Unix

To view a file, use the command –

cat filename

Let’s see the file we just created – 

[](https://www.guru99.com/images/cat%5Fview%5Fa%5Ffile%281%29.png)

Let’s see another file sample2

[](https://www.guru99.com/images/cat%5Fsample2.png)

The syntax to combine 2 files is –

cat file1 file2 > newfilename

Let’s combine sample 1 and sample 2.

[](https://www.guru99.com/images/cat%5Fcombine.png)

As soon as you insert this command and hit enter, the files are concatenated, but you do not see a result. This is because **Bash Shell (Terminal) is silent type**. Shell Commands will never give you a confirmation message like “OK” or “Command Successfully Executed”. It will only show a message when something goes wrong or when an error has occurred.

To view the new combo file “sample” use the command

cat sample

[](https://www.guru99.com/images/cat%5Fcombo.png)

**Note:** Only text files can be displayed and combined using this command.

## Deleting Files

The ‘rm’ command removes files from the system without confirmation.

To remove a file use syntax –

rm filename

[](https://www.guru99.com/images/linux%5Frm%5Fcommand.jpg) 

How to delete files using Linux/Unix Commands

## Moving and Re-naming files

To move a file, use the command.

mv filename new_file_location

Suppose we want to move the file “sample2” to location /home/guru99/Documents. Executing the command

**mv sample2 /home/guru99/Documents**

[](https://www.guru99.com/images/mv%5Ferror.png)

mv command needs super user permission. Currently, we are executing the command as a standard user. Hence we get the above error. To overcome the error use command.

sudo command_you_want_to_execute

Sudo program allows regular users to run programs with the security privileges of the superuser or root.

Sudo command will ask for password authentication. Though, you do not need to know the root password. You can supply your own password. After authentication, the system will invoke the requested command.

Sudo maintains a log of each command run. System administrators can trackback the person responsible for undesirable changes in the system.

guru99@VirtualBox:~$ sudo mv sample2 /home/quru99/Documents 
[sudo] password for guru99: ****
guru99@VirtualBox:~$ 

For renaming file:

mv filename newfilename

[](https://www.guru99.com/images/mv%281%29.png)

**NOTE**: By default, the password you entered for sudo is retained for 15 minutes per terminal. This eliminates the need of entering the password time and again.

You only need root/sudo privileges, only if the command involves files or directories not owned by the user or group running the commands

## Directory Manipulations

[](https://www.guru99.com/images/Direct.png) 

Directory Manipulation in Linux/Unix

Enough with File manipulations! Let’s learn some directory manipulation Linux commands with examples and syntax.

Creating Directories

Directories can be created on a Linux operating system using the following command

mkdir directoryname

This command will create a subdirectory in your present working directory, which is usually your “Home Directory”.

For example,

mkdir mydirectory

[](https://www.guru99.com/images/MKdir-1.png)

If you want to create a directory in a different location other than ‘Home directory’, you could use the following command –

mkdir 

For example:

mkdir /tmp/MUSIC

will create a directory ‘Music’ under ‘/tmp’ directory

[](https://www.guru99.com/images/8-2016/linux-5-1.png)

You can also create more than one directory at a time. 

[](https://www.guru99.com/images/8-2016/linux-5-2.png)

## Removing Directories

To remove a directory, use the command –

rmdir directoryname

Example

rmdir mydirectory

will delete the directory mydirectory

[](https://www.guru99.com/images/rmdir.png)

**Tip**: Ensure that there is no file / sub-directory under the directory that you want to delete. Delete the files/sub-directory first before deleting the parent directory.

[](https://www.guru99.com/images/rmdir1.png)

## Renaming Directory

The ‘mv’ (move) command (covered earlier) can also be used for renaming directories. Use the below-given format:

mv directoryname newdirectoryname

Let us try it:

[](https://www.guru99.com/images/8-2016/linux-5-3.png) 

How to rename a directory using Linux/Unix Commands

## **Other Important Commands**

## The ‘Man’ command

Man stands for manual which is a reference book of a [Linux operating system](https://www.guru99.com/introduction-linux.html). It is similar to HELP file found in popular software.

To get help on any command that you do not understand, you can type

man 

The terminal would open the manual page for that command.

For an example, if we type man man and hit enter; terminal would give us information on man command

[](https://www.guru99.com/images/man%5Fman.png)

[](https://www.guru99.com/images/man%5Fman%5F1.png)

## The History Command

History command shows all the basic commands in Linux that you have used in the past for the current terminal session. This can help you refer to the old commands you have entered and re-used them in your operations again.

[](https://www.guru99.com/images/history.png)

## **The clear command**

This command clears all the clutter on the terminal and gives you a clean window to work on, just like when you launch the terminal.

[](https://www.guru99.com/images/clear.png)

## Pasting commands into the terminal

Many times you would have to type in long commands on the Terminal. Well, it can be annoying at times, and if you want to avoid such a situation then copy, pasting the commands can come to rescue.

For copying, the text from a source, you would use **Ctrl + c,** but for pasting it on the Terminal, you need to use **Ctrl + Shift + p**. You can also try **Shift + Insert or select Edit>Paste on the menu**

NOTE: With Linux upgrades, these shortcuts keep changing. You can set your preferred shortcuts via Terminal> Edit> Keyboard Shortcuts.

## Printing in Unix/Linux

[](https://www.guru99.com/images/print.png) 

How to print a file using Linux/Unix commands

Let’s try out some Linux basic commands with examples that **can print files** in a format you want. What more, your original file does not get affected at all by the formatting that you do. Let us learn about these commands and their use.

Click [here](https://www.guru99.com/faq#faq1) if the video is not accessible   

## ‘pr’ command

This command helps in formatting the file for printing on the terminal. There are many Linux terminal commands available with this command which help in making desired format changes on file. The most used ‘**pr’** Unix commands with examples are listed below.

| Option          | Function                                                 |
| --------------- | -------------------------------------------------------- |
| \-x             | Divides the data into ‘x’ columns                        |
| \-h “header”    | Assigns “header” value as the report header              |
| \-t             | Does not print the header and top/bottom margins         |
| \-d             | Double spaces the output file                            |
| \-n             | Denotes all line with numbers                            |
| \-l page length | Defines the lines (page length) in a page. Default is 56 |
| \-o margin      | Formats the page by the margin number                    |

Let us try some of the options and study their effects.

### Dividing data into columns

‘**Tools’** is a file (shown below).

[](https://www.guru99.com/images/Tools.png)

We want its content to be arranged in three columns. The syntax for the same would be:

pr -x Filename

The ‘-x’ option with the ‘pr’ command divides the data into x columns.

[](https://www.guru99.com/images/pr%5F-x.png)

### Assigning a header

The syntax is:

pr -h "Header" Filename

The ‘-h’ options assigns “header” value as the report header.

[](https://www.guru99.com/images/pr%5F-header.png)

As shown above, we have arranged the file in 3 columns and assigned a header

### Denoting all lines with numbers

The syntax is:

pr -n Filename

This command denotes all the lines in the file with numbers.

[](https://www.guru99.com/images/pr%5F-n.png)

These are some of the ‘pr’ command options that you can use to modify the file format.

### Printing a file

Once you are **done with the formatting,** and it is time for you to get a **hard copy** of the file, you need to use the following command:

lp Filename

or

lpr Filename

In case you want to print multiple copies of the file, you can use the number modifier.

[](https://www.guru99.com/images/multiple%5Fprints.png)

In case you have multiple printers configured, you can specify a particular printer using the Printer modifier

[](https://www.guru99.com/images/multiple%5Fprinters.png)

## Installing Software

In windows, the installation of a program is done by running the setup.exe file. The installation bundle contains the program as well various dependent components required to run the program correctly.

[](https://www.guru99.com/images/VLCPlayer.png)

Using Linux/Unix basic commands, installation files in Linux are distributed as packages. But the package contains only the program itself. Any dependent components will have to be installed separately which are usually available as packages themselves.

[](https://www.guru99.com/images/Banshee.png)

You can use the **apt** commands to install or remove a package. Let’s update all the installed packages in our system using command –

sudo apt-get update

[](https://www.guru99.com/images/apt.png)

The easy and popular way to install programs on Ubuntu is by using the Software center as most of the software packages are available on it and it is far more secure than the files downloaded from the internet.

[](https://www.guru99.com/images/SoftwareCenter.png)

**Also Check:-** [Linux Command Cheat Sheet](https://www.guru99.com/linux-commands-cheat-sheet.html)

## Linux Mail Command

For sending mails through a terminal, you will need to install packages ‘mailutils’.

The command syntax is –

sudo apt-get install packagename

Once done, you can then use the following syntax for sending an email.

mail -s 'subject' -c 'cc-address' -b 'bcc-address' 'to-address'

This will look like:

[](https://www.guru99.com/images/mail.png)

Press Cntrl+D you are finished writing the mail. The mail will be sent to the mentioned address.

## Summary:

* You can format and print a file directly from the terminal. The formatting you do on the files does not affect the file contents
* In Unix/Linux, software is installed in the form of packages. A package contains the program itself. Any dependent component needs to be downloaded separately.
* You can also send e-mails from terminal using the **‘mail’** network commands. It is very useful Linux command.

## Linux Command List

Below is a Cheat Sheet of Linux/ Unix basic commands with examples that we have learned in this Linux commands tutorial

| Command                                                         | Description                                                                                |
| --------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| ls                                                              | Lists all files and directories in the present working directory                           |
| ls – R                                                          | Lists files in sub-directories as well                                                     |
| ls – a                                                          | Lists hidden files as well                                                                 |
| ls – al                                                         | Lists files and directories with detailed information like permissions, size, owner, etc.  |
| cat > filename                                                  | Creates a new file                                                                         |
| cat filename                                                    | Displays the file content                                                                  |
| cat file1 file2 > file3                                         | Joins two files (file1, file2) and stores the output in a new file (file3)                 |
| mv file “new file path”                                         | Moves the files to the new location                                                        |
| mv filename new\_file\_name                                     | Renames the file to a new filename                                                         |
| sudo                                                            | Allows regular users to run programs with the security privileges of the superuser or root |
| rm filename                                                     | Deletes a file                                                                             |
| man                                                             | Gives help information on a command                                                        |
| history                                                         | Gives a list of all past basic Linux commands list typed in the current terminal session   |
| clear                                                           | Clears the terminal                                                                        |
| mkdir directoryname                                             | Creates a new directory in the present working directory or a at the specified path        |
| rmdir                                                           | Deletes a directory                                                                        |
| mv                                                              | Renames a directory                                                                        |
| pr -x                                                           | Divides the file into x columns                                                            |
| pr -h                                                           | Assigns a header to the file                                                               |
| pr -n                                                           | Denotes the file with Line Numbers                                                         |
| lp -nc lpr c                                                    | Prints “c” copies of the File                                                              |
| lp -d  lpr -P                                                   | Specifies name of the printer                                                              |
| apt-get                                                         | Command used to install and update packages                                                |
| mail -s ‘subject’ -c ‘cc-address’ -b ‘bcc-address’ ‘to-address’ | Command to send email                                                                      |
| mail -s “Subject” to-address < Filename                         | Command to send email with attachment                                                      |

#### Summarize this post with:

ChatGPT Perplexity Grok Google AI 

**Stay Updated on AI** **Get Weekly AI Skills, Trends, Actionable Advice.** 

##### Sign up for the newsletter

Subscribe for Free 

 You have successfully subscribed.  
Please check your inbox.

![AI-Newsletter]() Chosen by over **350,000+** professionals 

[Scroll to top ](#wrapper)Scroll to top 

× 

Toggle Menu Close 

Search for: 

Search 

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://www.guru99.com/#organization","name":"Guru99","sameAs":["https://www.facebook.com/Guru99Official","https://twitter.com/guru99com"],"logo":{"@type":"ImageObject","@id":"https://www.guru99.com/#logo","url":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","contentUrl":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","caption":"Guru99","inLanguage":"en-US"}},{"@type":"WebSite","@id":"https://www.guru99.com/#website","url":"https://www.guru99.com","name":"Guru99","publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https://www.guru99.com/images/must-know-linux-commands-top-image.png","url":"https://www.guru99.com/images/must-know-linux-commands-top-image.png","width":"1202","height":"541","inLanguage":"en-US"},{"@type":"BreadcrumbList","@id":"https://www.guru99.com/must-know-linux-commands.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":"1","item":{"@id":"https://www.guru99.com","name":"Home"}},{"@type":"ListItem","position":"2","item":{"@id":"https://www.guru99.com/linux","name":"Linux"}},{"@type":"ListItem","position":"3","item":{"@id":"https://www.guru99.com/must-know-linux-commands.html","name":"Basics Linux/Unix Commands with Examples &#038; Syntax (List)"}}]},{"@type":"WebPage","@id":"https://www.guru99.com/must-know-linux-commands.html#webpage","url":"https://www.guru99.com/must-know-linux-commands.html","name":"Basics Linux/Unix Commands with Examples &#038; Syntax (List)","dateModified":"2026-01-02T13:12:44+05:30","isPartOf":{"@id":"https://www.guru99.com/#website"},"primaryImageOfPage":{"@id":"https://www.guru99.com/images/must-know-linux-commands-top-image.png"},"inLanguage":"en-US","breadcrumb":{"@id":"https://www.guru99.com/must-know-linux-commands.html#breadcrumb"}},{"@type":"Person","@id":"https://www.guru99.com/author/emily","name":"Emily Carter","description":"I'm Emily Carter, a Linux Development Specialist with expertise in kernel development, system architecture, and performance tuning.","url":"https://www.guru99.com/author/emily","image":{"@type":"ImageObject","@id":"https://www.guru99.com/images/emily-carter-author-120x120.png","url":"https://www.guru99.com/images/emily-carter-author-120x120.png","caption":"Emily Carter","inLanguage":"en-US"},"worksFor":{"@id":"https://www.guru99.com/#organization"}},{"headline":"Basics Linux/Unix Commands with Examples &#038; Syntax (List)","description":"Empower your tech skills with a solid grasp of Basics Linux/Unix Commands essential for navigating and controlling your open-source OS efficiently.","dateModified":"2026-01-02T13:12:44+05:30","image":{"@id":"https://www.guru99.com/images/must-know-linux-commands-top-image.png"},"author":{"@id":"https://www.guru99.com/author/emily","name":"Emily Carter"},"@type":"Article","name":"Basics Linux/Unix Commands with Examples &#038; Syntax (List)","articleSection":"Linux","@id":"https://www.guru99.com/must-know-linux-commands.html#schema-32621","isPartOf":{"@id":"https://www.guru99.com/must-know-linux-commands.html#webpage"},"publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US","mainEntityOfPage":{"@id":"https://www.guru99.com/must-know-linux-commands.html#webpage"}},{"@type":"VideoObject","embedUrl":"https://www.youtube.com/embed/_TlK0-5EJ-Y","name":"Basics Linux/Unix Commands with Examples &#038; Syntax (List)","description":"Empower your tech skills with a solid grasp of Basics Linux/Unix Commands essential for navigating and controlling your open-source OS efficiently.","uploadDate":"2020-01-26T00:00:00+05:30","thumbnailUrl":"https://www.guru99.com/images/ls-R(1).png","hasPart":[],"width":"560","height":"315","@id":"https://www.guru99.com/must-know-linux-commands.html#schema-508100","isPartOf":{"@id":"https://www.guru99.com/must-know-linux-commands.html#webpage"},"publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US"}]}
```
