---
title: "65 commonly used Linux commands"
description: "The following commonly used Linux commands allow users to perform numerous tasks using the Command Line Interface (CLI) instead of the Graphical User Interface (GUI), increasing control and speed. Lis..."
url: https://www.stackscale.com/blog/linux-commands/
date: 2022-12-15
modified: 2024-01-24
author: "Marketing Stackscale"
image: https://www.stackscale.com/wp-content/uploads/2022/12/linux-commands-shell-Stackscale.jpg
categories: ["Systems"]
tags: ["Linux"]
type: post
lang: en
---

# 65 commonly used Linux commands

The following commonly used Linux commands allow users to perform numerous tasks using the Command Line Interface (CLI) instead of the Graphical User Interface (GUI), increasing control and speed.

## List of some of the most used Linux commands

The following list includes helpful and interesting Linux commands to use distributions more effectively and enjoy greater control. Although they are GNU/Linux commands, they also run in most Unix and BSD systems.

> Linux commands are case-sensitive.

### Alias command

The `alias` command allows users to create temporary shortcuts for other commands and command options during a shell session. To list all aliases in the session, just run the `alias` command without an argument.

Syntax:

alias [-option] Name=String

An useful option to used with the `alias` command is `-p`, to print all the aliases that have been defined during a session in a reusable format.

### Apt command

The `apt` command is used to install, remove and manage packages in Debian and Debian-based distributions like Ubuntu. It requires using the `sudo` command or root privileges.

Syntax:

apt [-option] packagename

Some of the options that can be added to the `apt` command are:

- `install` to install a package.
- `update` to update the package index.
- `remove` to remove an installed package.

`apt` replaces the older `apt-get` command.

### Cal command

The `cal` command displays a calendar on the terminal. Syntax:

cal or cal month year

### Cd command

The `cd` command, short for “change directory”, is used to navigate through directories. It requires using the `sudo` command or root privileges.

Syntax:

cd /path or cd directory

When used without an option, it takes the user to the home folder. Some useful options to save time when changing directories are:

- `..` to move a level up.
- `-` to return to the previous directory.

### Chmod command

The `chmod` command is used to modify a file or directory’s read, write and execute permissions. Syntax:

chmod [-option] permission filename

Some of the options that can be added to the `chmod` command are:

- `-c` to display information when a change is made.
- `-v` to display a diagnostic for each processed file.

### Chown command

The `chown` command allows users to change the ownership of a file, directory or symbolic link to another username. Syntax:

chown [-option] owner:group file

Some of the options that can be added to the `chown` command are:

- `-c` to report when a change is made.
- `-f` to suppress most error messages.

### Clear command

The `clear` command is used to clear the terminal screen. Syntax:

clear

### Cmp command

The `cmp` command can be used to check if two files are identical. Syntax:

cmp

### Comm command

The `comm` command allows combining the functionalities of the `[diff](#diff)` and `[cmp](#cmp)` commands. It compares two sorted files line by line, displaying results in three columns, if no options are used. The first column contains the lines of the first file, the second column contains the lines of the second file and the third column contains the matching lines.

Syntax:

comm [-option]

Some of the options that can be added to the `comm` command are:

- `-1`, `-2` or `-3` to remove the number’s respective column.
- `-check-order` to verify if all lines of both files are properly sorted.

### Cp command

The `cp` command is used to copy files, folders and directories. It is possible to copy several files at the same time as well.

Syntax:

cp filename.extension /destination_directory

Some of the options that can be added to the `cp` command are:

- `—backup[=t]` to make a numbered backup of each existing destination file.
- `-l` to make hard links instead of copying.
- `-s` to make soft or symbolic links instead of copying.

It can also be used to copy a file’s content into another file. In this case, the syntax would be:

cp filename.extension new_file.extension

### Df command

The `df` command can be used to report the system’s disk space usage. Data is not readable by default, therefore it is often used together with the option `-h` to display the information in a human-readable format.

Syntax:

df [-option] filename

Some of the options that can be added to the `df` command are:

- `-T` to add a column indicating the filesystem type.
- `-m` to display the information in MBs.

### Diff command

The `diff` command, short for “difference”, is used to find differences between two files. It compares the content of both files, line by line, displaying the pieces that do not match.

Syntax:

diff [-option] filename_1 filename_2

Some of the options that can be added to the `diff` command are:

- `-i` to make the command case insensitive.
- `-u` to avoid the display of redundant information.

### Du command

The `du` command can be used to check a folder or directory’s storage space usage. This is useful to identify which part of a system is using an excessive amount of storage space.

Syntax:

du /directory/path

Some of the options that can be added to the `du` command are:

- `-h` to display the last modification date of folders and files.
- `-s` to get the total size of a particular folder.

### Echo command

The `echo` command is used to display a line of text or string in the terminal. Syntax:

echo [-option] string

Some of the options that can be added to the `echo` command are:

- `-n` to remove the trailing new line when displaying the output.
- `-e` to enable the interpretation of backslash escapes, such as `\b`, to remove spaces in between text.
- `-E` to disable the `-e` option and go back to the default display.

### Exit command

The `exit` command is used to end the current shell session, and it automatically closes the terminal in most Linux distributions. Syntax:

exit

### Find command

The [`find` command](https://www.stackscale.com/blog/find-command-linux/) is used to locate files in Linux, based on user-specified criteria. It filters files by filename and metadata.

Syntax:

find [-option] /path expression

Some of the options that can be added to the `find` command are:

- `-name` to find files by name.
- `-maxdepth` to limit the search to a maximum number of sub-directories.

To search files based on their content, it must be used together with the `[grep](#grep)` command.

### Free command

The `free` command is used to display a summary of memory usage — total, used, free, shared and available space, both for RAM and swap. Syntax:

free [-option]

Some of the options that can be added to the `free` command are:

- `-g` to display the information in gibibytes (GiB).
- `-l` to display detailed memory statistics.

### Grep command

The `grep` command is used to find content within files. Syntax:

grep “content” filename.extension

Some of the options that can be added to the `grep` command are:

- `-V` to display the version number of `grep`.
- `-i` to ignore lower and upper cases.

It can be used together with the `find` command to search files based on their content.

### Head command

The `head` command is used to display the first ten lines of a text. Syntax:

head [-option] filename

Some of the options that can be added to the `head` command are:

- `-n X` to display a customized number of lines.
- `-q` to avoid displaying the filename before the lines, when searching several files at a time.

### History command

The `history` command is used to display a list of the commands executed in the past. It requires using the `[sudo](#sudo)` command or root privileges.

Syntax:

history [-option]

Some of the options that can be added to the `history` command are:

- `-c` to clear the history list.
- `X` to specify the maximum number of results to be displayed in the list.

### Hostname command

The `hostname` command is used to know the system’s hostname. Syntax:

hostname [-option]

Some of the options that can be added to the `hostname` command are:

- `-i` to display the machine’s IP.
- `-f` to display the machine’s Fully Qualified Domain Name (FQDN).

### Htop command

The `htop` command is used to monitor system resources and server processes in real time. It allows vertical and horizontal scrolling and it is available in most [Linux distributions](https://www.stackscale.com/blog/popular-linux-distributions/).

Syntax:

htop [-option]

Some of the options that can be added to the `htop` command are:

- `-u` to only display the processes of a given user.
- `-d` to display the delay between updates in tenths of seconds.

### Ifconfig command

The `ifconfig` command, short for “interface configuration”, is used to display a list of all network interfaces together with the IP and MAC addresses, as well as other additional information.

Syntax:

ifconfig [-option]

### Ip command

The `ip` command is used to configure network interfaces. It can be used to bring them up and down, assign and remove addresses and routes, and much more.

Syntax:

ip [-option] object command

### Jobs command

The `jobs` command is used to display all the running processes and their status. It is only available in the following shells: bash, csh, ksh and tcsh.

Syntax:

jobs [-option] jobID

Some of the options that can be added to the `jobs` command are:

- `-n` to list jobs whose status has changed since the last modification.
- `-p` to only list process IDs.

### Kill command

The `kill` command is used to terminate an unresponsive program or process manually, when impossible to close it otherwise. Syntax:

kill signal_option processID

Run the following command to know the program’s process ID: `ps`

This command can be used with many different signals. The most commonly used are:

- `SIGTERM` to request a program to stop running, giving it time to save all its progress. When not specifying a particular signal, this is the default mode.
- `SIGKILL` to force a program to stop running without saving its progress.

### Less command

The `less` command can be used to inspect large files backward and forward, as it allows scrolling through the file using the Enter and Space keys. Syntax:

less filename.extension

Some of the options that can be added to the `less` command are:

- `-?` to display a summary of the commands accepted by `less`.
- `-I` to ignore low and upper cases.

### Ln command

The `ln` command, short for “link”, can be used to create hard and soft or symbolic links to files and directories.

On the one hand, a **hard link** is a mirror of the original file, and shares the same [inode](https://www.stackscale.com/blog/inodes-linux/) number. Hard links are not deleted if the original file is. On the other hand, a **soft or symbolic link** is basically a shortcut that makes reference to the original file, without retaining its data. In case of deleting the original file, the soft link will no longer work.

The command’s default setting is intended for creating hard links, as they can only be created on the command line.

Syntax:

ln /path reference_name

Syntax to create the link in a different directory:

ln /path /alternative_path/reference_name

In order to create a symbolic link, add the `-s` option:

ln -s /path reference_name

### Ls command

The `ls` command is used to list files and directories within a system. Without specifying a path, it shows the contents in the current working directory.

Syntax:

ls /path

Some of the options that can be added to the `ls` command are:

- `-a` to show hidden files as well.
- `-R` to also list the files in the subdirectories.

### Man command

The `man` command can be used to get the manual of any command that can be run in the terminal. Syntax:

man [-option] command_name

Some of the options that can be added to the `man` command are:

- `-k` to search a command as a regular expression in all the manuals.
- `-f` to know the sections in which a command is present.

### Mkdir command

The `mkdir` command is used to create a directory or multiple directories at once. It also allows setting their respective permissions.

Syntax:

mkdir [-option] directory_name

Some of the options that can be added to the `mkdir` command are:

- `-mXXX` to set the permissions.
- `-p` to create a directory between two directories.

### Mv command

The `mv` command is used to move and rename files and directories.

Syntax to move:

mv filename.extension /path

Syntax to rename:

mv filename.extension new_filename.extension

Some of the options that can be added to the `mv` command are:

- `-n` to avoid overwriting an existing file.
- `-u` to move only when the destination file is missing or the source file is newer than the destination file.

### Nano command

The `nano` command is used to edit and manage files, and is compatible with most languages. Syntax:

nano filename

Some of the options that can be added to the `nano` command are:

- `-B` to backup the previous version of a file when saving it; suffixing the filename with a tilde (~).
- `-u` to save a file by default in Unix format.

### Pacman command

The `pacman` command is used to install, remove and manage packages in Arch Linux and Arch-based distributions like Manjaro. Syntax:

pacman [-option] package_name

### Passwd command

The `passwd` command can be used to add and change user passwords.

Syntax to add a password to an user after creating it with the `[useradd](#useradd)` command:

passwd strong_password

Syntax to change the user password:

passwd

### Ping command

The `ping` command is used to test network connectivity. It is also used to troubleshoot some connectivity issues.

Syntax:

ping [-option] hostname_or_IP

### Ps command

The `ps` command, short for “process status”, outputs a snapshot of the running processes in the system. Along with each process, it displays the following details: process ID (PID), type of terminal (TTY), running time (TIME) and the command that launches the process (CMD).

Syntax:

ps [-option]

Some of the options that can be added to the `ps` command are:

- `-u` to display the user associated with each process.
- `-T` to display the current shell session associated with each process.

### Pwd command

The `pwd` command can be used to find the path of the current working directory. Syntax:

pwd [-option]

Some of the options that can be added to the `pwd` command are:

- `-P` to display the physical directory, without symbolic links. This is the option by default if no option is specified.
- `-version` to display information about the version.

### Reset command

The `reset` command reboots the terminal, restoring settings to default. Its execution takes longer than the clear command.

Syntax:

reset

### Rm command

The `rm` command is used to delete files and folders within a directory. It requires having write permissions.

Syntax:

rm filename

Some of the options that can be added to the `rm` command are:

- `-f` to ignore nonexistent files and arguments.
- `-d` to remove empty directories.

It must be carefully used, as it is difficult to recover files and directories deleted with this command.

### Service command

The `service` command is used to start, stop and restart services. Syntax:

service service_name -option

The main options of this command are: `start`, `stop` and `restart`.

### Shutdown command

The `shutdown` command can be used to power off, halt and reboot a machine. The default syntax immediately shuts down the machine.

Syntax:

shutdown now

### Ssh command

The `ssh` command is used to connect to an external machine on the network using the [SSH protocol](https://www.stackscale.com/blog/ssh-protocol/). Syntax:

ssh username@hostname

Some of the options that can be added to the `ssh` command are:

- `-4` to force the use of IPv4 addresses only.
- `-6` to force the use of IPv6 addresses only.
- `-q` to enable quiet mode.

### Su command

The `su` command, short for “switch user”, allows users to run a program as another user. Syntax:

su [-option] ]

Some of the options that can be added to the `su` command are:

- `-g` to specify the primary group (only available to the root user).
- `-s` to run the specified shell instead of the default one.

When used without an option or argument, it runs through root privileges and requires authentication and the use of `sudo` privileges temporarily.

### Sudo command

The `sudo` command, short for “super do”, is used to perform tasks requiring admin or root permissions. In case the user does not authenticate himself when trying to run the command, the system will log the activity as a security event.

Syntax:

sudo (command)

Some of the options that can be added to the `sudo` command are:

- `-E` to indicate to the security policy that the user wishes to preserve his existing environment variables.
- `-k` to invalidate the user’s cached credentials, when used without a command.

By default, the command can be run for 15 minutes per session.

### Tail command

The `tail` command is used to display the last ten lines of a file, to check for updates and error messages. Syntax:

tail [-option] filename

Some of the options that can be added to the `tail` command are:

- `-q` to avoid displaying headers specifying filnames.
- `--retry` to keep trying to open a file if it is inaccessible.

### Tar command

The `tar` command is used to archive files or directories into a .tar file, with optional compression. Syntax:

tar [-option] archive_filename file_to_be_archived

Some of the options that can be added to the `tar` command are:

- `-c` to create a new archive.
- `-t` to list the contents of an archive.

### Top command

The `top` command can be used to discover the processes consuming the most resources. It displays all running processes and a dynamic real-time view of the system, including details such as CPU and memory usage.

Syntax:

top

### Touch command

The `touch` command can be used to create new files in the current directory. Adding options, it also allows modification of timestamps.

Syntax:

touch [-option] filename.extension

Some of the options that can be added to the `touch` command are:

- `-a` to change the access time.
- `-m` to change the modification time.

### Traceroute command

The `traceroute` command can be used to check the route packets take to a particular host, as well as the time it takes, by specifying its hostname, IP address or domain name.

Syntax:

traceroute hostname

### Unalias command

The `unalias` command can be used to delete alias created with the `[alias](#alias)` command. Syntax:

unalias alias_name

Some of the options that can be added to the `unalias` command are:

- `-a` to remove all the aliases.

### Uname command

The `uname` command, short for “Unix name”, outputs detailed information about the Linux operating system and hardware. Syntax:

uname [-option]

Some of the options that can be added to the `uname` command are:

- `-s` to display the kernel name.
- `-a` to display all the system information.

### Unzip command

The `unzip` command is used to extract zipped files from an archive. Syntax:

unzip [-option] filename.zip

### Useradd command

The `useradd` command allows the creation of new users. It requires using the `[sudo](#sudo)` command or root privileges.

Syntax:

useradd [-option] username

### Userdel command

The `userdel` command allows removing existing users. It requires using the [``](https://docs.google.com/document/d/1Qvwm0_LdlqpVTWKHP3NojO7rb5N3vyOzA2ZfS8jlf3U/edit#heading=h.oilb74xkqybe)`[sudo](#sudo)` or root privileges.

Syntax:

userdel username

### Usermod command

The `usermod` command allows the modification of existing users. It requires using the [``](https://docs.google.com/document/d/1Qvwm0_LdlqpVTWKHP3NojO7rb5N3vyOzA2ZfS8jlf3U/edit#heading=h.oilb74xkqybe)`[sudo](#sudo)` or root privileges.

Syntax:

usermod username

### Vi command

The `vi` command is used to edit and manage files. Syntax:

vi filename

It has two operating modes:

- `insert` to edit and create text files.
- `command` to perform basic operations such as opening, copying, pasting and saving.

### Wc command

The `wc` command, short for “word count”, outputs the number of lines and words in a text file, as well as its byte-size. Syntax:

wc filename.extension

Some of the options that can be added to the `wc` command are:

- `-c` to display the byte counts.
- `-m` to display the character counts.

### Wget command

The `wget` command can be used to download files from the Internet. Syntax:

wget [-option] url

Some of the options that can be added to the `wget` command are:

- `-o` to log all messages to log file.
- `-nv` to turn off the command’s output, except for error messages and basic information.

### Whatis command

The `whatis` command outputs what any command can be used for. Syntax:

whatis command_name

### Whereis command

The `whereis` command is used to find the path of the command typed in after it. Syntax:

whereis command

### Which command

The `which` command is used to identify the path of a particular executable. Syntax:

which [-option] filename

### Whoami command

The `whoami` command, short for “who am I”, can be used to display the username in use. Syntax:

whoami

### Yum command

The `yum` command is used to install, remove and manage packages in RHEL and Red Hat-based distributions like CentOS. Syntax:

yum [-option] package_name

### Zip command

The `zip` command is used to compress a file or several files into the ZIP universal format. It is also useful for archiving files and directories, thus reducing disk usage.

Syntax:

zip [-option] zip_file filename

## Basic Linux commands summary

| Command | Usage |
| --- | --- |
| `alias` | Create a shortcut for other commands and command options. |
| `apt` | Install, remove and manage packages in Debian-based distros. |
| `cal` | Display a calendar on the terminal. |
| `cd` | Navigate through Linux directories. |
| `chmod` | Modify a file or directory’s read, write and execute permissions. |
| `chown` | Change the ownership of a file, directory or symbolic link to another username. |
| `clear` | Clear the terminal screen. |
| `cmp` | Check if 2 files are identical. |
| `comm` | Combine the functionalities of the `[diff](#diff)` and `[cmp](#cmp)` commands. |
| `cp` | Copy and paste files, content, folders and directories. |
| `df` | Report the system’s disk space usage. |
| `diff` | Compare the content of 2 files to find not matching pieces of content. |
| `du` | Check how much storage space a folder or directory takes up. |
| `echo` | Display a line of text or string in the terminal. |
| `exit` | Exit the current shell session. |
| `find` | Search files directly from the command line. |
| `free` | Display a summary of memory usage. |
| `grep` | Find content within files. |
| `head` | Display the first 10 lines of a text. |
| `history` | Display a list of the commands executed in the past. |
| `hostname` | Know the system’s hostname. |
| `htop` | Monitor system resources and server processes in real time. |
| `ifconfig` | Display a list of all network interfaces together with the IP and MAC addresses, and other additional information. |
| `ip` | Configure network interfaces. |
| `jobs` | Display all the running processes and their status. |
| `kill` | Terminate an unresponsive program or process manually. |
| `less` | Inspect large files backward and forward, scrolling with the Enter and Space keys. |
| `ln` | Create hard and soft links to other files. |
| `ls` | List files and directories within a system. |
| `man` | Get the manual of any command that can be run in the terminal. |
| `mkdir` | Create a directory or multiple directories at once, and their respective permissions. |
| `mv` | Move and rename files and directories. |
| `nano` | Edit and manage files; compatible with most languages. |
| `pacman` | Install, remove and manage packages in Arch-based distros. |
| `passwd` | Add and change user passwords. |
| `ping` | Test network connectivity. |
| `ps` | Output a snapshot of the running processes in the system. |
| `pwd` | Find the path of the current working directory. |
| `reset` | Reboot the terminal, restoring settings to default. |
| `rm` | Delete files and folders. |
| `service` | Start, stop and restart services. |
| `shutdown` | Power off, halt and reboot a machine. |
| `ssh` | Connect to an external machine on the network using the SSH protocol. |
| `su` | Run a program as a different user. |
| `sudo` | Perform tasks requiring admin or root permissions. |
| `tail` | Display the last 10 lines of a file. |
| `tar` | Archive files or directories into a .tar file. |
| `top` | Discover the processes consuming the most resources. |
| `touch` | Create new files and modify timestamps. |
| `traceroute` | Check the route packets take to a particular host, as well as the time it takes. |
| `unalias` | Delete alias defined with the `[alias](#alias)` command. |
| `uname` | Output detailed information about the Linux operating system and hardware. |
| `unzip` | Extract zipped files from an archive. |
| `useradd` | Create a new user. |
| `userdel` | Delete existing users. |
| `usermod` | Modify existing users. |
| `vi` | Edit and manage files. |
| `wc` | Output the number of lines and words in a text file, as well as its byte-size. |
| `wget` | Download files from the Internet. |
| `whatis` | Output any command’s functionality. |
| `whereis` | Delete files and folders. |
| `which` | Identify the path of a particular executable. |
| `whoami` | Display the username in use. |
| `yum` | Install, remove and manage packages in RHEL-based distros. |
| `zip` | Compress files into the ZIP universal format. |

## Useful shortcuts for the Linux Command Line Interface

The following table includes some useful shortcuts for using the [Linux](https://www.stackscale.com/blog/linux/) Command Line Interface.

| **Shortcut** | **Usage** |
| --- | --- |
| Ctrl + A | Moving to the beginning of the line. |
| Ctrl + C | Terminating a running command. |
| Ctrl + E | Moving to the end of the line. |
| Ctrl + Q | Undoing the terminal freeze. |
| Ctrl + S | Temporarily freezing the terminal. |
| Ctrl + Z | Pausing a working command. |
| Tab | Auto-filling after entering a command with an argument. |
| ; | Separating commands, when executing multiple ones in a single line. |
| && | Allowing the next command to run if the previous one is successful, when executing several commands in a single line. |
