Linux

List of 51 Linux Commands for Beginners

Table of Contents

Linux is a top-rated platform on the internet.  Linux is a free and open-source operating system, meaning anyone can use, modify, and distribute it without cost or restrictions.

It powers many devices and systems, including personal computers, servers, supercomputers, smartphones (Android), and embedded devices.

As per the stats, nearly 97% of websites on the internet use Linux servers and 55.9% of professional developers depend upon Linux for their professional needs.

Next,

Linux also has shortcuts! Yes, you heard it right.

Those shortcuts help to end the task quickly. Linux consists of commands and one or two words that perform various operations in no time. In this article, we will mention the handpicked list of Linux Commands.

So, it’s time to hit the road!

What are the Linux Commands?

Linux commands provide you control over the system from the command line interface (CLI) instead of using a mouse or trackpad. They are text instructions written into the terminal to inform your system exactly what to do.

The commands you mentioned on the Linux terminal are case–sensitive and follow a syntax like “command – options arguments.” You can combine those commands for complex tasks using pipelines and redirection.

Check below a few key things to understand the Linux Commands:

  • Case sensitive
  • Follow particular syntax
  • They are combined for complex operations using pipelines and redirection.
  • You get fine–grained control over your system, which is hard to get over with graphical interfaces.
  • You can automate tasks via shell scripts and batch processing.
  • You can use it to operate system resources like the file system, network, memory, and CPU.
  • You can form the basis of interaction with Linux servers and operating systems.

If you’re a programmer and want to learn coding then you start practicing Linux commands without leaving Windows using the Windows Subsystem for Linux.

You can operate Linux within Windows without dual booting and get the best of both operating systems.

File Management Commands in Linux

This is a common task on the Linux command line.

ls (list): Lists the contents of a directory.

Syntax: ls [options] [directory]

Options in ls:

ls -l: Shows detailed information about files and directories, including permissions, owner, size, and modification date.

ls -a: Shows hidden files (those starting with a dot).

cd (change directory): Changes the current working directory.

Syntax: cd [directory]

Options:

cd ~: Goes to your home directory.

cd ..: Goes up one directory level.

cd ~/pictures – Allow to move into the pictures folder in the home directory of the user you currently logged in with.

pwd (print working directory): Prints the full path of your current working directory.

mkdir (make directory): Creates a new directory.

Syntax: mkdir [options] <directory>

Options:

mkdir -p: Creates parent directories if they don’t exist.

rmdir (remove directory): Removes an empty directory.

Syntax: rmdir [options] <directory>

Options:

-v: Verbose output when deleting directories

-p: Remove main directories recursively as per need.

cp (copy): Copies files or directories.

Syntax: cp [options] source destination

Options:

cp -r: Copies directories recursively (including all subdirectories and files).

Syntax: cp -r /home/user/documents /backups/

mv (move): Moves or renames files or directories.

Syntax: mv [options] source destination

Options:

-i: Check before overwriting any existing files at the destination location. This eliminates overwriting of data mistakenly done.

-v: Outgrow verbose output displays each file or directory as it’s moved. This is useful for approving the exact moved file.

rm (remove): Deletes files or directories.

Syntax: rm [options] name

Options:

rm -r: Deletes directories recursively (use with caution!).

rm -f: Forces deletion without prompting for confirmation.

cat (concatenate): Displays the entire contents of a file.

Syntax: cat (older file name) > (newer file name)

Options:

show-all, -A: It is the same as -vET.

–number-nonblank, -b: It tells the total non-empty output lines. Also, it overrides -n.

-e: It is the same as -vE.

–show-ends, -E: It displays the $ symbol at the completion of all lines.

less (display file content page by page): Views long files one page at a time, allowing for scrolling up and down and searching text.

Syntax: less [option] [name or location of the file]

Options:

-E – It auto exits at the end of the file.

-f – It forces non–regular files to be opened

-F – Exit if the entire file can be shown on the first screen

-g – Showcase the string that was found by the last search command.

head (show first lines of a file): Displays the first few lines of a file.

Syntax: head [option] file_name

Options:

-n – display a specific number of lines

-c – display a specific number of bytes

-v – display the file name tag

-q – avoid separating the content of various files with a file name tag

tail (show last lines of a file): Displays the last few lines of a file.

Syntax: tail [+ -[number] [lbcr]  ] [file]

Options:

-l, -b or -c

find (search for files): Searches for files based on various criteria, such as name, size, permissions, and modification time.

Syntax: find [path] [criteria]

Options:

-type f – Look for only normal files, eliminate directories.

-mtime +30 – Look for the file’s modification over 30 days ago.

-user jane – Look for files belonging to user “jane.”

du (disk usage): Estimates file space usage

syntax: du [options] [path]

Options:

-h – Shows file sizes in a readable way to humans in a format like K for Kilobytes rather than a byte count.

-s – Only display the total size for a directory, rather than listing each subdirectory and file.

-a – Highlight solo file sizes in addition to totals. Useful to locate large files.

touch (create empty file): Creates a new empty file or updates the timestamp of an existing file.

Syntax: touch [options] file_name

Options

-a – alter the access time only

-c – file creation is suppressed if the file doesn’t exist

-d – Sets access and modification times with the help of specified STRING.

-m – changes modification time

-r – uses the access and modification times from the reference file

chmod (change file permissions): Changes the read, write, and execute permissions of files and directories.

Syntax: chmod permission filename

Search and Filter Commands in Linux

Next in the list are search and filter commands that help you to alter and manipulate text right from the Linux command line.

17)grep: Filters text files for lines matching a specified pattern, case-sensitive by default.

Example: grep “error” log.txt (searches for “error” within log.txt)

Syntax: grep [options] pattern [files]

Options:

-i- Passover case distinctions in patterns

-R- Repetitively look for subdirectories

-c- Print only a count of matching lines

-v- reverse match, print non–matching lines

Example: sed ‘s/old/new/g’ file.txt (replaces “old” with “new” throughout file.txt)

syntax: sed options ‘commands’ input-file  

Some beneficial sed commands:

s – Search and replace text

/pattern/d – Delete lines matching a pattern

10,20d – Delete lines 10-20

1,3!d – Delete all except lines 1-3

awk: Powerful pattern scanning and processing language for text data

Syntax: awk ‘pattern {action}’ input-file

Advanced awk capabilities:

Allow to compute fields mathematically

Conditional statements

Develop functions for manipulating strings, numbers, and dates

Output formatting control

sort: Sorts lines of text alphabetically or numerically.

Syntax: sort [options] [file]

Useful sort options:

-n – Sort numerically instead of alphabetically

-r – Reverse the sort order

-k – Sort based on a specific field or column

uniq: Reports or removes duplicate lines from a sorted file.

Syntax: uniq [options] [input]

Options:

-c – Ending unique lines with the count of occurrences.

-d- showcase the duplicate lines

wc: Counts lines, words, and characters in a file.

Syntax: wc [options] [file]

Options:

-l – Print only the line count.

-w – Print only the word count.

-c – Print only the byte count.

Archive Commands

Archiving commands help you to bundle various files and directories into compressed archive files for easy portability and storage. Usual archive formats in Linux include .tar, .gz, and .zip

Features:

tar is the most versatile archiving command in Linux, capable of creating, extracting, listing, and modifying archives.

gzip and bzip2 are compression utilities often used in conjunction with tar to create compressed archives.

zip is a popular cross-platform archive format, often used for Windows compatibility.

rar is a proprietary format with higher compression ratios but is less common in Linux environments.

Choose the appropriate command based on the desired compression level, compatibility requirements, and personal preferences.

tar – Store and Extract Files from An Archive: Creating archives

Syntax:

tar [options] filename

Useful tar options

-c – Develop a new .tar archive file.

-x – Extract files from a .tar archive.

-f – Tells archive filename rather than stdin/stdout.

-v – Verbose output showing archived files.

-z – Compress or uncompress the archive with gzip.

unzip – Extracting zip archives

Syntax: unzip archive.zip

It is the same as gunzip, the unzip command extracts and uncompresses the files from the .zip archives.

zip – creating zip archives

Syntax: zip [options] archive.zip filenames

Options:

-r – Repetitively zip a directory

-e – Encrypt content with a strong password

File Transfer Commands

The file transfer command helps you to move files between systems over a network. It’s beneficial for moving the files to remote servers or downloading the content from the internet.

scp: Securely copies files between local and remote systems using SSH.

Scp syntax copies files from a source path to a defined destination as user@host:

scp source user@host:destination

Example: scp file.txt user@remote_host:/home/user

rsync: Efficiently synchronizes files and directories between locations, often used for backups and mirroring.

Syntax: rsync [options] source destination

options

-a – Archive mode syncs repe

Archive mode syncs repetitively and holds permissions, times, etc.

-h – Human-readable output.

-v – Verbose output

Example: rsync -a /source/directory /destination/directory

curl: Transfers data to or from a server, and supports various protocols that consist of REST, HTTP, FTP, etc.

Example: curl -o file.zip https://example.com/file.zip

Options:

-o – write output to file

-I – display response headers only

– L – follow rediects

It’s developed to transfer data across the network programmatically.

wget: Downloads files from web servers using HTTP or FTP protocols.

Example: wget https://example.com/file.zip

Options:

-c – resume interrupted download

-r – continuous downloading

-o – save to a particular filename

wget is suitable for automatic downloads and mirroring websites.

sftp: Secure File Transfer Protocol client for interactive file transfers over SSH.

Example: sftp user@remote_host

It connects to the host to accept the commands like:

sftp user@host

get remotefile localfile

put localfile remotefile

It redeems the remotefile from the server and copies localfile to the remote host. Sftp has an interactive shell for moving the file systems, transferring files and directories, and managing the permissions and properties.

File Permission Commands

chown – Change File Owner and Group

The chown command changes ownership of a file or directory. Ownership includes two components – the user who is the owner, and the group it belongs to.

Example:

chown steav:developers file.txt

The above-mentioned example will set the owner user to “steav” and the owner group to “developers”. Only the root superuser account is able to use Chown to monitor the file owners. It’s used to fix permission problems by monitoring the owner and group as per need.

umask – allow to set default file permissions

This command controls the default permissions given to newly created files. It takes an octal mask as input that substracts from 666 for files and 777 for directories.

Example:

Umask 007

New files permission is default 750 instead of 666, and new directories to 700 instead of 777. Setting an unmask allows you to configure default file permissions rather than relying on system defaults. The umask command is beneficial for restricting permissions on new files without relying on someone’s guide and manually adding restrictions.

chmod – change File Modes or Access Permissions

This command is beneficial to alter the access permissions or modes of files and directories. The permission modes inform who can read, write, or execute the file.

Example:

chmod 755 file.txt

These are three sets of permissions – owner, group, and public. Permissions are set using numeric modes from 0 to 7:

7 – read, write, and execute.

6 – read and write.

4 – read only.

0 – no permission.

You can set owner permissions to 7 (rwx), group to 5 (r-x), and public to 5 (r – x). You can also reference users and groups symbolically.

Chmod g+w file.text

The g+w syntax adds group write permission to the file.

Making a proper setting of file and directory permissions is important for Linux security and controlling access. Chmod leads to flexible control to configure permissions precisely as per the need.

Redirection Command in Linux

Redirection is a powerful feature in Linux that allows you to change the standard input (stdin) and standard output (stdout) of commands. This means you can send the output of a command to a file, read input from a file instead of the keyboard, or even pipe the output of one command to the input of another command.

> (greater than): Redirects standard output to a file. Overwrites existing content.

Example: ls -l > file_list.txt saves the output of ls -l to file_list.txt.

This will execute ls -l to list the contents of the /home directory.

Then, instead of printing that output to the terminal, the > symbol captures that standard output and writes t to homelist.txt, overwriting any existing file contents.  

Redirecting standard output is beneficial for saving command results to files for storage, debugging, or chaining commands together.

>> (double greater than): Appends standard output to a file. Preserves existing content.

Example: echo “New text” >> file_list.txt adds “New text” to the end of file_list.txt.

This will append the last 10 lines of the syslog log file onto the end of logfile.txt. Unlike >, >> adds the output without erasing the current logfile .txt contents.

Appending is useful in gathering command output in one place without losing existing data.

< (less than): Redirects standard input from a file.

Example: grep “error” < logfile.txt searches for “error” within logfile.txt.

The < redirection operator feeds a file’s contents as standard input to a command rather than taking input from the keyboard. Redirecting input is beneficial for batch–processing files and automating workflows.

| (pipe): Sends the standard output of one command as the standard input of another command.

Example: ls -l | less displays the output of ls -l in the less pager for easier viewing.

This pipe the output of ls -l into the less command where you can scroll via file listing. Piping is beneficial to chain together commands where the output of one feed the input of another. Further, developing the complex operations out of smaller single – purpose programs.

Process Management Commands

ps: Displays a snapshot of current processes.

ps aux shows detailed information about all running processes.

For example:

ps aux

Options: aux – display processes for all users

–forest – shows tree of parent/child processes

ps gives you the flexibility to check what is going on in your system.

top: Provides a real-time, interactive view of processes, including CPU and memory usage.

Useful for monitoring system performance and identifying resource-intensive processes.

For example:

top -u mysql

The above command checks the processes just for the “mysql” user. It’s beneficial for identifying resource-intensive programs.

kill: Sends a signal to a process to terminate it.

  1. kill PID sends the SIGTERM signal to the process with ID PID.
  2. kill -9 PID sends the SIGKILL signal, which forcefully terminates the process.

It gives the signal to a process to terminate or kill it. Signals allow easy shutdown if the process handles them.

For example:

kill -11 12345

The above command sends the SIGTERM (11) signal to stop the process with PID 12345 smoothly.

pkill: Kills processes by name or other attributes.

  1. pkill Firefox kills all processes named “firefox”.

For example:

pkill -9 firefox

It ends all firefox processes with SIGKILL (9). It targets operations by making equal name, user, and other criteria than PID.

User Management Commands

useradd (or adduser on some systems): Creates a new system user account.

Example: useradd della creates a user named “della” with default settings.

Use options to specify the home directory, shell, password expiration, etc.

usermod: Modifies existing user account properties.

Examples: usermod -l new_name old_name changes the username.

usermod -d /home/new_home john changes the home directory.

usermod -aG group1,group2 john adds the user to multiple groups.

usermod -L john locks the account (prevents login).

usermod -U john unlocks the account.

userdel: Deletes a user account.

  1. userdel della deletes the user “john”.
  2. userdel -r della additionally removes the user’s home directory and mail spool.
  3. userdel -f – force to delete even if the user is logged in or running any process actively.

This forces the removal of user “della”, and also deletes the files.  

Identifying options like -r and -f with userdel leads the user account to delete even if the user is logged in or has active operations.

groupadd: Creates a new group.

Example: groupadd developers create a group named “developers”.

Options:

-r – develop a system group used for core system functions.

-g – Specify the new group’s GID instead of using the next available.

The above command creates a new “sysadmin” group with system privileges. When creating new groups, the -r or -g allows it to be set up correctly.

passwd: Sets or changes a user’s password.

The passwd command sets or updates a user’s authentication password/tokens. This allows you to alter the login password.

For example:

passwd della

This prompts user “della” to enter a new password mutually. If you’ve forgot the password for an account then you can login to Linux with sudo or su privileges and change the password using the similar method.

Networking Commands

ping: Checks connectivity to a remote host by sending ICMP echo requests.

Options:

-c [count] – limit packets sent

-i – [interval] – wait interval seconds between pings

In the above command, you ping google.com and output round–trip stats informing connectivity and latency. Generally, ping is useful to check if the system you’re trying to connect to is working and connected to the network.  

ifconfig (or ip addr): Displays information about network interfaces, including IP addresses, MAC addresses, and status.

Example:

ifconfig interface_name IP_address interface_name – name of the network interface. 

IP_address – IP address that is assigned to the network interface.

Using ifconfig with no other arguments will give you a list of all the network interfaces that are   available to use, along with IP and extra network information.  ifconfig can be used to set addresses, enable / disable interfaces, and changes options.

netstat (or ss): Displays active network connections, sockets, and routing tables.

For example:

netstat -pt tcp

This command will generate all the active TCP connections and the processes that are using them.

traceroute (or mtr): Traces the path of network packets to a destination, identifying potential bottlenecks or routing problems.

For example:

   traceroute google.com

   This monitors the path to connect google.com and generates each network hop.

iptables – IPv4 Packet Filtering And NAT

This helps you to configure Linux netfilter firewall rules to check and process network packets. It develops policies and rules for how to handle the system in a different type of inbound and outbound connections and traffic.

For example:

iptables -A INPUT -s IP address -j DROP

The above command will block all input from IP

It offers superior control over the Linux kernel firewall to monitor routing, NAT, packet filtering, and other traffic control. It’s an important tool for protecting Linux servers.

Wrapping Up

Elevate your Linux game with these 50 beginner commands.

Our new blog post is all about Linux commands for beginners. Whether you’re looking to automate tasks, navigate directories, or manage files, these commands will help you get the job done.


Ekta Tripathi
A passionate Digital Marketing Ex and Content Writer working with Hostripples. I am passionate about writing blogs related to Information Technology and Digital Marketing. In my free time, I love to listen songs, spend time with my daughters and hang around social networking sites.

Recent Posts

The Ultimate Showdown: Linux vs Windows for VPS Hosting

As the demand for virtual private servers (VPS) continues to grow, businesses and individuals are faced with a crucial decision:…

2 weeks ago

Questions to Ask Your Web Hosting Support Team

Web hosting is a large industry, as many other factors help any web hosting provider to form a company. The…

2 weeks ago

How to Secure Your WordPress Site in 2025

Welcome to the complete guide to WordPress security best practices in 2024. As technology evolves rapidly, implementing strong security measures…

3 weeks ago

Unlocking the Secrets of Hosting: Essential Questions to Ask Hostripples

Hey, wanted to learn about web hosting? Or do you want to start a new website and need hosting? Questions…

3 weeks ago

DDoS Attacks: What You Need to Know for Protection

In today's digital world, the threat of DDoS attacks has become increasingly prevalent. These types of attacks have the power…

1 month ago