Top Most Basic And Advanced Command In Linux

Regularly using Linux commands? Today, let’s explore 50+ essential Linux commands you should know. These are some of the most useful and frequently used commands.

We’ll be running these commands on an Ubuntu server, but you can follow along on any modern Linux system.

Here’s a more natural and user-friendly version of your list:

  1. ls – List the contents of a directory.
  2. pwd – Show the current directory you’re in.
  3. cd – Move between directories.
  4. mkdir – Create a new folder.
  5. mv – Move or rename files.
  6. cp – Copy files or folders.
  7. rm – Delete files or directories.
  8. touch – Create an empty file.
  9. ln – Make a shortcut (symbolic link) to a file.
  10. clear – Clean up the terminal screen.
  11. cat – View the contents of a file.
  12. echo – Print text to the terminal.
  13. less – View a file’s contents page by page.
  14. man – Open the manual for any command.
  15. uname – Display basic system info.
  16. whoami – Show your current logged-in username.
  17. tar – Compress or extract files.
  18. grep – Search for text within files.
  19. head – Show the first few lines of a file.
  20. tail – Show the last few lines of a file.
  21. diff – Compare two files and show differences.
  22. cmp – Check if two files are exactly the same.
  23. comm – Find common and unique lines between files.
  24. sort – Arrange lines in a file in order.
  25. export – Set environment variables.
  26. zip – Compress files into a .zip archive.
  27. unzip – Extract files from a .zip archive.
  28. ssh – Securely connect to another computer over the network.
  29. service – Start, stop, or restart services.
  30. ps – See a list of running programs (processes).
  31. kill / killall – Stop a process by its ID or name.
  32. df – Check available disk space.
  33. mount – Attach a storage device or partition.
  34. chmod – Change file permissions.
  35. chown – Change the owner of a file or folder.
  36. ifconfig – Show network connection details.
  37. traceroute – See the path data takes to reach a website.
  38. wget – Download files from the internet.
  39. ufw – Manage the firewall settings.
  40. iptables – Advanced firewall control.
  41. apt / pacman / yum / rpm – Install or remove software based on your Linux distribution.
  42. sudo – Run a command with admin (root) privileges.
  43. cal – Display a calendar in the terminal.
  44. alias – Create shortcuts for commands.
  45. dd – Copy data, often used for making bootable USBs.
  46. whereis – Find where a command is stored on the system.
  47. whatis – Get a quick description of a command.
  48. top – See running processes and system usage live.
  49. useradd / usermod – Add a new user or modify an existing one.
  50. passwd – Set or change a user’s password.

Let’s take a closer look at each of these commands and break them down in more detail. We already have plenty of articles covering each one individually. To make things easier for you, we’ll include links to those existing articles and keep updating this guide as we cover new topics.

The ls command

The ls command lets you see the files and folders in your current location. It’s one of the most useful Linux commands you’ll use often.

# ls

Running the command without any arguments will list all the files and directories in the current folder. It also provides various options to customize how the information is displayed.

The pwd command

The pwd command simply shows you the folder you’re currently in. It’s a simple but useful tool for finding your way around in the terminal.

# pwd

Your terminal prompt usually shows the full directory path, but if it doesn’t, this command helps you quickly check where you are. It’s also useful in scripts to find the directory where the script is saved.

The cd command

When working in the terminal, moving between directories is essential. The cd command is one of the key Linux commands you should know—it lets you navigate through folders. Just type cd followed by the directory name.

# cd

The mkdir command

The mkdir command lets you quickly create folders right from the terminal.

# mkdir dir

As you can see in the screenshot above, we created the “dir” directory using a simple command.

The cp and mv commands

The cp and mv commands in Linux work like copy-paste and cut-paste in Windows. Since Linux doesn’t have a separate rename command, we use mv to rename files and folders as well.

# cp

In the above command, we created a copy of the file.

Let’s see what happens when we use the mv command the same way.

# mv

Since the file was moved within the same directory, it was simply renamed. The file name has now changed.

The rm command

The rm command is used to delete files and folders in Linux. It’s a key command that every Linux user should know.

# rm file

To delete a directory, use the -r option with the rm command. Without it, rm won’t remove directories.

# rm -r dir

The -r flag in the rm command stands for “recursive.” This means it doesn’t just delete a file—it removes entire folders along with everything inside them, including subfolders and their files.

Note:- Be careful when using rm -r, as it can permanently delete a lot of files and folders fast. To stay safe, use -i with it—this will ask for confirmation before each delete.

# rm -ri dir1/

This will prompt you for confirmation before deleting each file and directory.

The touch command

The touch command in Linux makes a new empty file or refreshes the time on an old one.

# touch file

The ln command

To link one file to another in Linux, you can use the ln command. It’s a key command every Linux admin should know!

# ln -s file file_copy
# ls -l

The -s flag makes a shortcut, called a symbolic link (or symlink), to a file or folder. It’s like a pointer that directs you to the original location.

The clear command

The clear command in Linux wipes the terminal screen, removing all text and giving you a fresh start.

# clear

Note:- The clear command doesn’t delete any files or data—it just refreshes your terminal screen.

The cat, echo, and less commands

To display the contents of a file or print a message in the terminal, we use the cat or echo command.

# cat file
# echo file

The cat command displays the contents of a file, while the echo command simply prints whatever you type after it.

The less command helps when a command’s output is too long to fit on the screen. It lets you scroll through the text using the Enter or Space keys, making it easier to read.

# cat /etc/passwd | less

Note:- Use less -S to wrap long lines, so you don’t have to scroll sideways. Add -N to show line numbers, making it easier to find specific lines.

# cat /etc/passwd | less -SN

The man command

The man command in Linux shows the manual for a specific command, including how to use it, available options, and examples.

# man cat

The uname and whoami commands

The uname and whoami commands are useful for quickly checking system details, especially when working on multiple machines.

The uname command in Linux shows details about the system’s kernel, like its name, version, release, and the type of hardware it’s running on.

# uname -a

The parameter -a with uname command stands for “all”. This prints out the complete information. 

Here are some useful flags you can use with the uname command:

  • uname -s: Shows the kernel name.
  • uname -n: Displays the system’s hostname.
  • uname -r: Reveals the kernel release version.
  • uname -v: Provides details about the kernel version.
  • uname -m: Tells you the machine’s hardware type.

The tar, zip, and unzip commands

The tar command in Linux is used to create and extract archive files. You can even extract multiple archives at once with it.

To create an archive, use the -c option. To extract files from an archive, use -x.

# tar -cvf myfile.tar file file1 file2 file3

Let’s talk about the zip and unzip commands. They’re simple to use—just run them without any extra options, and they’ll do the job. Here’s an example to show how they work.

# zip myfile.zip file file1 file2 file3
# unzip myfile.zip

The grep command

The grep command stands for “global regular expression print,” meaning it can search for patterns in text across multiple files and lines.

# cat /etc/passwd | grep root

The head and tail commands

The head and tail commands let you quickly peek at the start or end of a file without opening it in a text editor. By default, they show the first or last 10 lines, but you can change that using the -n option followed by the number of lines you want to see.

#  head /etc/passwd
#  tail /etc/passwd

The diff, comm, and cmp commands

The diff, comm, and cmp commands in Linux and Unix help compare files. They let you find differences, merge changes, and check if files are the same.

# diff file file1

The cmp command only shows the line number where the difference occurs, not the actual content that differs.

# cmp file file1

The comm command compares two sorted files and shows the differences—what’s unique in each file and what they have in common.

# comm file file1

Note:- The diff, comm, and cmp commands are handy tools for comparing files in Linux and Unix. Knowing how to use them helps you spot differences, merge changes, and manage files more efficiently.

The sort command in Linux

The sort command in Linux and Unix sorts lines in a text file or from standard input. You can use it to arrange lines in ascending or descending order, sort by specific fields, or even define a custom sorting method.

# sort file

The export command

The export command in Linux and Unix is used to set environment variables, which store information that programs and commands can use.

# export <variable name>=<value>

The ssh command

The ssh command lets you securely connect to another computer or server. It encrypts the connection, so you can safely run commands and transfer files.

# ssh username@remote-server
# ssh root@192.168.1.10
The `ssh` command is super flexible! You can use it to:  

- Set up different login methods (password, public key, etc.)  
- Choose encryption algorithms  
- Enable compression for faster transfers  
- Forward ports for remote access  
- Use X11 forwarding for GUI apps  
- Manage SSH keys for secure connections  

The service command

The service command in Linux helps manage background system processes, like networking, databases, and authentication. You can use it to start, stop, restart, or check the status of services. It works as a shortcut for the more advanced systemctl command, which controls the system’s service manager.

# service ssh status
# service ssh stop
# service ssh start 

The ps, kill, and killall commands

The ps, kill, and killall commands help you check and manage running processes in Linux.

The ps command shows details about the processes currently running on your system. Here are some examples of how to use it:

# ps -ef

Display a list of all running processes

Display a list of all processes for a specific process ID (PID)

# ps -p PID
# ps -p 3
# ps

To stop a process, just type kill followed by its PID (Process ID).

# kill 2367
# killall bash

The df and mount commands

In Linux, the df and mount commands are handy tools for checking disk space and managing filesystems.

The df command shows how much disk space is used and available on your system.

# df -h

The mount command connects a storage device or file system to a folder, making it accessible.

# mount /dev/cdrom /mnt

The chmod and chown commands

Use chmod to change file permissions and chown to change file ownership in Linux.

The chmod command lets you change who can access or modify a file or folder.

# chmod +rwx file

The chown command changes who owns a file or folder.

# chown www-data:www-data file

The ifconfig and traceroute commands

The ifconfig command helps manage network connections, while traceroute shows the path network packets take.

The ifconfig command shows all network interfaces, including their IP and MAC addresses, plus other details.

# ifconfig

The traceroute command shows the path network packets take to reach a destination. Just enter an IP address, hostname, or domain name to see the route.

# traceroute google.com

The wget command

If you need to download a file using the terminal, the wget command is a super useful tool. It’s one of those essential Linux commands that come in handy when dealing with source files.

# wget https://wordpress.org/wordpress-6.7.2.tar.gz

The ufw and iptables commands

UFW and iptables help manage firewalls on Linux.

UFW and IPTables are both tools for managing the Linux firewall. IPTables directly sets firewall rules for Netfilter, while UFW provides a simpler way to configure those rules before passing them to IPTables.

# iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
# ufw allow 80

Package Managers in Linux

Different Linux distributions come with their own package managers, which are tools used to install and manage software. If you’re on Ubuntu, you’ll use apt, but if you’re working on a different distro like Fedora, Arch, or CentOS, the commands will be different. Here’s a quick cheat sheet:

  • Debian/Ubuntu: apt install <package>
  • Arch Linux: pacman -S <package>
  • Red Hat/CentOS/Fedora: yum install <package>

Getting comfortable with your distro’s package manager will make your life a lot easier. Even if you have a GUI-based tool, try using the command line first—it’s faster, more powerful, and a great skill to have!

The sudo command

The first time a sudo-enabled user runs the sudo command, they escalate their privileges. This works like temporarily switching to the root user, depending on their granted permissions.

# sudo df -h

The cal command

Simply type cal in your terminal to see a nicely formatted calendar.

# cal

The whereis and whatis commands

The whereis and whatis commands in Linux help you find details about programs and files.

The whereis command finds the location of a program’s binary, source, and manual pages, while the whatis command gives a brief description of a command.

# whereis pwd
# whatis pwd

The top command

The top command in Linux shows real-time system activity, like CPU and memory usage, plus running processes. It helps monitor system performance live.

# top

The useradd command

The adduser command is just a shortcut for useradd, and both do the same job—creating a new user in Linux.

# adduser ak

The passwd command

Now that you know how to create new users, let’s set their passwords too! You can use the passwd command to set a password for your own account, or if you have the right permissions, for other users as well.

# passwd ak

The dd command

The dd command in Linux is a powerful tool for copying and converting data at a low level. It’s often used to back up or clone storage devices. For example, to create an exact copy of one hard drive onto another, you can use the dd command.

# dd if=/dev/sdb of=/dev/sda

The alias command

Do you find yourself typing the same long commands over and over in the terminal? Maybe it’s rm -r, ls -l, or something longer like tar -xvzf. If so, there’s a simple way to save time and boost your productivity—create an alias!

An alias is just a shortcut for a command you use frequently. Instead of typing out the full command every time, you can set up a short, custom name for it. It’s a small trick that can make a big difference in your workflow!

# alias lsl="ls -l"
# lsl

Leave a Reply

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