Reading time: 6 mins

31 Basic Linux Commands You Must Know

By Team Agaetis, April 7, 2023
Linux Commands

Linux is famous for its easily accessible commands. By using the Linux command line, users can navigate the file system, view and edit files, create directories, and run scripts. Every Linux user should know a few basic commands while using this operating system.

Before we begin, please note: 
  •  Linux commands are case-sensitive.
  • “$” indicates the start of a command
  • “#” indicates the end of a command and the start of a comment
Top Linux commands you can use:
  1. ls – The ls command is used to list all the files and directories in the current directory. You can run this command without any parameters.

Syntax:

ls


This can be useful if you need to find a particular file or if you want to know what files are in the current directory. Additionally, this command can also be used to get information about the files and directories, such as the size, type, and timestamp.

Example:

ls command Example
  1. cd – change the current working directory
    This can quickly and easily switch between different directories, allowing you to access the files you need swiftly.

Syntax:

cd <directory name>  

Example:

cd Command Example
  1. pwd – print the current working directory

Syntax:

pwd

Example:

pwd Linux Command
  1. mkdir – create a new directory in the current working directory.  

Syntax:

mkdir <directory name>

Example:

mkdir Linux Command
  1. rmdir – To delete a directory, use the rmdir command.

Syntax:

rmdir <directory name> 

Example:

rmdir Linux Command
  1. touch – The touch command is used to create a new or empty file. It can also be used to create multiple empty files at once.

Syntax:

touch <file name>  
touch <file1>  <file2> 

Example:

touch Linux Command
  1. cat –  cat or Concatenate allows you to display the contents of a file, create a file, copy the content of one file to another file, etc.

Syntax:

To display the content of the file:

cat <file name>  

To create a file:

cat > [file name]

To copy content from an old to a new file:

cat [oldfile] > [newfile]

Tip: You can save the file by pressing “CTRL+D” 

Example:

cat Linux Command
  1. tac As its name suggests, tac is the reverse of cat. The file content is displayed in reverse order from the last line.

Syntax:

tac <file name> 

Example:

tac Linux Command

  1. cp – The cp helps you to copy a file or directory

Syntax:
To copy the source file to Destination, execute it as follows:

cp [option] Source Destination

To copy the source file to Directory, run the following command:

cp [option] Source Directory

Example:

cp Linux Command
  1. wc – Using the wc command, you can count the lines, words, and characters in a file.

Syntax:

wc <file name>  

Example:

wc Linux Command

  1. mv – The mv command allows you to move a file from one location to another, rename a file or directory

Syntax:

mv <file name> <directory path>

Example:

mv Linux Command
  1. rm – This command allows you to remove a file

Syntax:

rm <file name>

Example:

rm Linux Command
  1. sort – Use the sort command in order to sort files alphabetically.

Syntax:

sort <file name>  

Example:

sort Linux Command

  1. head – The head command displays the content of a file. You can view the first 10 lines of a file.

Syntax:

head <file name>  

Example:

head Linux Command

  1.  tail – Similar to the head command, the tail command allows you to view the last 10 lines of a file.

Syntax:

tail <file name>  

Example:

tail Linux Command

  1. more – Similar to the cat command, you can use the more command to display the contents of the file. The key difference is that more command displays a full-screen output at a time.

Syntax:

more <file name> 

Example:

more Command example
more Linux Command

  1. less – As the name suggests, the less command is used to display the contents of a file one screen at a time. Due to the fact that it accesses files page by page, it is useful when dealing with large text files.

Syntax:

less <file name> 

Example:

less Linux Command
less command example

  1. find – You can use it to find files and directories.

Syntax:

find / -name

Example:

find Linux Command

  1. time –  You can display the time it takes to run a command with this command.

Syntax:

time 

Example:

time Linux Command

  1. su – The su command helps you to provide administrative access to another user. 

Syntax:

su <user name>

Example:

su Linux Command

  1. useradd – Using useradd, you can add or remove users on Linux servers.

Syntax:

useradd  username  

Example:

useradd Linux Command

  1. passwd – With the help of the passwd command, you can create and change the password for a user.

Syntax:

passwd <username>

Example:

passwd Linux Command
  1. sudo sudo (superuser do) 

elevates a user’s permissions to execute a command as the superuser (root)

Syntax:

sudo <command>

Example:

sudo Linux Command

  1. grep – The grep (global regular expression print) command is the most powerful command and filter there is. With it, you can search for a pattern/content in a file. 


Syntax:

grep  <search string>  <filename>

  1. tr  – You can use the tr command to translate the file content.

Syntax:

tr -cds STRING1 STRING2  
  1. df – The df (disk free) command displays the amount of free disk space available on the file system.

Syntax:

df
  1. du – Using the du command (disk usage), you can determine how much space a file or directory takes up.

Syntax:

du
  1. uniq –

The uniq command creates a sorted list in which every word appears only once.

Syntax:

command <file name> | uniq  
  1. ssh: You can use the ssh command to connect to a remote server over a secure shell (SSH) protocol

Syntax:

ssh user_name@host(IP/Domain_name)
  1. history – You can use the history command to view the list of previously executed commands.

Syntax:

history
  1. man – The  man command displays the user manual for any command you execute. It is an inbuilt manual for all commands on Linux.

Syntax:

man [option] [section number] [command name]

Linux has many more commands, but these are some of the most commonly used. 

Bonus: What are manual pages in Linux?

The purpose of man pages is to help users understand how the Linux commands are used. The pages are installed by default alongside the commands. Whenever a software developer creates a man page, it will serve as an explanation of how to use that specific command.

You can learn more about each command by using the manual pages. Simply type “man command_name” in the terminal, and there you have it!

Hope our article helped you know more about the Basic Linux Commands. Save this article to your bookmarks for future reference!


Is it your dream to have your own website? Agaetis is here to help you! Contact us today!

Share

Let’s build something together

About Agaetis

The word Agaetis means excellence. Keeping up with the name, we at Agaetis Technologies are firm believers in sparing no effort to deliver excellence through our work. Our websites are crafted with love and care that enables our clients to engage with visitors on a higher plane.

Design

Brandbook | Portfolio Design | UI Design | UX Design | Social Media Banners| Social Media Posts | Website Design | Ecommerce Design | User Experience | Interface Design | Prototyping | Responsive Design

Web Application Development

Custom Development | Ecommerce Development | Enterprise Frameworks Integrations | Dynamic Websites | Headless CMS Development | Wordpress | API Integration | Saas Solutions | Paas Solutions | Social Networking | CRM Developments | ERP Developments | Invoice Generators | Custom Wordpress Theme creation | Custom Opencart Theme creation | Opencart Development | Shopify

Website Development

Offshore Web Development | Portfolio Website | Company Website | Blogs

Strategy & Consultation

Digital Strategy | Market Research | Content Strategy | Analysis | Ecommerce Strategy | Technical Consultation

Digital Marketing

SEO/SEM | SMM | SEO Audit Report | Pagespeed Report | Data insights and analysis report.